From 04992f14f15bb7227dd1812d3fdb3cda912c2bba Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 30 Aug 2023 17:55:01 -0700 Subject: Improvements to UI in web logged-out views (#1341) * Add LoggedOutLayout for desktop/tablet web * Avoid screen flash in the transition to onboarding * Fix comment --- src/state/models/ui/create-account.ts | 9 +-- src/view/com/auth/LoggedOut.tsx | 39 +++++----- src/view/com/auth/create/CreateAccount.tsx | 106 ++++++++++++++------------ src/view/com/auth/create/Policies.tsx | 1 + src/view/com/auth/login/Login.tsx | 102 +++++++++++++++---------- src/view/com/util/layouts/LoggedOutLayout.tsx | 102 +++++++++++++++++++++++++ 6 files changed, 239 insertions(+), 120 deletions(-) create mode 100644 src/view/com/util/layouts/LoggedOutLayout.tsx (limited to 'src') diff --git a/src/state/models/ui/create-account.ts b/src/state/models/ui/create-account.ts index d9d4f51b9..c5d9f6d9b 100644 --- a/src/state/models/ui/create-account.ts +++ b/src/state/models/ui/create-account.ts @@ -109,13 +109,8 @@ export class CreateAccountModel { this.setError('') this.setIsProcessing(true) - // open the onboarding screens after the session is created - const sessionReadySub = this.rootStore.onSessionReady(() => { - sessionReadySub.remove() - this.rootStore.onboarding.start() - }) - try { + this.rootStore.onboarding.start() // start now to avoid flashing the wrong view await this.rootStore.session.createAccount({ service: this.serviceUrl, email: this.email, @@ -125,7 +120,7 @@ export class CreateAccountModel { }) track('Create Account') } catch (e: any) { - sessionReadySub.remove() + this.rootStore.onboarding.skip() // undo starting the onboard let errMsg = e.toString() if (e instanceof ComAtprotoServerCreateAccount.InvalidInviteCodeError) { errMsg = diff --git a/src/view/com/auth/LoggedOut.tsx b/src/view/com/auth/LoggedOut.tsx index e35706466..6d3b87dd3 100644 --- a/src/view/com/auth/LoggedOut.tsx +++ b/src/view/com/auth/LoggedOut.tsx @@ -9,7 +9,6 @@ import {usePalette} from 'lib/hooks/usePalette' import {useStores} from 'state/index' import {useAnalytics} from 'lib/analytics/analytics' import {SplashScreen} from './SplashScreen' -import {CenteredView} from '../util/Views' enum ScreenState { S_LoginOrCreateAccount, @@ -43,25 +42,23 @@ export const LoggedOut = observer(() => { } return ( - - - - {screenState === ScreenState.S_Login ? ( - - setScreenState(ScreenState.S_LoginOrCreateAccount) - } - /> - ) : undefined} - {screenState === ScreenState.S_CreateAccount ? ( - - setScreenState(ScreenState.S_LoginOrCreateAccount) - } - /> - ) : undefined} - - - + + + {screenState === ScreenState.S_Login ? ( + + setScreenState(ScreenState.S_LoginOrCreateAccount) + } + /> + ) : undefined} + {screenState === ScreenState.S_CreateAccount ? ( + + setScreenState(ScreenState.S_LoginOrCreateAccount) + } + /> + ) : undefined} + + ) }) diff --git a/src/view/com/auth/create/CreateAccount.tsx b/src/view/com/auth/create/CreateAccount.tsx index d6cb1a0a7..8cf1cfaf5 100644 --- a/src/view/com/auth/create/CreateAccount.tsx +++ b/src/view/com/auth/create/CreateAccount.tsx @@ -10,6 +10,7 @@ import { import {observer} from 'mobx-react-lite' import {useAnalytics} from 'lib/analytics/analytics' import {Text} from '../../util/text/Text' +import {LoggedOutLayout} from 'view/com/util/layouts/LoggedOutLayout' import {s} from 'lib/styles' import {useStores} from 'state/index' import {CreateAccountModel} from 'state/models/ui/create-account' @@ -65,60 +66,65 @@ export const CreateAccount = observer( }, [model, track]) return ( - - - - {model.step === 1 && } - {model.step === 2 && } - {model.step === 3 && } - - - - - Back - - - - {model.canNext ? ( + + + + + {model.step === 1 && } + {model.step === 2 && } + {model.step === 3 && } + + - {model.isProcessing ? ( - - ) : ( - - Next - - )} - - ) : model.didServiceDescriptionFetchFail ? ( - - - Retry + + Back - ) : model.isFetchingServiceDescription ? ( - <> - - - Connecting... - - - ) : undefined} - - - - + + {model.canNext ? ( + + {model.isProcessing ? ( + + ) : ( + + Next + + )} + + ) : model.didServiceDescriptionFetchFail ? ( + + + Retry + + + ) : model.isFetchingServiceDescription ? ( + <> + + + Connecting... + + + ) : undefined} + + + + + ) }, ) diff --git a/src/view/com/auth/create/Policies.tsx b/src/view/com/auth/create/Policies.tsx index a3943d8cc..8eb669bcf 100644 --- a/src/view/com/auth/create/Policies.tsx +++ b/src/view/com/auth/create/Policies.tsx @@ -93,6 +93,7 @@ function validWebLink(url?: string): string | undefined { const styles = StyleSheet.create({ policies: { + flexDirection: 'row', gap: 8, }, errorIcon: { diff --git a/src/view/com/auth/login/Login.tsx b/src/view/com/auth/login/Login.tsx index c277bfb9e..fac923393 100644 --- a/src/view/com/auth/login/Login.tsx +++ b/src/view/com/auth/login/Login.tsx @@ -17,6 +17,7 @@ import {BskyAgent} from '@atproto/api' import {useAnalytics} from 'lib/analytics/analytics' import {Text} from '../../util/text/Text' import {UserAvatar} from '../../util/UserAvatar' +import {LoggedOutLayout} from 'view/com/util/layouts/LoggedOutLayout' import {s, colors} from 'lib/styles' import {createFullHandle} from 'lib/strings/handles' import {toNiceDomain} from 'lib/strings/url-helpers' @@ -99,52 +100,69 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => { } return ( - + {currentForm === Forms.Login ? ( - + + + ) : undefined} {currentForm === Forms.ChooseAccount ? ( - + + + ) : undefined} {currentForm === Forms.ForgotPassword ? ( - + + + ) : undefined} {currentForm === Forms.SetNewPassword ? ( - + + + ) : undefined} {currentForm === Forms.PasswordUpdated ? ( @@ -834,9 +852,9 @@ const SetNewPasswordForm = ({ const PasswordUpdatedForm = ({onPressNext}: {onPressNext: () => void}) => { const {screen} = useAnalytics() - // useEffect(() => { - screen('Signin:PasswordUpdatedForm') - // }, [screen]) + useEffect(() => { + screen('Signin:PasswordUpdatedForm') + }, [screen]) const pal = usePalette('default') return ( diff --git a/src/view/com/util/layouts/LoggedOutLayout.tsx b/src/view/com/util/layouts/LoggedOutLayout.tsx new file mode 100644 index 000000000..daa33cece --- /dev/null +++ b/src/view/com/util/layouts/LoggedOutLayout.tsx @@ -0,0 +1,102 @@ +import React from 'react' +import {StyleSheet, View} from 'react-native' +import {Text} from '../text/Text' +import {usePalette} from 'lib/hooks/usePalette' +import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' +import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' + +export const LoggedOutLayout = ({ + leadin, + title, + description, + children, +}: React.PropsWithChildren<{ + leadin: string + title: string + description: string +}>) => { + const {isMobile, isTabletOrMobile} = useWebMediaQueries() + const pal = usePalette('default') + const sideBg = useColorSchemeStyle(pal.viewLight, pal.view) + const contentBg = useColorSchemeStyle(pal.view, { + backgroundColor: pal.colors.background, + borderColor: pal.colors.border, + borderLeftWidth: 1, + }) + + if (isMobile) { + return {children} + } + return ( + + + + {leadin} + + + {title} + + + {description} + + + + {children} + + + ) +} + +const styles = StyleSheet.create({ + container: { + flexDirection: 'row', + height: '100vh', + }, + side: { + flex: 1, + paddingHorizontal: 40, + paddingBottom: 80, + justifyContent: 'center', + }, + content: { + flex: 2, + paddingHorizontal: 40, + justifyContent: 'center', + }, + + leadinText: { + fontSize: 36, + fontWeight: '800', + textAlign: 'right', + }, + leadinTextSmall: { + fontSize: 24, + }, + titleText: { + fontSize: 58, + fontWeight: '800', + textAlign: 'right', + }, + titleTextSmall: { + fontSize: 36, + }, + descriptionText: { + maxWidth: 400, + marginTop: 10, + marginLeft: 'auto', + textAlign: 'right', + }, + contentWrapper: { + maxWidth: 600, + }, +}) -- cgit 1.4.1