diff --git a/src/components/dialogs/SwitchAccount.tsx b/src/components/dialogs/SwitchAccount.tsx index 696ee0e5d4..0013f92bee 100644 --- a/src/components/dialogs/SwitchAccount.tsx +++ b/src/components/dialogs/SwitchAccount.tsx @@ -43,10 +43,10 @@ export function SwitchAccountDialog({ return ( - + - Switch Account + Switch account Select account} style={web([a.py_2xl])}> - - Sign in as... - + {isWeb && ( + + Sign in as... + + )} onSelectAccount()} pendingDid={pendingDid} /> - - - - + {isWeb && ( + + + + + )} ) } diff --git a/src/screens/Login/LoginForm.tsx b/src/screens/Login/LoginForm.tsx index 7212f611b1..8a28771178 100644 --- a/src/screens/Login/LoginForm.tsx +++ b/src/screens/Login/LoginForm.tsx @@ -1,11 +1,5 @@ import React, {useRef, useState} from 'react' -import { - ActivityIndicator, - Keyboard, - LayoutAnimation, - type TextInput, - View, -} from 'react-native' +import {Keyboard, type TextInput, View} from 'react-native' import { ComAtprotoServerCreateSession, type ComAtprotoServerDescribeServer, @@ -19,10 +13,11 @@ import {cleanError} from '#/lib/strings/errors' import {createFullHandle} from '#/lib/strings/handles' import {logger} from '#/logger' import {isIOS} from '#/platform/detection' +import {isWeb} from '#/platform/detection' import {useSetHasCheckedForStarterPack} from '#/state/preferences/used-starter-packs' import {useSessionApi} from '#/state/session' import {useLoggedOutViewControls} from '#/state/shell/logged-out' -import {atoms as a, ios, useTheme} from '#/alf' +import {atoms as a, ios, useTheme, web} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {FormError} from '#/components/forms/FormError' import {HostingProvider} from '#/components/forms/HostingProvider' @@ -84,7 +79,6 @@ export const LoginForm = ({ const onPressNext = async () => { if (isProcessing) return Keyboard.dismiss() - LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) setError('') const identifier = identifierValueRef.current.toLowerCase().trim() @@ -141,7 +135,6 @@ export const LoginForm = ({ requestNotificationsPermission('Login') } catch (e: any) { const errMsg = e.toString() - LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) setIsProcessing(false) if ( e instanceof ComAtprotoServerCreateSession.AuthFactorTokenRequiredError @@ -178,7 +171,7 @@ export const LoginForm = ({ } return ( - Sign in}> + Log in}> Hosting provider @@ -308,25 +301,26 @@ export const LoginForm = ({ )} - - - + + {isWeb && ( + <> + + + )} {!serviceDescription && error ? ( ) : !serviceDescription ? ( - <> - - - Connecting... - - + ) : ( diff --git a/src/screens/Login/components/AuthLayout/Header/index.tsx b/src/screens/Login/components/AuthLayout/Header/index.tsx new file mode 100644 index 0000000000..f11137dd27 --- /dev/null +++ b/src/screens/Login/components/AuthLayout/Header/index.tsx @@ -0,0 +1,92 @@ +import {useContext} from 'react' +import {type GestureResponderEvent, View} from 'react-native' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {HITSLOP_30} from '#/lib/constants' +import {isWeb} from '#/platform/detection' +import {Logomark} from '#/view/icons/Logomark' +import {atoms as a, platform, useGutters, useTheme} from '#/alf' +import {Button, ButtonIcon, type ButtonProps} from '#/components/Button' +import {ArrowLeft_Stroke2_Corner0_Rounded as ArrowLeft} from '#/components/icons/Arrow' +import { + BUTTON_VISUAL_ALIGNMENT_OFFSET, + Header, + HEADER_SLOT_SIZE, +} from '#/components/Layout' +import {AuthLayoutNavigationContext} from '../context' + +/** + * This is a simplified version of `Layout.Header` for the auth screens. + */ + +export const Slot = Header.Slot + +export function Outer({children}: {children: React.ReactNode}) { + const t = useTheme() + const gutters = useGutters([0, 'wide']) + + return ( + + {children} + + ) +} + +export function Content({children}: {children?: React.ReactNode}) { + return ( + + {isWeb ? children : } + + ) +} + +export function Logo() { + const t = useTheme() + + return +} + +export function BackButton({onPress, style, ...props}: Partial) { + const {_} = useLingui() + const navigation = useContext(AuthLayoutNavigationContext) + + const onPressBack = (evt: GestureResponderEvent) => { + onPress?.(evt) + if (evt.defaultPrevented) return + navigation?.goBack() + } + + return ( + + + + ) +} diff --git a/src/screens/Login/components/AuthLayout/Header/index.web.tsx b/src/screens/Login/components/AuthLayout/Header/index.web.tsx new file mode 100644 index 0000000000..08e9eb0eb3 --- /dev/null +++ b/src/screens/Login/components/AuthLayout/Header/index.web.tsx @@ -0,0 +1,23 @@ +import {type ButtonProps} from '#/components/Button' +import {Header} from '#/components/Layout' + +// TEMP: Web needs a much more comprehensive layout change to support the new design +// so to do this incrementally, we'll do native only and migrate to web later + +export const Slot = Header.Slot + +export function Outer({}: {children: React.ReactNode}) { + return null +} + +export function Content({}: {children?: React.ReactNode}) { + return null +} + +export function Logo() { + return null +} + +export function BackButton({}: Partial) { + return null +} diff --git a/src/screens/Login/components/AuthLayout/context.ts b/src/screens/Login/components/AuthLayout/context.ts new file mode 100644 index 0000000000..871113fcdf --- /dev/null +++ b/src/screens/Login/components/AuthLayout/context.ts @@ -0,0 +1,5 @@ +import {createContext} from 'react' + +export const AuthLayoutNavigationContext = createContext<{ + goBack: () => void +} | null>(null) diff --git a/src/screens/Login/components/AuthLayout/index.tsx b/src/screens/Login/components/AuthLayout/index.tsx new file mode 100644 index 0000000000..2b3629bbd8 --- /dev/null +++ b/src/screens/Login/components/AuthLayout/index.tsx @@ -0,0 +1 @@ +export * as Header from './Header' diff --git a/src/screens/Login/index.tsx b/src/screens/Login/index.tsx index 9cbbd51216..4c6f502979 100644 --- a/src/screens/Login/index.tsx +++ b/src/screens/Login/index.tsx @@ -18,6 +18,8 @@ import {SetNewPasswordForm} from '#/screens/Login/SetNewPasswordForm' import {atoms as a, native} from '#/alf' import {ScreenTransition} from '#/components/ScreenTransition' import {ChooseAccountForm} from './ChooseAccountForm' +import * as AuthLayout from './components/AuthLayout' +import {AuthLayoutNavigationContext} from './components/AuthLayout/context' enum Forms { Login, @@ -130,11 +132,14 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => { let content = null let title = '' let description = '' + let goBack = null switch (currentForm) { case Forms.Login: title = _(msg`Sign in`) description = _(msg`Enter your username and password`) + goBack = () => + accounts.length ? gotoForm(Forms.ChooseAccount) : handlePressBack() content = ( void}) => { onAttemptFailed={onAttemptFailed} onAttemptSuccess={onAttemptSuccess} setServiceUrl={setServiceUrl} - onPressBack={() => - accounts.length ? gotoForm(Forms.ChooseAccount) : handlePressBack() - } + onPressBack={goBack} onPressForgotPassword={onPressForgotPassword} onPressRetryConnect={refetchService} /> @@ -156,16 +159,18 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => { case Forms.ChooseAccount: title = _(msg`Sign in`) description = _(msg`Select from an existing account`) + goBack = handlePressBack content = ( ) break case Forms.ForgotPassword: title = _(msg`Forgot Password`) description = _(msg`Let's get your password reset!`) + goBack = () => gotoForm(Forms.Login) content = ( void}) => { serviceDescription={serviceDescription} setError={setError} setServiceUrl={setServiceUrl} - onPressBack={() => gotoForm(Forms.Login)} + onPressBack={goBack} onEmailSent={() => gotoForm(Forms.SetNewPassword)} /> ) @@ -181,12 +186,13 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => { case Forms.SetNewPassword: title = _(msg`Forgot Password`) description = _(msg`Let's get your password reset!`) + goBack = () => gotoForm(Forms.ForgotPassword) content = ( gotoForm(Forms.ForgotPassword)} + onPressBack={goBack} onPasswordSet={() => gotoForm(Forms.PasswordUpdated)} /> ) @@ -200,23 +206,35 @@ export const Login = ({onPressBack}: {onPressBack: () => void}) => { break } + const navigation = goBack ? {goBack} : null + return ( - - - - - - {content} - - - - - + + + + + + + + + + + + {content} + + + + + + ) }