Compare commits
3 Commits
608add0714
...
cd67c350b4
| Author | SHA1 | Date | |
|---|---|---|---|
| cd67c350b4 | |||
| bbe6a8a3e4 | |||
| 8712c7ea22 |
@ -6,6 +6,9 @@
|
||||
},
|
||||
"(без текста)" : {
|
||||
|
||||
},
|
||||
"@" : {
|
||||
|
||||
},
|
||||
"@%@" : {
|
||||
"localizations" : {
|
||||
@ -282,9 +285,6 @@
|
||||
},
|
||||
"Введите логин и мы отправим шестизначный код подтверждения." : {
|
||||
|
||||
},
|
||||
"Введите логин." : {
|
||||
|
||||
},
|
||||
"Введите пароль" : {
|
||||
"comment" : "Пароль\nПоле ввода пароля на приложение"
|
||||
@ -2494,7 +2494,7 @@
|
||||
"Сохранить пароль" : {
|
||||
"comment" : "Кнопка сохранения пароля на приложение"
|
||||
},
|
||||
"Соцсеть" : {
|
||||
"Соцсеть (готово 10%)" : {
|
||||
|
||||
},
|
||||
"Спасибо! Мы получили ваш отзыв" : {
|
||||
@ -2596,7 +2596,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Только чаты" : {
|
||||
"Только чаты (готово 60%)" : {
|
||||
|
||||
},
|
||||
"Ты шо ебанутый? А ниче тот факт что новый пароль должен отличаться от старого." : {
|
||||
|
||||
@ -155,14 +155,14 @@ class LoginViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
func requestPasswordlessCode() {
|
||||
let trimmedLogin = passwordlessLogin.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
guard !trimmedLogin.isEmpty else {
|
||||
errorMessage = NSLocalizedString("Введите логин.", comment: "")
|
||||
guard LoginViewModel.isLoginValid(passwordlessLogin) else {
|
||||
errorMessage = NSLocalizedString("Неверный логин", comment: "")
|
||||
showError = true
|
||||
return
|
||||
}
|
||||
|
||||
let trimmedLogin = passwordlessLogin.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
|
||||
isSendingCode = true
|
||||
showError = false
|
||||
|
||||
@ -369,12 +369,19 @@ extension LoginViewModel {
|
||||
}
|
||||
|
||||
var canRequestPasswordlessCode: Bool {
|
||||
!passwordlessLogin.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty && !isSendingCode
|
||||
LoginViewModel.isLoginValid(passwordlessLogin) && !isSendingCode
|
||||
}
|
||||
|
||||
var canVerifyPasswordlessCode: Bool {
|
||||
isVerificationCodeComplete && !isVerifyingCode
|
||||
}
|
||||
|
||||
static func isLoginValid(_ login: String) -> Bool {
|
||||
let trimmed = login.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard trimmed == login else { return false }
|
||||
let pattern = "^[A-Za-z0-9_]{3,32}$"
|
||||
return trimmed.range(of: pattern, options: .regularExpression) != nil
|
||||
}
|
||||
}
|
||||
|
||||
private extension LoginViewModel {
|
||||
|
||||
@ -109,8 +109,7 @@ struct PasswordLoginView: View {
|
||||
}
|
||||
|
||||
private var isUsernameValid: Bool {
|
||||
let pattern = "^[A-Za-z0-9_]{3,32}$"
|
||||
return viewModel.username.range(of: pattern, options: .regularExpression) != nil
|
||||
LoginViewModel.isLoginValid(viewModel.username)
|
||||
}
|
||||
|
||||
private var isPasswordValid: Bool {
|
||||
@ -149,10 +148,10 @@ struct PasswordLoginView: View {
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
HStack(spacing: 8) {
|
||||
Text("@")
|
||||
.foregroundColor(.secondary)
|
||||
TextField(NSLocalizedString("Введите логин", comment: ""), text: $viewModel.username)
|
||||
.padding()
|
||||
.background(Color(.secondarySystemBackground))
|
||||
.cornerRadius(12)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.focused($focusedField, equals: .username)
|
||||
@ -161,6 +160,10 @@ struct PasswordLoginView: View {
|
||||
viewModel.username = String(newValue.prefix(32))
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.background(Color(.secondarySystemBackground))
|
||||
.cornerRadius(12)
|
||||
|
||||
if !isUsernameValid && !viewModel.username.isEmpty {
|
||||
Text(NSLocalizedString("Неверный логин", comment: "Неверный логин"))
|
||||
@ -391,6 +394,10 @@ private struct PasswordlessRequestView: View {
|
||||
let onShowModePrompt: () -> Void
|
||||
@FocusState private var isFieldFocused: Bool
|
||||
|
||||
private var isLoginValid: Bool {
|
||||
LoginViewModel.isLoginValid(viewModel.passwordlessLogin)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollView(showsIndicators: false) {
|
||||
VStack(alignment: .leading, spacing: 24) {
|
||||
@ -409,19 +416,28 @@ private struct PasswordlessRequestView: View {
|
||||
// Text(NSLocalizedString("Логин", comment: ""))
|
||||
// .font(.subheadline)
|
||||
// .foregroundColor(.secondary)
|
||||
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)
|
||||
.focused($isFieldFocused)
|
||||
.onChange(of: viewModel.passwordlessLogin) { newValue in
|
||||
if newValue.count > 64 {
|
||||
viewModel.passwordlessLogin = String(newValue.prefix(64))
|
||||
}
|
||||
if !isLoginValid && !viewModel.passwordlessLogin.isEmpty {
|
||||
Text(NSLocalizedString("Неверный логин", comment: ""))
|
||||
.foregroundColor(.red)
|
||||
.font(.caption)
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,13 +741,13 @@ private struct MessengerModePrompt: View {
|
||||
|
||||
VStack(spacing: 12) {
|
||||
optionButton(
|
||||
title: NSLocalizedString("Соцсеть", comment: ""),
|
||||
title: NSLocalizedString("Соцсеть (готово 10%)", comment: ""),
|
||||
subtitle: NSLocalizedString("Лента, истории, подписки", comment: ""),
|
||||
isMessenger: false
|
||||
)
|
||||
|
||||
optionButton(
|
||||
title: NSLocalizedString("Только чаты", comment: ""),
|
||||
title: NSLocalizedString("Только чаты (готово 60%)", comment: ""),
|
||||
subtitle: NSLocalizedString("Минимум отвлечений, чистый мессенджер", comment: ""),
|
||||
isMessenger: true
|
||||
)
|
||||
|
||||
@ -75,18 +75,22 @@ struct RegistrationView: View {
|
||||
|
||||
Group {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(spacing: 8) {
|
||||
Text("@")
|
||||
.foregroundColor(.secondary)
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.background(Color(.secondarySystemBackground))
|
||||
.cornerRadius(12)
|
||||
|
||||
if !isUsernameValid && !username.isEmpty {
|
||||
Text(NSLocalizedString("Логин должен быть от 3 до 32 символов (английские буквы, цифры, _)", comment: ""))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user