-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: update notification account settings to use BIP-44 designs #20307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9c84627
926eab1
b8f76b4
9269693
b12a6d3
957a2c3
d641cb1
a9574bd
a88a088
7d58f71
96be66a
48fc651
fbf39c0
bba3019
0e45afd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { AccountGroupObject } from '@metamask/account-tree-controller'; | ||
| import React, { useCallback, useMemo } from 'react'; | ||
| import { TouchableOpacity, View } from 'react-native'; | ||
| import { type ImageSourcePropType, TouchableOpacity, View } from 'react-native'; | ||
| import { useSelector } from 'react-redux'; | ||
| import { useNavigation } from '@react-navigation/native'; | ||
| import { useStyles } from '../../../hooks'; | ||
|
|
@@ -36,18 +36,24 @@ interface AccountCellProps { | |
| avatarAccountType: AvatarAccountType; | ||
| hideMenu?: boolean; | ||
| startAccessory?: React.ReactNode; | ||
| endContainer?: React.ReactNode; | ||
| chainId?: string; | ||
| onSelectAccount?: () => void; | ||
| } | ||
|
|
||
| const AccountCell = ({ | ||
| type BalanceEndContainerProps = Pick< | ||
| AccountCellProps, | ||
| 'accountGroup' | 'hideMenu' | 'onSelectAccount' | ||
| > & { | ||
| networkImageSource?: ImageSourcePropType; | ||
| }; | ||
|
|
||
| const BalanceEndContainer = ({ | ||
| accountGroup, | ||
| avatarAccountType, | ||
| hideMenu = false, | ||
| startAccessory, | ||
| chainId, | ||
| hideMenu, | ||
| onSelectAccount, | ||
| }: AccountCellProps) => { | ||
| networkImageSource, | ||
| }: BalanceEndContainerProps) => { | ||
| const { styles } = useStyles(styleSheet, {}); | ||
| const { navigate } = useNavigation(); | ||
|
|
||
|
|
@@ -63,12 +69,6 @@ const AccountCell = ({ | |
| const totalBalance = groupBalance?.totalBalanceInUserCurrency; | ||
| const userCurrency = groupBalance?.userCurrency; | ||
|
|
||
| const selectEvmAddress = useMemo( | ||
| () => selectIconSeedAddressByAccountGroupId(accountGroup.id), | ||
| [accountGroup.id], | ||
| ); | ||
| const evmAddress = useSelector(selectEvmAddress); | ||
|
|
||
| const displayBalance = useMemo(() => { | ||
| if (totalBalance == null || !userCurrency) { | ||
| return undefined; | ||
|
|
@@ -79,6 +79,61 @@ const AccountCell = ({ | |
| }); | ||
| }, [totalBalance, userCurrency]); | ||
|
|
||
| return ( | ||
| <> | ||
| <TouchableOpacity onPress={onSelectAccount}> | ||
| <View style={styles.balanceContainer}> | ||
| <Text | ||
| variant={TextVariant.BodyMDMedium} | ||
| color={TextColor.Default} | ||
| testID={AccountCellIds.BALANCE} | ||
| > | ||
| {totalBalance ? displayBalance : null} | ||
| </Text> | ||
| {networkImageSource && ( | ||
| <Avatar | ||
| variant={AvatarVariant.Network} | ||
| size={AvatarSize.Xs} | ||
| style={styles.networkBadge} | ||
| imageSource={networkImageSource} | ||
| /> | ||
| )} | ||
| </View> | ||
| </TouchableOpacity> | ||
| {!hideMenu && ( | ||
| <TouchableOpacity | ||
| testID={AccountCellIds.MENU} | ||
| style={styles.menuButton} | ||
| onPress={handleMenuPress} | ||
| > | ||
| <Icon | ||
| name={IconName.MoreVertical} | ||
| size={IconSize.Md} | ||
| color={TextColor.Alternative} | ||
| /> | ||
| </TouchableOpacity> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| const AccountCell = ({ | ||
| accountGroup, | ||
| avatarAccountType, | ||
| hideMenu = false, | ||
| startAccessory, | ||
| endContainer, | ||
| chainId, | ||
| onSelectAccount, | ||
| }: AccountCellProps) => { | ||
| const { styles } = useStyles(styleSheet, {}); | ||
|
|
||
| const selectEvmAddress = useMemo( | ||
| () => selectIconSeedAddressByAccountGroupId(accountGroup.id), | ||
| [accountGroup.id], | ||
| ); | ||
| const evmAddress = useSelector(selectEvmAddress); | ||
|
|
||
| // Determine which account address and network avatar to display based on the chainId | ||
| let networkAccountAddress; | ||
| let networkImageSource; | ||
|
|
@@ -138,37 +193,13 @@ const AccountCell = ({ | |
| </View> | ||
| </TouchableOpacity> | ||
| <View style={styles.endContainer}> | ||
| <TouchableOpacity onPress={onSelectAccount}> | ||
| <View style={styles.balanceContainer}> | ||
| <Text | ||
| variant={TextVariant.BodyMDMedium} | ||
| color={TextColor.Default} | ||
| testID={AccountCellIds.BALANCE} | ||
| > | ||
| {totalBalance ? displayBalance : null} | ||
| </Text> | ||
| {networkImageSource && ( | ||
| <Avatar | ||
| variant={AvatarVariant.Network} | ||
| size={AvatarSize.Xs} | ||
| style={styles.networkBadge} | ||
| imageSource={networkImageSource} | ||
| /> | ||
| )} | ||
| </View> | ||
| </TouchableOpacity> | ||
| {!hideMenu && ( | ||
| <TouchableOpacity | ||
| testID={AccountCellIds.MENU} | ||
| style={styles.menuButton} | ||
| onPress={handleMenuPress} | ||
| > | ||
| <Icon | ||
| name={IconName.MoreVertical} | ||
| size={IconSize.Md} | ||
| color={TextColor.Alternative} | ||
| /> | ||
| </TouchableOpacity> | ||
| {endContainer || ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I guess
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha good callout. Emm might visit this later since I have approvals 🤪 I've tested this feature with the team 👍🏾 |
||
| <BalanceEndContainer | ||
| accountGroup={accountGroup} | ||
| hideMenu={hideMenu} | ||
| onSelectAccount={onSelectAccount} | ||
| networkImageSource={networkImageSource} | ||
| /> | ||
| )} | ||
| </View> | ||
| </Box> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| import { ViewStyle } from 'react-native'; | ||
|
|
||
| export interface AccountListHeaderProps { | ||
| title: string; | ||
| containerStyle?: ViewStyle; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified so we can pass in either a custom component or rely on the existing component. Provides more flexibility.