This commit is contained in:
cheykrym 2025-12-03 09:05:16 +03:00
parent bbe6a8a3e4
commit cd67c350b4
3 changed files with 50 additions and 35 deletions

View File

@ -6,6 +6,9 @@
},
"(без текста)" : {
},
"@" : {
},
"@%@" : {
"localizations" : {

View File

@ -148,18 +148,22 @@ struct PasswordLoginView: View {
}
VStack(alignment: .leading, spacing: 12) {
TextField(NSLocalizedString("Введите логин", comment: ""), text: $viewModel.username)
.padding()
.background(Color(.secondarySystemBackground))
.cornerRadius(12)
.autocapitalization(.none)
.disableAutocorrection(true)
.focused($focusedField, equals: .username)
.onChange(of: viewModel.username) { newValue in
if newValue.count > 32 {
viewModel.username = String(newValue.prefix(32))
HStack(spacing: 8) {
Text("@")
.foregroundColor(.secondary)
TextField(NSLocalizedString("Введите логин", comment: ""), text: $viewModel.username)
.autocapitalization(.none)
.disableAutocorrection(true)
.focused($focusedField, equals: .username)
.onChange(of: viewModel.username) { newValue in
if newValue.count > 32 {
viewModel.username = String(newValue.prefix(32))
}
}
}
}
.padding()
.background(Color(.secondarySystemBackground))
.cornerRadius(12)
if !isUsernameValid && !viewModel.username.isEmpty {
Text(NSLocalizedString("Неверный логин", comment: "Неверный логин"))
@ -412,20 +416,24 @@ private struct PasswordlessRequestView: View {
// Text(NSLocalizedString("Логин", comment: ""))
// .font(.subheadline)
// .foregroundColor(.secondary)
TextField(NSLocalizedString("Введите логин", comment: ""), text: $viewModel.passwordlessLogin)
.textContentType(.username)
.keyboardType(.default)
.autocapitalization(.none)
.disableAutocorrection(true)
.padding()
.background(Color(.secondarySystemBackground))
.cornerRadius(12)
.focused($isFieldFocused)
.onChange(of: viewModel.passwordlessLogin) { newValue in
if newValue.count > 32 {
viewModel.passwordlessLogin = String(newValue.prefix(32))
HStack(spacing: 8) {
Text("@")
.foregroundColor(.secondary)
TextField(NSLocalizedString("Введите логин", comment: ""), text: $viewModel.passwordlessLogin)
.textContentType(.username)
.keyboardType(.default)
.autocapitalization(.none)
.disableAutocorrection(true)
.focused($isFieldFocused)
.onChange(of: viewModel.passwordlessLogin) { newValue in
if newValue.count > 32 {
viewModel.passwordlessLogin = String(newValue.prefix(32))
}
}
}
}
.padding()
.background(Color(.secondarySystemBackground))
.cornerRadius(12)
if !isLoginValid && !viewModel.passwordlessLogin.isEmpty {
Text(NSLocalizedString("Неверный логин", comment: ""))
.foregroundColor(.red)

View File

@ -75,18 +75,22 @@ struct RegistrationView: View {
Group {
VStack(alignment: .leading, spacing: 4) {
TextField(NSLocalizedString("Введите логин", comment: "Логин"), text: $username)
.autocapitalization(.none)
.disableAutocorrection(true)
.focused($focusedField, equals: .username)
.padding()
.background(Color(.secondarySystemBackground))
.cornerRadius(12)
.onChange(of: username) { newValue in
if newValue.count > 32 {
username = String(newValue.prefix(32))
HStack(spacing: 8) {
Text("@")
.foregroundColor(.secondary)
TextField(NSLocalizedString("Введите логин", comment: "Логин"), text: $username)
.autocapitalization(.none)
.disableAutocorrection(true)
.focused($focusedField, equals: .username)
.onChange(of: username) { newValue in
if newValue.count > 32 {
username = String(newValue.prefix(32))
}
}
}
}
.padding()
.background(Color(.secondarySystemBackground))
.cornerRadius(12)
if !isUsernameValid && !username.isEmpty {
Text(NSLocalizedString("Логин должен быть от 3 до 32 символов (английские буквы, цифры, _)", comment: ""))