-
Notifications
You must be signed in to change notification settings - Fork 9
/
App+View.swift
67 lines (60 loc) · 1.33 KB
/
App+View.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
58
59
60
61
62
63
64
65
66
67
import ComposableArchitecture
import SwiftUI
// MARK: - App.View
extension App {
@MainActor
struct View: SwiftUI.View {
private let store: StoreOf<App>
init(store: StoreOf<App>) {
self.store = store
}
var body: some SwiftUI.View {
SwitchStore(store.scope(state: \.root, action: \.child)) { state in
switch state {
case .main:
CaseLet(
/App.State.Root.main,
action: App.ChildAction.main,
then: { Main.View(store: $0) }
)
case .onboardingCoordinator:
CaseLet(
/App.State.Root.onboardingCoordinator,
action: App.ChildAction.onboardingCoordinator,
then: { OnboardingCoordinator.View(store: $0) }
)
case .splash:
CaseLet(
/App.State.Root.splash,
action: App.ChildAction.splash,
then: { Splash.View(store: $0) }
)
}
}
.tint(.app.gray1)
.presentsLoadingViewOverlay()
.onOpenURL { url in
store.send(.view(.urlOpened(url)))
}
.task { @MainActor in
await store.send(.view(.task)).finish()
}
}
}
}
#if DEBUG
import ComposableArchitecture
import SwiftUI
struct AppView_Previews: PreviewProvider {
static var previews: some View {
App.View(
store: .init(initialState: .init()) {
App()
.dependency(\.localAuthenticationClient.queryConfig) {
.biometricsAndPasscodeSetUp
}
}
)
}
}
#endif