From c4b30b7f75fe5ec087e63b1673941638a741d0f1 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Mon, 11 Dec 2023 10:37:28 +0100 Subject: [PATCH 1/6] :fire: (DesignKit): Remove unused ContentView --- Modules/DesignKit/Sources/ContentView.swift | 44 --------------------- 1 file changed, 44 deletions(-) delete mode 100644 Modules/DesignKit/Sources/ContentView.swift diff --git a/Modules/DesignKit/Sources/ContentView.swift b/Modules/DesignKit/Sources/ContentView.swift deleted file mode 100644 index 30ec75552e..0000000000 --- a/Modules/DesignKit/Sources/ContentView.swift +++ /dev/null @@ -1,44 +0,0 @@ -// Leka - iOS Monorepo -// Copyright 2023 APF France handicap -// SPDX-License-Identifier: Apache-2.0 - -import SwiftUI - -// MARK: - Hello - -public struct Hello: View { - // MARK: Lifecycle - - public init(_ name: String, in color: Color) { - self.name = name - self.color = color - } - - // MARK: Public - - public var body: some View { - VStack { - Text("Hello, \(self.name)!") - .padding(50) - .background(self.color) - - Image(uiImage: DesignKitAsset.Assets.lekaLogo.image) - .resizable() - .scaledToFit() - .frame(width: 200.0) - } - } - - // MARK: Internal - - let name: String - let color: Color -} - -// MARK: - ContentView_Previews - -struct ContentView_Previews: PreviewProvider { - static var previews: some View { - Hello("World", in: .pink) - } -} From 6841db5b986e6d7fc6e9313755bb2d08d8ea9b5e Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Mon, 11 Dec 2023 12:36:53 +0100 Subject: [PATCH 2/6] :lipstick: (DesignKit): Add Color extension for leka colors --- Modules/DesignKit/Sources/Colors.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Modules/DesignKit/Sources/Colors.swift diff --git a/Modules/DesignKit/Sources/Colors.swift b/Modules/DesignKit/Sources/Colors.swift new file mode 100644 index 0000000000..ae53b78b01 --- /dev/null +++ b/Modules/DesignKit/Sources/Colors.swift @@ -0,0 +1,13 @@ +// Leka - iOS Monorepo +// Copyright 2023 APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import SwiftUI + +public extension Color { + static let lkBackground: Color = .init(uiColor: .systemGray6) +} + +public extension ShapeStyle where Self == Color { + static var lkBackground: Color { .lkBackground } +} From 98535c3ddb3fa3edc70e34c13ba5c056b010e279 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Mon, 11 Dec 2023 15:04:34 +0100 Subject: [PATCH 3/6] :children_crossing: (RobotKit): RobotConnectionView - remove cloud image background, replace with color --- .../Sources/UI/Views/RobotConnectionView.swift | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Modules/RobotKit/Sources/UI/Views/RobotConnectionView.swift b/Modules/RobotKit/Sources/UI/Views/RobotConnectionView.swift index 672f322f01..8aadbd034e 100644 --- a/Modules/RobotKit/Sources/UI/Views/RobotConnectionView.swift +++ b/Modules/RobotKit/Sources/UI/Views/RobotConnectionView.swift @@ -43,7 +43,7 @@ public struct RobotConnectionView: View { .padding(.top, 15) .padding(.bottom, 40) } - .background(BackgroundView()) + .background(.lkBackground) .onAppear { self.viewModel.scanForRobots() } @@ -65,15 +65,6 @@ public struct RobotConnectionView: View { // MARK: Internal - struct BackgroundView: View { - var body: some View { - DesignKitAsset.Images.interfaceCloud.swiftUIImage - .resizable() - .aspectRatio(contentMode: .fill) - .ignoresSafeArea(.all) - } - } - @StateObject var viewModel: RobotConnectionViewModel @Environment(\.dismiss) var dismiss From aedce6c4a7eaf93480bcfbcc0456abcbe45bc39d Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Mon, 11 Dec 2023 15:46:34 +0100 Subject: [PATCH 4/6] :lipstick: (GEK): Add .lkBackground to ActivityView and list --- .../Sources/GEKNewSystem/GEKNewSystemView.swift | 2 ++ .../Sources/_NewSystem/Views/Activity/ActivityView.swift | 1 + 2 files changed, 3 insertions(+) diff --git a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift index d374986e6a..529cfb1034 100644 --- a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift +++ b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift @@ -61,7 +61,9 @@ struct GEKNewSystemView: View { ActivityView(viewModel: ActivityViewViewModel(activity: activity)) } .buttonStyle(.borderedProminent) + .frame(maxWidth: .infinity) } + .background(.lkBackground) .navigationTitle("List of Activities") } } diff --git a/Modules/GameEngineKit/Sources/_NewSystem/Views/Activity/ActivityView.swift b/Modules/GameEngineKit/Sources/_NewSystem/Views/Activity/ActivityView.swift index 991526ade4..1068a071a9 100644 --- a/Modules/GameEngineKit/Sources/_NewSystem/Views/Activity/ActivityView.swift +++ b/Modules/GameEngineKit/Sources/_NewSystem/Views/Activity/ActivityView.swift @@ -35,6 +35,7 @@ public struct ActivityView: View { self.continueButton } + .background(.lkBackground) .ignoresSafeArea(.all, edges: .bottom) .navigationBarTitleDisplayMode(.inline) .toolbar { From 757845221e43cde392654e6d63af1a9ebbd279fd Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Wed, 13 Dec 2023 11:08:02 +0100 Subject: [PATCH 5/6] :lipstick: (GEK): Remove .lkBackground activity list --- .../Sources/GEKNewSystem/GEKNewSystemView.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift index 529cfb1034..cbb5c70b35 100644 --- a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift +++ b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift @@ -63,7 +63,6 @@ struct GEKNewSystemView: View { .buttonStyle(.borderedProminent) .frame(maxWidth: .infinity) } - .background(.lkBackground) .navigationTitle("List of Activities") } } From c1bd05039496d976c8be07399a84821a09d8def1 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Wed, 13 Dec 2023 12:53:04 +0100 Subject: [PATCH 6/6] :alembic: (UIExplorer): Add very basic style manager to switch between Apple, Leka's style --- .../Sources/MainApp.swift | 36 +++++ .../Sources/Navigation/NavigationView.swift | 138 +++++++++--------- 2 files changed, 109 insertions(+), 65 deletions(-) diff --git a/Apps/LekaActivityUIExplorer/Sources/MainApp.swift b/Apps/LekaActivityUIExplorer/Sources/MainApp.swift index c0cfecd04f..2917def7e7 100644 --- a/Apps/LekaActivityUIExplorer/Sources/MainApp.swift +++ b/Apps/LekaActivityUIExplorer/Sources/MainApp.swift @@ -2,13 +2,49 @@ // Copyright 2023 APF France handicap // SPDX-License-Identifier: Apache-2.0 +import DesignKit import SwiftUI +// MARK: - StyleManager + +// TODO: (@ladislas) Replace by DesignSystem +class StyleManager: ObservableObject { + @Published var accentColor: Color? + @Published var colorScheme: ColorScheme = .light + + func setDefaultColorScheme(_ colorScheme: ColorScheme) { + self.colorScheme = colorScheme + } + + func toggleAccentColor() { + self.accentColor = if self.accentColor == nil { + DesignKitAsset.Colors.lekaDarkBlue.swiftUIColor + } else { + nil + } + } + + func toggleColorScheme() { + self.colorScheme = self.colorScheme == .light ? .dark : .light + } +} + +// MARK: - LekaActivityUIExplorerApp + @main struct LekaActivityUIExplorerApp: App { + @Environment(\.colorScheme) var colorScheme + @StateObject var styleManager: StyleManager = .init() + var body: some Scene { WindowGroup { NavigationView() + .tint(self.styleManager.accentColor) + .preferredColorScheme(self.styleManager.colorScheme) + .environmentObject(self.styleManager) + .onAppear { + self.styleManager.setDefaultColorScheme(self.colorScheme) + } } } } diff --git a/Apps/LekaActivityUIExplorer/Sources/Navigation/NavigationView.swift b/Apps/LekaActivityUIExplorer/Sources/Navigation/NavigationView.swift index 480503e97e..ab0e32e8d2 100644 --- a/Apps/LekaActivityUIExplorer/Sources/Navigation/NavigationView.swift +++ b/Apps/LekaActivityUIExplorer/Sources/Navigation/NavigationView.swift @@ -39,65 +39,7 @@ class NavigationViewViewModel: ObservableObject { // MARK: - NavigationView struct NavigationView: View { - struct CategoryLabel: View { - // MARK: Lifecycle - - init(category: Category) { - self.category = category - - switch category { - case .home: - self.title = "Home" - self.systemImage = "house" - - case .activities: - self.title = "Activities" - self.systemImage = "dice" - - case .experimentations: - self.title = "Experimentation" - self.systemImage = "flask" - - case .designSystemAppleFonts: - self.title = "Apple Fonts" - self.systemImage = "textformat" - - case .designSystemAppleButtons: - self.title = "Apple Buttons" - self.systemImage = "button.horizontal" - - case .designSystemAppleColorsSwiftUI: - self.title = "Apple Colors SwiftUI" - self.systemImage = "swatchpalette.fill" - - case .designSystemAppleColorsUIKit: - self.title = "Apple Colors UIKit" - self.systemImage = "swatchpalette" - - case .designSystemLekaButtons: - self.title = "Leka Buttons" - self.systemImage = "button.horizontal" - - case .designSystemLekaColorsSwiftUI: - self.title = "Leka Colors SwiftUI" - self.systemImage = "swatchpalette.fill" - } - } - - // MARK: Internal - - let category: Category - let title: String - let systemImage: String - - var body: some View { - Label(self.title, systemImage: self.systemImage) - .tag(self.category) - } - } - - @Environment(\.colorScheme) var colorScheme - @State var preferedColorScheme: ColorScheme = .light + @EnvironmentObject var styleManager: StyleManager @ObservedObject var navigation: Navigation = .shared @StateObject var viewModel: NavigationViewViewModel = .init() @@ -131,13 +73,21 @@ struct NavigationView: View { CategoryLabel(category: .designSystemLekaColorsSwiftUI) } } - // TODO(@ladislas): remove if not necessary + // TODO: (@ladislas) remove if not necessary // .disabled(navigation.disableUICompletly) .navigationTitle("Categories") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button { - self.preferedColorScheme = self.preferedColorScheme == .light ? .dark : .light + self.styleManager.toggleAccentColor() + } label: { + Image(systemName: "eyedropper") + } + } + + ToolbarItem(placement: .topBarTrailing) { + Button { + self.styleManager.toggleColorScheme() } label: { Image(systemName: "circle.lefthalf.filled") } @@ -180,17 +130,75 @@ struct NavigationView: View { } } } - .preferredColorScheme(self.preferedColorScheme) - .onAppear { - self.preferedColorScheme = self.colorScheme - } .fullScreenCover(isPresented: self.$viewModel.isRobotConnectionPresented) { RobotConnectionView(viewModel: RobotConnectionViewModel()) } } } +// MARK: - CategoryLabel + +struct CategoryLabel: View { + // MARK: Lifecycle + + init(category: Category) { + self.category = category + + switch category { + case .home: + self.title = "Home" + self.systemImage = "house" + + case .activities: + self.title = "Activities" + self.systemImage = "dice" + + case .experimentations: + self.title = "Experimentation" + self.systemImage = "flask" + + case .designSystemAppleFonts: + self.title = "Apple Fonts" + self.systemImage = "textformat" + + case .designSystemAppleButtons: + self.title = "Apple Buttons" + self.systemImage = "button.horizontal" + + case .designSystemAppleColorsSwiftUI: + self.title = "Apple Colors SwiftUI" + self.systemImage = "swatchpalette.fill" + + case .designSystemAppleColorsUIKit: + self.title = "Apple Colors UIKit" + self.systemImage = "swatchpalette" + + case .designSystemLekaButtons: + self.title = "Leka Buttons" + self.systemImage = "button.horizontal" + + case .designSystemLekaColorsSwiftUI: + self.title = "Leka Colors SwiftUI" + self.systemImage = "swatchpalette.fill" + } + } + + // MARK: Internal + + let category: Category + let title: String + let systemImage: String + + var body: some View { + Label(self.title, systemImage: self.systemImage) + .tag(self.category) + } +} + +// MARK: - FormView_Previews + #Preview { NavigationView() .previewInterfaceOrientation(.landscapeLeft) + .environmentObject(StyleManager()) }