diff --git a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift index d374986e6a..cbb5c70b35 100644 --- a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift +++ b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift @@ -61,6 +61,7 @@ struct GEKNewSystemView: View { ActivityView(viewModel: ActivityViewViewModel(activity: activity)) } .buttonStyle(.borderedProminent) + .frame(maxWidth: .infinity) } .navigationTitle("List of Activities") } 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()) } 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 } +} 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) - } -} 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 { 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