Newer
Older
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
68
import ComposableArchitecture
import SwiftUI
public struct WelcomeView: View {
public init(store: Store<WelcomeState, WelcomeAction>) {
self.store = store
}
let store: Store<WelcomeState, WelcomeAction>
struct ViewState: Equatable {
init(_ state: WelcomeState) {
isCreatingAccount = state.isCreatingAccount
}
var isCreatingAccount: Bool
}
public var body: some View {
WithViewStore(store.scope(state: ViewState.init)) { viewStore in
NavigationView {
Form {
Section {
Text("xx messenger")
}
Section {
Button {
viewStore.send(.newAccountTapped)
} label: {
HStack {
if viewStore.isCreatingAccount {
ProgressView().padding(.trailing)
Text("Creating Account...")
} else {
Text("New Account")
}
}
.frame(maxWidth: .infinity)
}
Button {
viewStore.send(.restoreTapped)
} label: {
Text("Restore from Backup")
.frame(maxWidth: .infinity)
}
}
}
.disabled(viewStore.isCreatingAccount)
.navigationTitle("Welcome")
}
.navigationViewStyle(.stack)
}
}
}
#if DEBUG
public struct WelcomeView_Previews: PreviewProvider {
public static var previews: some View {
WelcomeView(store: Store(
initialState: WelcomeState(),
reducer: .empty,
environment: ()
))
}
}
#endif