добавлен глазик
This commit is contained in:
parent
728bea60c2
commit
ab5218f02a
@ -6,6 +6,9 @@ struct ChangePasswordView: View {
|
|||||||
@State private var oldPassword = ""
|
@State private var oldPassword = ""
|
||||||
@State private var newPassword = ""
|
@State private var newPassword = ""
|
||||||
@State private var confirmPassword = ""
|
@State private var confirmPassword = ""
|
||||||
|
@State private var isOldPasswordVisible = false
|
||||||
|
@State private var isNewPasswordVisible = false
|
||||||
|
@State private var isConfirmPasswordVisible = false
|
||||||
|
|
||||||
private var isOldPasswordValid: Bool {
|
private var isOldPasswordValid: Bool {
|
||||||
return oldPassword.count >= 8 && oldPassword.count <= 128
|
return oldPassword.count >= 8 && oldPassword.count <= 128
|
||||||
@ -28,8 +31,28 @@ struct ChangePasswordView: View {
|
|||||||
Section {
|
Section {
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
SecureField(NSLocalizedString("Старый пароль", comment: "Старый пароль"), text: $oldPassword)
|
if isOldPasswordVisible {
|
||||||
.autocapitalization(.none)
|
TextField(NSLocalizedString("Старый пароль", comment: "Старый пароль"), text: $oldPassword)
|
||||||
|
.autocapitalization(.none)
|
||||||
|
.disableAutocorrection(true)
|
||||||
|
.textContentType(.password)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
} else {
|
||||||
|
SecureField(NSLocalizedString("Старый пароль", comment: "Старый пароль"), text: $oldPassword)
|
||||||
|
.autocapitalization(.none)
|
||||||
|
.disableAutocorrection(true)
|
||||||
|
.textContentType(.password)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
isOldPasswordVisible.toggle()
|
||||||
|
}) {
|
||||||
|
Image(systemName: isOldPasswordVisible ? "eye.slash" : "eye")
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
}
|
||||||
|
.buttonStyle(PlainButtonStyle())
|
||||||
|
.padding(.horizontal, 4)
|
||||||
|
|
||||||
if !oldPassword.isEmpty {
|
if !oldPassword.isEmpty {
|
||||||
Image(systemName: isOldPasswordValid ? "checkmark.circle" : "xmark.circle")
|
Image(systemName: isOldPasswordValid ? "checkmark.circle" : "xmark.circle")
|
||||||
@ -38,8 +61,28 @@ struct ChangePasswordView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
SecureField(NSLocalizedString("Новый пароль", comment: "Новый пароль"), text: $newPassword)
|
if isNewPasswordVisible {
|
||||||
.autocapitalization(.none)
|
TextField(NSLocalizedString("Новый пароль", comment: "Новый пароль"), text: $newPassword)
|
||||||
|
.autocapitalization(.none)
|
||||||
|
.disableAutocorrection(true)
|
||||||
|
.textContentType(.newPassword)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
} else {
|
||||||
|
SecureField(NSLocalizedString("Новый пароль", comment: "Новый пароль"), text: $newPassword)
|
||||||
|
.autocapitalization(.none)
|
||||||
|
.disableAutocorrection(true)
|
||||||
|
.textContentType(.newPassword)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
isNewPasswordVisible.toggle()
|
||||||
|
}) {
|
||||||
|
Image(systemName: isNewPasswordVisible ? "eye.slash" : "eye")
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
}
|
||||||
|
.buttonStyle(PlainButtonStyle())
|
||||||
|
.padding(.horizontal, 4)
|
||||||
|
|
||||||
if !newPassword.isEmpty {
|
if !newPassword.isEmpty {
|
||||||
let isAllValid = isNewPasswordValid && !isOldPasswordSame
|
let isAllValid = isNewPasswordValid && !isOldPasswordSame
|
||||||
@ -50,8 +93,28 @@ struct ChangePasswordView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
SecureField(NSLocalizedString("Подтверждение пароля", comment: "Подтверждение пароля"), text: $confirmPassword)
|
if isConfirmPasswordVisible {
|
||||||
.autocapitalization(.none)
|
TextField(NSLocalizedString("Подтверждение пароля", comment: "Подтверждение пароля"), text: $confirmPassword)
|
||||||
|
.autocapitalization(.none)
|
||||||
|
.disableAutocorrection(true)
|
||||||
|
.textContentType(.password)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
} else {
|
||||||
|
SecureField(NSLocalizedString("Подтверждение пароля", comment: "Подтверждение пароля"), text: $confirmPassword)
|
||||||
|
.autocapitalization(.none)
|
||||||
|
.disableAutocorrection(true)
|
||||||
|
.textContentType(.password)
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
|
||||||
|
Button(action: {
|
||||||
|
isConfirmPasswordVisible.toggle()
|
||||||
|
}) {
|
||||||
|
Image(systemName: isConfirmPasswordVisible ? "eye.slash" : "eye")
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
}
|
||||||
|
.buttonStyle(PlainButtonStyle())
|
||||||
|
.padding(.horizontal, 4)
|
||||||
|
|
||||||
if !confirmPassword.isEmpty {
|
if !confirmPassword.isEmpty {
|
||||||
Image(systemName: isPasswordConfirmValid ? "checkmark.circle" : "xmark.circle")
|
Image(systemName: isPasswordConfirmValid ? "checkmark.circle" : "xmark.circle")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user