diff --git a/yobble/Resources/Localizable.xcstrings b/yobble/Resources/Localizable.xcstrings index 77c5a8c..a3f5df9 100644 --- a/yobble/Resources/Localizable.xcstrings +++ b/yobble/Resources/Localizable.xcstrings @@ -1835,9 +1835,6 @@ }, "Подтвердить" : { "comment" : "Кнопка подтверждения кода 2FA" - }, - "Подтвердить вход" : { - }, "Подтверждение email" : { "comment" : "Раздел подтверждения email" @@ -2133,6 +2130,9 @@ }, "Проверьте цифры и попробуйте снова." : { "comment" : "Описание ошибки неверного кода 2FA" + }, + "Проверяем код…" : { + }, "Продолжить" : { diff --git a/yobble/Views/Login/LoginView.swift b/yobble/Views/Login/LoginView.swift index 6465cd9..0d429d3 100644 --- a/yobble/Views/Login/LoginView.swift +++ b/yobble/Views/Login/LoginView.swift @@ -539,26 +539,16 @@ private struct PasswordlessVerifyView: View { OTPInputView(code: $viewModel.verificationCode, isFocused: $isCodeFieldFocused) -// Button { -// withAnimation { -// viewModel.verifyPasswordlessCode() -// } -// } label: { -// if viewModel.isVerifyingCode { -// ProgressView() -// .frame(maxWidth: .infinity) -// .padding() -// } else { -// Text(NSLocalizedString("Подтвердить вход", comment: "")) -// .bold() -// .frame(maxWidth: .infinity) -// .padding() -// } -// } -// .foregroundColor(.white) -// .background(viewModel.canVerifyPasswordlessCode ? Color.blue : Color.gray) -// .cornerRadius(12) -// .disabled(!viewModel.canVerifyPasswordlessCode) + if viewModel.isVerifyingCode { + HStack(spacing: 8) { + ProgressView() + Text(NSLocalizedString("Проверяем код…", comment: "")) + .font(.subheadline) + } + .frame(maxWidth: .infinity) + .padding(.vertical, 4) + .foregroundColor(.secondary) + } VStack(alignment: .leading, spacing: 8) { Text(NSLocalizedString("Не получили код?", comment: "")) @@ -619,6 +609,12 @@ private struct PasswordlessVerifyView: View { isCodeFieldFocused = false } } + .onAppear { + triggerAutoVerificationIfNeeded() + } + .onChange(of: viewModel.verificationCode) { _ in + triggerAutoVerificationIfNeeded() + } .loginErrorAlert(viewModel: viewModel) } @@ -640,6 +636,11 @@ private struct PasswordlessVerifyView: View { } } } + + private func triggerAutoVerificationIfNeeded() { + guard viewModel.canVerifyPasswordlessCode else { return } + viewModel.verifyPasswordlessCode() + } } private struct OTPInputView: View {