Skip to content

Commit

Permalink
🔀 Merge branch 'ladislas/feature/add-light-gray-background'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Dec 13, 2023
2 parents e3cbc53 + c1bd050 commit 1cc82de
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct GEKNewSystemView: View {
ActivityView(viewModel: ActivityViewViewModel(activity: activity))
}
.buttonStyle(.borderedProminent)
.frame(maxWidth: .infinity)
}
.navigationTitle("List of Activities")
}
Expand Down
36 changes: 36 additions & 0 deletions Apps/LekaActivityUIExplorer/Sources/MainApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
138 changes: 73 additions & 65 deletions Apps/LekaActivityUIExplorer/Sources/Navigation/NavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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())
}
13 changes: 13 additions & 0 deletions Modules/DesignKit/Sources/Colors.swift
Original file line number Diff line number Diff line change
@@ -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 }
}
44 changes: 0 additions & 44 deletions Modules/DesignKit/Sources/ContentView.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public struct ActivityView: View {

self.continueButton
}
.background(.lkBackground)
.ignoresSafeArea(.all, edges: .bottom)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
Expand Down
11 changes: 1 addition & 10 deletions Modules/RobotKit/Sources/UI/Views/RobotConnectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public struct RobotConnectionView: View {
.padding(.top, 15)
.padding(.bottom, 40)
}
.background(BackgroundView())
.background(.lkBackground)
.onAppear {
self.viewModel.scanForRobots()
}
Expand All @@ -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
Expand Down

0 comments on commit 1cc82de

Please sign in to comment.