Skip to content

Commit af32a8d

Browse files
committed
wip
1 parent b46fa5b commit af32a8d

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

Examples/TicTacToe/tic-tac-toe/Sources/LoginSwiftUI/LoginView.swift

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,14 @@ public struct LoginView: View {
1515
var isFormDisabled: Bool
1616
var isLoginButtonDisabled: Bool
1717
@BindingViewState var password: String
18-
19-
init(state: BindingViewStore<Login.State>) {
20-
self.alert = state.alert
21-
self._email = state.$email
22-
self.isActivityIndicatorVisible = state.isLoginRequestInFlight
23-
self.isFormDisabled = state.isLoginRequestInFlight
24-
self.isLoginButtonDisabled = !state.isFormValid
25-
self._password = state.$password
26-
}
2718
}
2819

2920
public init(store: StoreOf<Login>) {
3021
self.store = store
3122
}
3223

3324
public var body: some View {
34-
WithViewStore(self.store, observe: ViewState.init, send: { .view($0) }) { viewStore in
25+
WithViewStore(self.store, observe: \.view, send: { .view($0) }) { viewStore in
3526
Form {
3627
Text(
3728
"""
@@ -81,6 +72,19 @@ public struct LoginView: View {
8172
}
8273
}
8374

75+
extension BindingViewStore<Login.State> {
76+
var view: LoginView.ViewState {
77+
LoginView.ViewState(
78+
alert: self.alert,
79+
email: self.$email,
80+
isActivityIndicatorVisible: self.isLoginRequestInFlight,
81+
isFormDisabled: self.isLoginRequestInFlight,
82+
isLoginButtonDisabled: !self.isFormValid,
83+
password: self.$password
84+
)
85+
}
86+
}
87+
8488
struct LoginView_Previews: PreviewProvider {
8589
static var previews: some View {
8690
NavigationStack {

Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorSwiftUI/TwoFactorView.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,14 @@ public struct TwoFactorView: View {
1212
var isActivityIndicatorVisible: Bool
1313
var isFormDisabled: Bool
1414
var isSubmitButtonDisabled: Bool
15-
16-
init(store: BindingViewStore<TwoFactor.State>) {
17-
self.alert = store.alert
18-
self._code = store.$code
19-
self.isActivityIndicatorVisible = store.isTwoFactorRequestInFlight
20-
self.isFormDisabled = store.isTwoFactorRequestInFlight
21-
self.isSubmitButtonDisabled = !store.isFormValid
22-
}
2315
}
2416

2517
public init(store: StoreOf<TwoFactor>) {
2618
self.store = store
2719
}
2820

2921
public var body: some View {
30-
WithViewStore(self.store, observe: ViewState.init, send: { .view($0) }) { viewStore in
22+
WithViewStore(self.store, observe: \.view, send: { .view($0) }) { viewStore in
3123
Form {
3224
Text(#"To confirm the second factor enter "1234" into the form."#)
3325

@@ -62,6 +54,18 @@ public struct TwoFactorView: View {
6254
}
6355
}
6456

57+
extension BindingViewStore<TwoFactor.State> {
58+
var view: TwoFactorView.ViewState {
59+
TwoFactorView.ViewState(
60+
alert: self.alert,
61+
code: self.$code,
62+
isActivityIndicatorVisible: self.isTwoFactorRequestInFlight,
63+
isFormDisabled: self.isTwoFactorRequestInFlight,
64+
isSubmitButtonDisabled: !self.isFormValid
65+
)
66+
}
67+
}
68+
6569
struct TwoFactorView_Previews: PreviewProvider {
6670
static var previews: some View {
6771
NavigationStack {

0 commit comments

Comments
 (0)