Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at cope-settings-sync 96 lines 2.8 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 accounts, 18 title, 19 pendingDid: pendingDidProp, 20 selectedDid, 21 otherLabel, 22 showAddAccount = true, 23 onSelectAccount: onSelectAccountProp, 24 onSelectOther: onSelectOtherProp, 25}: { 26 control: Dialog.DialogControlProps 27 accounts?: SessionAccount[] 28 title?: string 29 pendingDid?: string | null 30 selectedDid?: string | null 31 otherLabel?: string 32 showAddAccount?: boolean 33 onSelectAccount?: (account: SessionAccount) => void 34 onSelectOther?: () => void 35}) { 36 const {_} = useLingui() 37 const {currentAccount} = useSession() 38 const {onPressSwitchAccount, pendingDid} = useAccountSwitcher() 39 const {setShowLoggedOut} = useLoggedOutViewControls() 40 41 const onSelectAccount = useCallback( 42 (account: SessionAccount) => { 43 if (onSelectAccountProp) { 44 control.close(() => { 45 onSelectAccountProp(account) 46 }) 47 return 48 } 49 if (account.did !== currentAccount?.did) { 50 control.close(() => { 51 onPressSwitchAccount(account, 'SwitchAccount') 52 }) 53 } else { 54 control.close() 55 } 56 }, 57 [control, currentAccount, onPressSwitchAccount, onSelectAccountProp], 58 ) 59 60 const onPressAddAccount = useCallback(() => { 61 if (onSelectOtherProp) { 62 control.close(() => { 63 onSelectOtherProp() 64 }) 65 return 66 } 67 control.close(() => { 68 setShowLoggedOut(true) 69 }) 70 }, [control, onSelectOtherProp, setShowLoggedOut]) 71 72 return ( 73 <Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}> 74 <Dialog.Handle /> 75 <Dialog.ScrollableInner label={_(msg`Switch account`)}> 76 <View style={[a.gap_lg]}> 77 <Text style={[a.text_2xl, a.font_semi_bold]}> 78 {title ?? <Trans>Switch account</Trans>} 79 </Text> 80 81 <AccountList 82 accounts={accounts} 83 onSelectAccount={onSelectAccount} 84 onSelectOther={onPressAddAccount} 85 otherLabel={otherLabel ?? _(msg`Add account`)} 86 pendingDid={pendingDidProp ?? pendingDid} 87 selectedDid={selectedDid} 88 showAddAccount={showAddAccount} 89 /> 90 </View> 91 92 <Dialog.Close /> 93 </Dialog.ScrollableInner> 94 </Dialog.Outer> 95 ) 96}