From 22289e3d5cd2214754599d02cbda05c5811cf266 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 25 Sep 2023 16:18:48 +0800 Subject: [PATCH] Fix login screen sizes, add some spinners during login --- .../Sources/App/Views/Labels/ApplyLabelsView.swift | 2 +- .../App/Views/LinkedItemMetadataEditView.swift | 2 +- .../Sources/App/Views/Profile/ProfileView.swift | 2 +- .../Views/Registration/EmailAuth/EmailAuthView.swift | 3 ++- .../Registration/EmailAuth/EmailLoginFormView.swift | 11 ++++++++++- .../Registration/EmailAuth/EmailSignupFormView.swift | 11 ++++++++++- .../Sources/App/Views/RootView/RootView.swift | 2 +- apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift | 2 +- 8 files changed, 27 insertions(+), 8 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift b/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift index 8da9ead0a..ac264390e 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Labels/ApplyLabelsView.swift @@ -174,7 +174,7 @@ struct ApplyLabelsView: View { } #elseif os(macOS) innerBody - .frame(minWidth: 400, minHeight: 400) + .frame(minWidth: 400, minHeight: 600) #endif } .task { diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkedItemMetadataEditView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkedItemMetadataEditView.swift index 80b58d2a5..d7f81aef7 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LinkedItemMetadataEditView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LinkedItemMetadataEditView.swift @@ -138,7 +138,7 @@ struct LinkedItemMetadataEditView: View { ) } } - .frame(minWidth: 400, minHeight: 400) + .frame(minWidth: 400, minHeight: 600) } #endif } diff --git a/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift b/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift index 0e9533313..e47f3682e 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Profile/ProfileView.swift @@ -83,7 +83,7 @@ struct ProfileView: View { innerBody } .listStyle(InsetListStyle()) - .frame(minWidth: 400, minHeight: 400) + .frame(minWidth: 400, minHeight: 600) #endif } diff --git a/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailAuthView.swift b/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailAuthView.swift index 8ac1a14c1..5006b2981 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailAuthView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailAuthView.swift @@ -17,6 +17,7 @@ enum EmailAuthState { @Published var emailAuthState = EmailAuthState.signIn @Published var potentialUsernameStatus = PotentialUsernameStatus.noUsername @Published var potentialUsername = "" + @Published var isLoading = false var subscriptions = Set() } @@ -68,7 +69,7 @@ struct EmailAuthView: View { } #else innerBody - .frame(minWidth: 400, minHeight: 400) + .frame(minWidth: 400, minHeight: 600) .buttonStyle(PlainButtonStyle()) #endif } diff --git a/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailLoginFormView.swift b/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailLoginFormView.swift index 6770b96d9..26a9d3d19 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailLoginFormView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailLoginFormView.swift @@ -11,8 +11,11 @@ extension EmailAuthViewModel { authenticator: Authenticator ) async { do { + isLoading = true try await authenticator.submitEmailLogin(email: email, password: password) + isLoading = false } catch { + isLoading = false if let newLoginError = error as? LoginError { if newLoginError == .pendingEmailVerification { emailAuthState = .pendingEmailVerification(email: email, password: password) @@ -175,7 +178,13 @@ struct EmailPendingVerificationView: View { ) } }, - label: { Text(LocalText.registrationStatusCheck) } + label: { + if viewModel.isLoading { + ProgressView() + } else { + Text(LocalText.registrationStatusCheck) + } + } ) .buttonStyle(SolidCapsuleButtonStyle(color: .appDeepBackground, width: 300)) diff --git a/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailSignupFormView.swift b/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailSignupFormView.swift index 25a23c143..9e65232a8 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailSignupFormView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Registration/EmailAuth/EmailSignupFormView.swift @@ -22,6 +22,7 @@ extension EmailAuthViewModel { emailAuthState = .pendingEmailVerification(email: email, password: password) } catch { loginError = error as? LoginError + emailAuthState = .signUp } } @@ -171,6 +172,7 @@ struct EmailSignupFormView: View { Button( action: { + viewModel.emailAuthState = .loading Task { await viewModel.signUp( email: email, @@ -180,7 +182,14 @@ struct EmailSignupFormView: View { ) } }, - label: { Text(LocalText.genericSubmit) } + label: { + switch viewModel.emailAuthState { + case .loading: + ProgressView() + default: + Text(LocalText.genericSubmit) + } + } ) .buttonStyle(SolidCapsuleButtonStyle(color: .appCtaYellow, width: 300)) diff --git a/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift b/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift index 185685255..abff913d1 100644 --- a/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift @@ -66,7 +66,7 @@ struct InnerRootView: View { innerBody #elseif os(macOS) innerBody - .frame(minWidth: 400, idealWidth: 1200, minHeight: 400, idealHeight: 1200) + .frame(minWidth: 400, idealWidth: 1200, minHeight: 600, idealHeight: 1200) #endif } .onOpenURL { Authenticator.handleGoogleURL(url: $0) } diff --git a/apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift b/apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift index 413176650..06c56f3d5 100644 --- a/apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/WelcomeView.swift @@ -196,7 +196,7 @@ struct WelcomeView: View { if let loginError = viewModel.loginError { HStack { LoginErrorMessageView(loginError: loginError) - Spacer() + .frame(maxWidth: 400, alignment: .leading) } } }