-
Notifications
You must be signed in to change notification settings - Fork 0
/
Color_Palette.swift
57 lines (48 loc) · 1.62 KB
/
Color_Palette.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// dE_CalculatorApp.swift
// dE Calculator
//
// Created by Denis Dmitriev on 17.05.2024.
//
import SwiftUI
import FirebaseAnalytics
@main
struct Color_Palette: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
@StateObject private var shop: PaletteShop = .init()
@StateObject private var chShop: CHPaletteShop = .init()
@AppStorage(UserDefaultsKey.lightMode.key)
private var lightMode: LightMode = .automatic
@Environment(\.colorScheme) private var colorScheme
var body: some Scene {
WindowGroup {
ContentView()
.onAppear {
navigationTitleAppearance()
backButtonAppearance()
}
.preferredColorScheme(preferredColorScheme)
}
.environmentObject(shop)
.environmentObject(chShop)
}
private var preferredColorScheme: ColorScheme {
switch lightMode {
case .automatic:
return colorScheme
case .light:
return .light
case .dark:
return .dark
}
}
private func navigationTitleAppearance() {
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: UIColor.appPrimary]
UINavigationBar.appearance().titleTextAttributes = [.foregroundColor: UIColor.appPrimary]
}
private func backButtonAppearance() {
let backImage = UIImage(systemName: "arrow.left")
UINavigationBar.appearance().backIndicatorImage = backImage
UINavigationBar.appearance().backIndicatorTransitionMaskImage = backImage
}
}