|
|
|
|
@ -10,17 +10,26 @@ import LeStorage |
|
|
|
|
|
|
|
|
|
struct UserCreationFormView: View { |
|
|
|
|
|
|
|
|
|
@FocusState private var focusedField: Field? |
|
|
|
|
fileprivate enum Field: Int, Hashable { |
|
|
|
|
case username |
|
|
|
|
case password1 |
|
|
|
|
case password2 |
|
|
|
|
case email |
|
|
|
|
case firstName |
|
|
|
|
case lastName |
|
|
|
|
case phone |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@EnvironmentObject var networkMonitor: NetworkMonitor |
|
|
|
|
|
|
|
|
|
@Binding var isPresented: Bool |
|
|
|
|
@Binding var showEmailValidationMessage: Bool |
|
|
|
|
|
|
|
|
|
// @Binding var showLoginScreen: Bool |
|
|
|
|
|
|
|
|
|
@State var username: String = "" |
|
|
|
|
@State var email: String = "" |
|
|
|
|
@State var password1: String = "" |
|
|
|
|
@State var password2: String = "" |
|
|
|
|
@State var email: String = "" |
|
|
|
|
|
|
|
|
|
@State var firstName: String = "" |
|
|
|
|
@State var lastName: String = "" |
|
|
|
|
@ -51,23 +60,44 @@ struct UserCreationFormView: View { |
|
|
|
|
TextField("Nom d'utilisateur", text: self.$username) |
|
|
|
|
.autocorrectionDisabled() |
|
|
|
|
.textInputAutocapitalization(.never) |
|
|
|
|
.submitLabel(.next) |
|
|
|
|
.focused($focusedField, equals: Field.username) |
|
|
|
|
.onSubmit { self.focusedField = Field.email } |
|
|
|
|
TextField("Email", text: self.$email) |
|
|
|
|
.keyboardType(.emailAddress) |
|
|
|
|
.textInputAutocapitalization(.never) |
|
|
|
|
.submitLabel(.next) |
|
|
|
|
.focused($focusedField, equals: Field.email) |
|
|
|
|
.onSubmit { self.focusedField = Field.password1 } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
SecureField("Mot de passe", text: self.$password1) |
|
|
|
|
.submitLabel(.next) |
|
|
|
|
.focused($focusedField, equals: Field.password1) |
|
|
|
|
.onSubmit { self.focusedField = Field.password2 } |
|
|
|
|
SecureField("Confirmez le mot de passe", text: self.$password2) |
|
|
|
|
.submitLabel(.next) |
|
|
|
|
.focused($focusedField, equals: Field.password2) |
|
|
|
|
.onSubmit { self.focusedField = Field.firstName } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
TextField("Prénom", text: self.$firstName) |
|
|
|
|
.submitLabel(.next) |
|
|
|
|
.autocorrectionDisabled() |
|
|
|
|
.focused($focusedField, equals: Field.firstName) |
|
|
|
|
.onSubmit { self.focusedField = Field.lastName } |
|
|
|
|
TextField("Nom", text: self.$lastName) |
|
|
|
|
.submitLabel(.next) |
|
|
|
|
.autocorrectionDisabled() |
|
|
|
|
.focused($focusedField, equals: Field.lastName) |
|
|
|
|
.onSubmit { self.focusedField = Field.phone } |
|
|
|
|
TextField("Téléphone", text: self.$phone) |
|
|
|
|
.submitLabel(.next) |
|
|
|
|
.autocorrectionDisabled() |
|
|
|
|
.focused($focusedField, equals: Field.phone) |
|
|
|
|
// .onSubmit { self.focusNextField($focusedField) } |
|
|
|
|
|
|
|
|
|
LabeledContent { |
|
|
|
|
Picker(selection: $selectedCountryIndex) { |
|
|
|
|
|