Compare commits
No commits in common. "608add0714f6d56cc87196c57810bc5c44592603" and "1cec8aee3eea1bccd3eb85219f2c1baa9cdf2fde" have entirely different histories.
608add0714
...
1cec8aee3e
@ -12,8 +12,7 @@ class LoginViewModel: ObservableObject {
|
|||||||
@Published var username: String = ""
|
@Published var username: String = ""
|
||||||
@Published var userId: String = ""
|
@Published var userId: String = ""
|
||||||
@Published var password: String = ""
|
@Published var password: String = ""
|
||||||
@Published var isLoading: Bool = false
|
@Published var isLoading: Bool = true // сразу true, чтобы показать спиннер при автологине
|
||||||
@Published var isInitialLoading: Bool = true // отдельный флаг для сплэша до завершения автологина
|
|
||||||
@Published var showError: Bool = false
|
@Published var showError: Bool = false
|
||||||
@Published var errorMessage: String = ""
|
@Published var errorMessage: String = ""
|
||||||
@Published var isLoggedIn: Bool = false
|
@Published var isLoggedIn: Bool = false
|
||||||
@ -128,7 +127,6 @@ class LoginViewModel: ObservableObject {
|
|||||||
self?.socketService.disconnect()
|
self?.socketService.disconnect()
|
||||||
}
|
}
|
||||||
self?.isLoading = false
|
self?.isLoading = false
|
||||||
self?.isInitialLoading = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +135,7 @@ class LoginViewModel: ObservableObject {
|
|||||||
func login() {
|
func login() {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
showError = false
|
showError = false
|
||||||
|
|
||||||
authService.login(username: username, password: password) { [weak self] success, error in
|
authService.login(username: username, password: password) { [weak self] success, error in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self?.isLoading = false
|
self?.isLoading = false
|
||||||
|
|||||||
@ -125,7 +125,7 @@ struct PasswordLoginView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView(showsIndicators: false) {
|
ScrollView(showsIndicators: false) {
|
||||||
VStack(alignment: .leading, spacing: 24) {
|
VStack(alignment: .leading, spacing: 24) {
|
||||||
LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: hideKeyboardAndShowModePrompt)
|
LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: onShowModePrompt)
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
focusedField = nil
|
focusedField = nil
|
||||||
@ -299,11 +299,6 @@ struct PasswordLoginView: View {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private func hideKeyboardAndShowModePrompt() {
|
|
||||||
focusedField = nil
|
|
||||||
onShowModePrompt()
|
|
||||||
}
|
|
||||||
|
|
||||||
private func openLanguageSettings() {
|
private func openLanguageSettings() {
|
||||||
guard let url = URL(string: UIApplication.openSettingsURLString) else { return }
|
guard let url = URL(string: UIApplication.openSettingsURLString) else { return }
|
||||||
UIApplication.shared.open(url)
|
UIApplication.shared.open(url)
|
||||||
@ -394,7 +389,7 @@ private struct PasswordlessRequestView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView(showsIndicators: false) {
|
ScrollView(showsIndicators: false) {
|
||||||
VStack(alignment: .leading, spacing: 24) {
|
VStack(alignment: .leading, spacing: 24) {
|
||||||
LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: hideKeyboardAndShowModePrompt)
|
LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: onShowModePrompt)
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
Text(NSLocalizedString("Вход", comment: ""))
|
Text(NSLocalizedString("Вход", comment: ""))
|
||||||
@ -507,11 +502,6 @@ private struct PasswordlessRequestView: View {
|
|||||||
.loginErrorAlert(viewModel: viewModel)
|
.loginErrorAlert(viewModel: viewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func hideKeyboardAndShowModePrompt() {
|
|
||||||
isFieldFocused = false
|
|
||||||
onShowModePrompt()
|
|
||||||
}
|
|
||||||
|
|
||||||
private func openLanguageSettings() {
|
private func openLanguageSettings() {
|
||||||
guard let url = URL(string: UIApplication.openSettingsURLString) else { return }
|
guard let url = URL(string: UIApplication.openSettingsURLString) else { return }
|
||||||
UIApplication.shared.open(url)
|
UIApplication.shared.open(url)
|
||||||
@ -536,7 +526,7 @@ private struct PasswordlessVerifyView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView(showsIndicators: false) {
|
ScrollView(showsIndicators: false) {
|
||||||
VStack(alignment: .leading, spacing: 24) {
|
VStack(alignment: .leading, spacing: 24) {
|
||||||
LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: hideKeyboardAndShowModePrompt)
|
LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: onShowModePrompt)
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
Text(NSLocalizedString("Введите код", comment: ""))
|
Text(NSLocalizedString("Введите код", comment: ""))
|
||||||
@ -630,11 +620,6 @@ private struct PasswordlessVerifyView: View {
|
|||||||
.loginErrorAlert(viewModel: viewModel)
|
.loginErrorAlert(viewModel: viewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func hideKeyboardAndShowModePrompt() {
|
|
||||||
isCodeFieldFocused = false
|
|
||||||
onShowModePrompt()
|
|
||||||
}
|
|
||||||
|
|
||||||
private func openLanguageSettings() {
|
private func openLanguageSettings() {
|
||||||
guard let url = URL(string: UIApplication.openSettingsURLString) else { return }
|
guard let url = URL(string: UIApplication.openSettingsURLString) else { return }
|
||||||
UIApplication.shared.open(url)
|
UIApplication.shared.open(url)
|
||||||
@ -828,7 +813,6 @@ struct LoginView_Previews: PreviewProvider {
|
|||||||
private static func preview(step: LoginViewModel.LoginFlowStep) -> some View {
|
private static func preview(step: LoginViewModel.LoginFlowStep) -> some View {
|
||||||
let viewModel = LoginViewModel()
|
let viewModel = LoginViewModel()
|
||||||
viewModel.isLoading = false
|
viewModel.isLoading = false
|
||||||
viewModel.isInitialLoading = false
|
|
||||||
viewModel.loginFlowStep = step
|
viewModel.loginFlowStep = step
|
||||||
viewModel.passwordlessLogin = "preview@yobble.app"
|
viewModel.passwordlessLogin = "preview@yobble.app"
|
||||||
viewModel.verificationCode = "123456"
|
viewModel.verificationCode = "123456"
|
||||||
|
|||||||
@ -55,7 +55,7 @@ struct RegistrationView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView(showsIndicators: false) {
|
ScrollView(showsIndicators: false) {
|
||||||
VStack(alignment: .leading, spacing: 24) {
|
VStack(alignment: .leading, spacing: 24) {
|
||||||
LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: keyboardDismissingModePrompt)
|
LoginTopBar(openLanguageSettings: openLanguageSettings, onShowModePrompt: onShowModePrompt)
|
||||||
|
|
||||||
Button(action: goBack) {
|
Button(action: goBack) {
|
||||||
HStack(spacing: 6) {
|
HStack(spacing: 6) {
|
||||||
@ -222,14 +222,6 @@ struct RegistrationView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var keyboardDismissingModePrompt: (() -> Void)? {
|
|
||||||
guard let onShowModePrompt else { return nil }
|
|
||||||
return {
|
|
||||||
focusedField = nil
|
|
||||||
onShowModePrompt()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func openLanguageSettings() {
|
private func openLanguageSettings() {
|
||||||
guard let url = URL(string: UIApplication.openSettingsURLString) else { return }
|
guard let url = URL(string: UIApplication.openSettingsURLString) else { return }
|
||||||
UIApplication.shared.open(url)
|
UIApplication.shared.open(url)
|
||||||
@ -241,7 +233,6 @@ struct RegistrationView_Previews: PreviewProvider {
|
|||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
let viewModel = LoginViewModel()
|
let viewModel = LoginViewModel()
|
||||||
viewModel.isLoading = false // чтобы убрать спиннер
|
viewModel.isLoading = false // чтобы убрать спиннер
|
||||||
viewModel.isInitialLoading = false
|
|
||||||
return RegistrationView(viewModel: viewModel, onShowModePrompt: nil)
|
return RegistrationView(viewModel: viewModel, onShowModePrompt: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ struct yobbleApp: App {
|
|||||||
WindowGroup {
|
WindowGroup {
|
||||||
ZStack(alignment: .top) {
|
ZStack(alignment: .top) {
|
||||||
Group {
|
Group {
|
||||||
if viewModel.isInitialLoading {
|
if viewModel.isLoading {
|
||||||
SplashScreenView()
|
SplashScreenView()
|
||||||
} else if viewModel.isLoggedIn {
|
} else if viewModel.isLoggedIn {
|
||||||
MainView(viewModel: viewModel)
|
MainView(viewModel: viewModel)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user