Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
at main 65 lines 1.9 kB view raw
1import {useCallback} from 'react' 2import {View} from 'react-native' 3import {msg} from '@lingui/core/macro' 4import {useLingui} from '@lingui/react' 5import {Trans} from '@lingui/react/macro' 6 7import {useAccountSwitcher} from '#/lib/hooks/useAccountSwitcher' 8import {type SessionAccount, useSession} from '#/state/session' 9import {useLoggedOutViewControls} from '#/state/shell/logged-out' 10import {atoms as a} from '#/alf' 11import * as Dialog from '#/components/Dialog' 12import {AccountList} from '../AccountList' 13import {Text} from '../Typography' 14 15export function SwitchAccountDialog({ 16 control, 17}: { 18 control: Dialog.DialogControlProps 19}) { 20 const {_} = useLingui() 21 const {currentAccount} = useSession() 22 const {onPressSwitchAccount, pendingDid} = useAccountSwitcher() 23 const {setShowLoggedOut} = useLoggedOutViewControls() 24 25 const onSelectAccount = useCallback( 26 (account: SessionAccount) => { 27 if (account.did !== currentAccount?.did) { 28 control.close(() => { 29 onPressSwitchAccount(account, 'SwitchAccount') 30 }) 31 } else { 32 control.close() 33 } 34 }, 35 [currentAccount, control, onPressSwitchAccount], 36 ) 37 38 const onPressAddAccount = useCallback(() => { 39 control.close(() => { 40 setShowLoggedOut(true) 41 }) 42 }, [setShowLoggedOut, control]) 43 44 return ( 45 <Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}> 46 <Dialog.Handle /> 47 <Dialog.ScrollableInner label={_(msg`Switch account`)}> 48 <View style={[a.gap_lg]}> 49 <Text style={[a.text_2xl, a.font_semi_bold]}> 50 <Trans>Switch account</Trans> 51 </Text> 52 53 <AccountList 54 onSelectAccount={onSelectAccount} 55 onSelectOther={onPressAddAccount} 56 otherLabel={_(msg`Add account`)} 57 pendingDid={pendingDid} 58 /> 59 </View> 60 61 <Dialog.Close /> 62 </Dialog.ScrollableInner> 63 </Dialog.Outer> 64 ) 65}