Improve user interaction for the password change

multistore
Laurent 1 year ago
parent 5dffc41026
commit 87c4b10d97
  1. 2
      PadelClub/Views/Components/PasswordField.swift
  2. 23
      PadelClub/Views/User/ChangePasswordView.swift
  3. 2
      PadelClub/Views/User/UserCreationView.swift

@ -35,8 +35,8 @@ struct PasswordField: View {
let image = self.visible ? "eye.slash" : "eye"
Image(systemName: image)
}
}
.autocorrectionDisabled(true)
}

@ -10,15 +10,23 @@ 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 {
Group {
if self.showForm {
Form {
PasswordField("Old password", text: self.$oldPassword)
@ -29,7 +37,11 @@ struct ChangePasswordView: View {
Button(action: {
self._changePassword()
}, label: {
if self.isLoading {
Text("Changer de mot de passe")
} else {
ProgressView()
}
})
.frame(maxWidth: .infinity)
} footer: {
@ -38,6 +50,15 @@ struct ChangePasswordView: View {
}
}
}
} 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
}
}

@ -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

Loading…
Cancel
Save