From 712768dd8f9172ff79700765f9f09db07ca00028 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 4 Apr 2024 03:18:14 +0100 Subject: Use ALF for the account quick switch dialog (#3327) * Use ALF for account quick switch * clean up modal type * add haptics to dialog opening * move account list to it's own component and share * make tick slightly darker --- src/components/AccountList.tsx | 141 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 src/components/AccountList.tsx (limited to 'src/components/AccountList.tsx') diff --git a/src/components/AccountList.tsx b/src/components/AccountList.tsx new file mode 100644 index 000000000..169e7b84f --- /dev/null +++ b/src/components/AccountList.tsx @@ -0,0 +1,141 @@ +import React, {useCallback} from 'react' +import {View} from 'react-native' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {useProfileQuery} from '#/state/queries/profile' +import {type SessionAccount, useSession} from '#/state/session' +import {UserAvatar} from '#/view/com/util/UserAvatar' +import {atoms as a, useTheme} from '#/alf' +import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' +import {ChevronRight_Stroke2_Corner0_Rounded as Chevron} from '#/components/icons/Chevron' +import {Button} from './Button' +import {Text} from './Typography' + +export function AccountList({ + onSelectAccount, + onSelectOther, + otherLabel, +}: { + onSelectAccount: (account: SessionAccount) => void + onSelectOther: () => void + otherLabel?: string +}) { + const {isSwitchingAccounts, currentAccount, accounts} = useSession() + const t = useTheme() + const {_} = useLingui() + + const onPressAddAccount = useCallback(() => { + onSelectOther() + }, [onSelectOther]) + + return ( + + {accounts.map(account => ( + + + + + ))} + + + ) +} + +function AccountItem({ + account, + onSelect, + isCurrentAccount, +}: { + account: SessionAccount + onSelect: (account: SessionAccount) => void + isCurrentAccount: boolean +}) { + const t = useTheme() + const {_} = useLingui() + const {data: profile} = useProfileQuery({did: account.did}) + + const onPress = React.useCallback(() => { + onSelect(account) + }, [account, onSelect]) + + return ( + + ) +} -- cgit 1.4.1