1
1
import SwiftUI
2
2
3
3
struct RegisterScreen : View , RegisterScreenProtocol {
4
- let namespace : Namespace . ID
5
-
6
4
@EnvironmentObject
7
5
var eventBus : EventBus
8
6
@@ -24,12 +22,18 @@ struct RegisterScreen: View, RegisterScreenProtocol {
24
22
@AppStorage ( " account.isWaitingForRandomCode " )
25
23
var isWaitingForRandomCode = false
26
24
25
+ @AppStorage ( " account.hasAcceptedTerms " )
26
+ var hasAcceptedTerms = false
27
+
27
28
@AppStorage ( " account.isRegistering " )
28
29
var isRegistering = false
29
30
30
31
@KeychainStorage ( " connection.token " )
31
32
var token
32
33
34
+ @Environment ( \. config)
35
+ private var config
36
+
33
37
@FocusState
34
38
private var focused : FocusedField ?
35
39
@@ -46,7 +50,7 @@ struct RegisterScreen: View, RegisterScreenProtocol {
46
50
47
51
DynamicForm {
48
52
Section {
49
- EnvironmentPicker ( namespace : namespace ) . disabled ( isWaitingForRandomCode)
53
+ EnvironmentPicker ( ) . disabled ( isWaitingForRandomCode)
50
54
51
55
TextField (
52
56
" Register.Username " ,
@@ -59,7 +63,6 @@ struct RegisterScreen: View, RegisterScreenProtocol {
59
63
. disabled ( isWaitingForRandomCode)
60
64
. submitLabel ( . next)
61
65
. onSubmit { focused = . email }
62
- . matchedGeometryEffect ( id: " first-field " , in: namespace)
63
66
#if !os(macOS)
64
67
. textInputAutocapitalization( . never)
65
68
. keyboardType ( . asciiCapable)
@@ -100,18 +103,8 @@ struct RegisterScreen: View, RegisterScreenProtocol {
100
103
. keyboardType( . asciiCapable)
101
104
#endif
102
105
}
103
-
104
- SubmitOrCancel (
105
- namespace: namespace,
106
- submitLabel: " Register.Submit " ,
107
- canSubmit: canSubmit,
108
- canCancel: isWaitingForRandomCode,
109
- isLoading: isLoading,
110
- submitAction: submit,
111
- cancelAction: cancel
112
- )
113
106
} header: {
114
- LogoHeader ( namespace : namespace ) {
107
+ LogoHeader {
115
108
Image ( " Logo " , label: Text ( " Logo " ) ) . resizable ( )
116
109
} textContent: {
117
110
Text ( " Register.Header " )
@@ -132,6 +125,34 @@ struct RegisterScreen: View, RegisterScreenProtocol {
132
125
focused = . email
133
126
}
134
127
}
128
+
129
+ Section {
130
+ Toggle ( " Register.TermsAcceptance " , isOn: $hasAcceptedTerms)
131
+ . disabled ( isWaitingForRandomCode)
132
+
133
+ Link ( destination: config. app. info. termsOfService) {
134
+ Label ( " App.Help.TermsOfService " , systemImage: " shield " )
135
+ }
136
+ . foregroundStyle ( . tint)
137
+
138
+ Link ( destination: config. app. info. privacyPolicy) {
139
+ Label ( " App.Help.PrivacyPolicy " , systemImage: " lock " )
140
+ }
141
+ . foregroundStyle ( . tint)
142
+ } footer: {
143
+ Spacer ( )
144
+ }
145
+
146
+ Section {
147
+ SubmitOrCancel (
148
+ submitLabel: " Register.Submit " ,
149
+ canSubmit: canSubmit,
150
+ canCancel: isWaitingForRandomCode,
151
+ isLoading: isLoading,
152
+ submitAction: submit,
153
+ cancelAction: cancel
154
+ )
155
+ }
135
156
}
136
157
. disabled ( isLoading)
137
158
. animation ( . default, value: isWaitingForRandomCode)
@@ -161,15 +182,9 @@ struct RegisterScreen: View, RegisterScreenProtocol {
161
182
}
162
183
}
163
184
164
- @available ( macOS 14 . 0 , * )
165
- @available ( iOS 17 . 0 , * )
166
185
#Preview {
167
- @Previewable
168
- @Namespace
169
- var namespace
170
-
171
186
NavigationStack {
172
- RegisterScreen ( namespace : namespace )
187
+ RegisterScreen ( )
173
188
}
174
189
. environmentObject ( EventBus ( ) )
175
190
}
0 commit comments