Skip to content

Commit

Permalink
Merge pull request #19 from sergeykhliustin/update/performance-issues
Browse files Browse the repository at this point in the history
Performance fixes
  • Loading branch information
sergiikhliustin authored Feb 13, 2023
2 parents fb8b966 + d523b12 commit 6b51d65
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Models
import BuildioLogic

enum Route {
case builds(V0AppResponseItemModel)
case builds(V0AppResponseItemModel?)
case build(BuildResponseItemModel)
case logs(BuildResponseItemModel)
case artifacts(BuildResponseItemModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SwiftUI
import Combine

final class Navigators: ObservableObject {
@Published var tabSelection: Int = 0
@Published var isPresentingModal: Bool = false
private var navigators = NSMapTable<NSString, Navigator>(valueOptions: .weakMemory)
private let screenFactory: ScreenFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ struct AccountsScreenView: View {
@EnvironmentObject private var tokenManager: TokenManager

var body: some View {

ScrollView {
LazyVStack(spacing: 16) {
ForEach(tokenManager.tokens) { token in
ListItemWrapper {
navigators.popToRootAll()
tokenManager.token = token
navigators.tabSelection = 0
} content: {
AccountRowView(token, settings: {
navigator.go(.accountSettings(token), replace: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension UIFont {
case .caption: style = .caption1
case .caption2: style = .caption2
case .footnote: style = .footnote
case .body: fallthrough
case .body: style = .body
default: style = .body
}
return UIFont.preferredFont(forTextStyle: style)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ struct CircularProgressViewStyle: ProgressViewStyle {
.frame(width: 20, height: 20, alignment: .center)
.foregroundColor(theme.accentColorLight)
.rotationEffect(Angle(degrees: 360 * progress ))
.animation(.none)

CustomProgressShape()
.frame(width: 10, height: 10, alignment: .center)
.foregroundColor(theme.accentColor)
.rotationEffect(Angle(degrees: -360 * progress))
.animation(.none)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ struct LinearProgressViewStyle: ProgressViewStyle {
CustomProgressShape()
.foregroundColor(theme.accentColor)
.frame(width: geometry.size.width * progress)
.animation(.none)
}
}
.frame(height: 2, alignment: .center)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ struct RootScreenView: View {
@State private var selection: Int = 0

var body: some View {
RootTabBarWrapper(selection: $selection) {
RootTabView(selection: $selection)
RootTabBarWrapper {
RootTabView()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import SwiftUI

struct RootTabBarWrapper<Content: View>: View {
@ViewBuilder private let content: () -> Content
@Binding private var selection: Int
@ViewBuilder let content: () -> Content
@Environment(\.windowMode) private var windowMode
@Environment(\.keyboard) private var keyboard
@Environment(\.fullscreen) private var fullscreen
Expand All @@ -29,11 +28,6 @@ struct RootTabBarWrapper<Content: View>: View {
!fullscreen.wrappedValue && !keyboard && windowMode == .compact && !(UIDevice.current.userInterfaceIdiom == .phone && navigators.isPresentingModal)
}

init(selection: Binding<Int>, _ content: @escaping () -> Content) {
self._selection = selection
self.content = content
}

var body: some View {
GeometryReader { proxy in
MainSecondaryOptionalView(
Expand All @@ -46,12 +40,12 @@ struct RootTabBarWrapper<Content: View>: View {
content()

} secondary: {
CustomTabBar(selected: $selection)
CustomTabBar(selected: $navigators.tabSelection)
.padding(.bottom, proxy.safeAreaInsets.bottom)
}

} secondary: {
CustomTabBar(style: .vertical, selected: $selection)
CustomTabBar(style: .vertical, selected: $navigators.tabSelection)
.padding(.leading, interfaceOrientation == .landscapeRight ? proxy.safeAreaInsets.leading : 0)
.zIndex(1)

Expand All @@ -62,11 +56,3 @@ struct RootTabBarWrapper<Content: View>: View {
}
}
}

struct RootTabBarWrapper_Previews: PreviewProvider {
static var previews: some View {
RootTabBarWrapper(selection: .constant(0)) {
Text("wrapped")
}
}
}
14 changes: 1 addition & 13 deletions Modules/BuildioUI/Sources/BuildioUI/UI/Root/RootTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ struct RootTabView: View {
@Environment(\.theme) private var theme
@EnvironmentObject private var navigators: Navigators

@Binding private var selection: Int

init(selection: Binding<Int>) {
self._selection = selection
}

var body: some View {
let configuration = previewMode ? RootScreenItemType.preview : RootScreenItemType.default
TabView(selection: $selection) {
TabView(selection: $navigators.tabSelection) {
ForEach(0..<configuration.count) { index in
let item = configuration[index]
splitNavigation(for: item)
Expand Down Expand Up @@ -57,9 +51,3 @@ struct RootTabView: View {
}
}
}

struct RootTabView_Previews: PreviewProvider {
static var previews: some View {
RootTabView(selection: .constant(0))
}
}

0 comments on commit 6b51d65

Please sign in to comment.