Skip to content
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

fix(mobile): reflect token fiat value in account list #14446

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions suite-native/accounts/src/components/AccountListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { useFormatters } from '@suite-common/formatters';
import { AccountsRootState, selectFormattedAccountType } from '@suite-common/wallet-core';
import { Account, AccountKey } from '@suite-common/wallet-types';
import { Badge, RoundedIcon } from '@suite-native/atoms';
import { CryptoAmountFormatter, CryptoToFiatAmountFormatter } from '@suite-native/formatters';
import {
CryptoAmountFormatter,
CryptoToFiatAmountFormatter,
FiatAmountFormatter,
} from '@suite-native/formatters';
import { Translation } from '@suite-native/intl';
import {
isCoinWithTokens,
Expand All @@ -19,6 +23,7 @@ import { AccountListItemBase } from './AccountListItemBase';

export type AccountListItemProps = {
account: Account;
fiatBalance?: string | null;
hideTokens?: boolean;

onPress?: TouchableOpacityProps['onPress'];
Expand All @@ -44,6 +49,7 @@ export const AccountListItem = ({
onPress,
disabled,
hideTokens = false,
fiatBalance,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What abount not passing this as a prop but rather select it inside AccountListItem with a selector?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because sometimes this selector will be called but value will be unused anyway so I don't want to waste resources

}: AccountListItemProps) => {
const { accountLabel } = account;
const { NetworkNameFormatter } = useFormatters();
Expand Down Expand Up @@ -80,10 +86,18 @@ export const AccountListItem = ({
</>
}
mainValue={
<CryptoToFiatAmountFormatter
value={account.availableBalance}
network={account.symbol}
/>
shouldShowTokenBadge && fiatBalance !== undefined ? (
<FiatAmountFormatter
numberOfLines={1}
adjustsFontSizeToFit
value={fiatBalance}
/>
) : (
<CryptoToFiatAmountFormatter
value={account.availableBalance}
network={account.symbol}
/>
)
}
secondaryValue={
<CryptoAmountFormatter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const AccountListItemInteractive = ({
key={account.key}
account={account}
hideTokens={hideTokens}
fiatBalance={fiatBalance}
onPress={() =>
onSelectAccount({
account,
Expand Down
Loading