diff --git a/yobble/Views/Login/LoginView.swift b/yobble/Views/Login/LoginView.swift index 27f3f57..0dd0858 100644 --- a/yobble/Views/Login/LoginView.swift +++ b/yobble/Views/Login/LoginView.swift @@ -125,7 +125,7 @@ struct PasswordLoginView: View { var body: some View { ScrollView(showsIndicators: false) { VStack(alignment: .leading, spacing: 24) { - LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: onShowModePrompt) + LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: hideKeyboardAndShowModePrompt) Button { focusedField = nil @@ -299,6 +299,11 @@ struct PasswordLoginView: View { #endif } + private func hideKeyboardAndShowModePrompt() { + focusedField = nil + onShowModePrompt() + } + private func openLanguageSettings() { guard let url = URL(string: UIApplication.openSettingsURLString) else { return } UIApplication.shared.open(url) @@ -389,7 +394,7 @@ private struct PasswordlessRequestView: View { var body: some View { ScrollView(showsIndicators: false) { VStack(alignment: .leading, spacing: 24) { - LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: onShowModePrompt) + LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: hideKeyboardAndShowModePrompt) VStack(alignment: .leading, spacing: 8) { Text(NSLocalizedString("Вход", comment: "")) @@ -502,6 +507,11 @@ private struct PasswordlessRequestView: View { .loginErrorAlert(viewModel: viewModel) } + private func hideKeyboardAndShowModePrompt() { + isFieldFocused = false + onShowModePrompt() + } + private func openLanguageSettings() { guard let url = URL(string: UIApplication.openSettingsURLString) else { return } UIApplication.shared.open(url) @@ -526,7 +536,7 @@ private struct PasswordlessVerifyView: View { var body: some View { ScrollView(showsIndicators: false) { VStack(alignment: .leading, spacing: 24) { - LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: onShowModePrompt) + LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: hideKeyboardAndShowModePrompt) VStack(alignment: .leading, spacing: 8) { Text(NSLocalizedString("Введите код", comment: "")) @@ -620,6 +630,11 @@ private struct PasswordlessVerifyView: View { .loginErrorAlert(viewModel: viewModel) } + private func hideKeyboardAndShowModePrompt() { + isCodeFieldFocused = false + onShowModePrompt() + } + private func openLanguageSettings() { guard let url = URL(string: UIApplication.openSettingsURLString) else { return } UIApplication.shared.open(url) diff --git a/yobble/Views/Login/RegistrationView.swift b/yobble/Views/Login/RegistrationView.swift index 50eb336..e356b30 100644 --- a/yobble/Views/Login/RegistrationView.swift +++ b/yobble/Views/Login/RegistrationView.swift @@ -55,7 +55,7 @@ struct RegistrationView: View { var body: some View { ScrollView(showsIndicators: false) { VStack(alignment: .leading, spacing: 24) { - LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: onShowModePrompt) + LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: keyboardDismissingModePrompt) Button(action: goBack) { HStack(spacing: 6) { @@ -222,6 +222,14 @@ struct RegistrationView: View { } } + private var keyboardDismissingModePrompt: (() -> Void)? { + guard let onShowModePrompt else { return nil } + return { + focusedField = nil + onShowModePrompt() + } + } + private func openLanguageSettings() { guard let url = URL(string: UIApplication.openSettingsURLString) else { return } UIApplication.shared.open(url)