diff --git a/PadelClub/Views/Components/PasswordField.swift b/PadelClub/Views/Components/PasswordField.swift index 030e443..629eb02 100644 --- a/PadelClub/Views/Components/PasswordField.swift +++ b/PadelClub/Views/Components/PasswordField.swift @@ -35,8 +35,8 @@ struct PasswordField: View { let image = self.visible ? "eye.slash" : "eye" Image(systemName: image) } - } + .autocorrectionDisabled(true) } diff --git a/PadelClub/Views/User/ChangePasswordView.swift b/PadelClub/Views/User/ChangePasswordView.swift index 8e9b2e7..93fbbc5 100644 --- a/PadelClub/Views/User/ChangePasswordView.swift +++ b/PadelClub/Views/User/ChangePasswordView.swift @@ -10,32 +10,53 @@ import LeStorage struct ChangePasswordView: View { + @Environment(\.dismiss) var dismiss + @State var oldPassword: String = "" @State var password1: String = "" @State var password2: String = "" @State var isLoading: Bool = false + @State var errorMessage: String = "" + @State var showForm: Bool = true + var body: some View { - Form { - - PasswordField("Old password", text: self.$oldPassword) - PasswordField("Password", text: self.$password1) - PasswordField("Password again", text: self.$password2) - - Section { - Button(action: { - self._changePassword() - }, label: { - Text("Changer de mot de passe") - }) - .frame(maxWidth: .infinity) - } footer: { - if self.errorMessage.count > 0 { - Text(self.errorMessage).foregroundStyle(.red) + Group { + if self.showForm { + + Form { + + PasswordField("Old password", text: self.$oldPassword) + PasswordField("Password", text: self.$password1) + PasswordField("Password again", text: self.$password2) + + Section { + Button(action: { + self._changePassword() + }, label: { + if self.isLoading { + Text("Changer de mot de passe") + } else { + ProgressView() + } + }) + .frame(maxWidth: .infinity) + } footer: { + if self.errorMessage.count > 0 { + Text(self.errorMessage).foregroundStyle(.red) + } + } } + } else { + VStack { + Text("Votre mot de passe a bien été changé") + RowButtonView("Ok") { + dismiss() + } + }.padding() } } .navigationTitle("Changer de mot de passe") @@ -51,9 +72,11 @@ struct ChangePasswordView: View { password1: self.password1, password2: self.password2) self.isLoading = false + self.showForm = false } catch { Logger.error(error) self.errorMessage = ErrorUtils.message(error: error) + self.isLoading = false } } diff --git a/PadelClub/Views/User/UserCreationView.swift b/PadelClub/Views/User/UserCreationView.swift index 69074d8..848c386 100644 --- a/PadelClub/Views/User/UserCreationView.swift +++ b/PadelClub/Views/User/UserCreationView.swift @@ -86,7 +86,6 @@ struct UserCreationFormView: View { .focused($focusedField, equals: .password) .textContentType(.init(rawValue: "")) .keyboardType(.asciiCapable) - .autocorrectionDisabled(true) .submitLabel(.next) .onSubmit(of: .text) { focusedField = .confirmPassword @@ -96,7 +95,6 @@ struct UserCreationFormView: View { .focused($focusedField, equals: .confirmPassword) .textContentType(.init(rawValue: "")) .keyboardType(.asciiCapable) - .autocorrectionDisabled(true) .submitLabel(.next) .onSubmit(of: .text) { focusedField = .firstName