From 5ec8761b294b6a650af9ee286df6864d6fc4f25d Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 22 Aug 2024 20:09:55 -0500 Subject: Make settings account buttons a little nicer (#4980) * Replace account dropdown with Menu * Replace card row and add interaction state * Remove testID copy pasta * Sanitize handle * Remove hover from row --- src/view/com/util/AccountDropdownBtn.tsx | 78 +++++++++++++++++--------------- src/view/screens/Settings/index.tsx | 71 +++++++++++++++++------------ 2 files changed, 83 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/view/com/util/AccountDropdownBtn.tsx b/src/view/com/util/AccountDropdownBtn.tsx index fa2553d38..034fbfc65 100644 --- a/src/view/com/util/AccountDropdownBtn.tsx +++ b/src/view/com/util/AccountDropdownBtn.tsx @@ -1,53 +1,59 @@ import React from 'react' -import {Pressable} from 'react-native' -import { - FontAwesomeIcon, - FontAwesomeIconStyle, -} from '@fortawesome/react-native-fontawesome' -import {msg} from '@lingui/macro' +import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {SessionAccount, useSessionApi} from '#/state/session' -import {usePalette} from 'lib/hooks/usePalette' -import {s} from 'lib/styles' +import {HITSLOP_10} from 'lib/constants' +import {Button, ButtonIcon} from '#/components/Button' import {useDialogControl} from '#/components/Dialog' +import {DotGrid_Stroke2_Corner0_Rounded as Ellipsis} from '#/components/icons/DotGrid' +import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash' +import * as Menu from '#/components/Menu' import * as Prompt from '#/components/Prompt' import * as Toast from '../../com/util/Toast' -import {DropdownItem, NativeDropdown} from './forms/NativeDropdown' export function AccountDropdownBtn({account}: {account: SessionAccount}) { - const pal = usePalette('default') + const {_} = useLingui() const {removeAccount} = useSessionApi() const removePromptControl = useDialogControl() - const {_} = useLingui() - const items: DropdownItem[] = [ - { - label: _(msg`Remove account`), - onPress: removePromptControl.open, - icon: { - ios: { - name: 'trash', - }, - android: 'ic_delete', - web: ['far', 'trash-can'], - }, - }, - ] return ( <> - - - - - + + + {({props}) => { + return ( + + ) + }} + + + + + { + removePromptControl.open() + }}> + + Remove account + + + + + + + void }) { - const pal = usePalette('default') const {_} = useLingui() const t = useTheme() const {currentAccount} = useSession() const {data: profile} = useProfileQuery({did: account.did}) const isCurrentAccount = account.did === currentAccount?.did - const contents = ( + const contents = (ctx: ButtonContext) => ( - - - - - + + + {profile?.displayName || account.handle} - - - {account.handle} - + + + {sanitizeHandle(account.handle, '@')} + ) return isCurrentAccount ? ( - + label={_(msg`Your profile`)} + style={[a.w_full]}> {contents} - + ) : ( - onPressSwitchAccount(account, 'Settings') } - accessibilityRole="button" - accessibilityLabel={_(msg`Switch to ${account.handle}`)} - accessibilityHint={_(msg`Switches the account you are logged in to`)} - activeOpacity={0.8}> + label={_(msg`Switch to ${account.handle}`)} + style={[a.w_full]}> {contents} - + ) } -- cgit 1.4.1