Skip to content

Commit

Permalink
feat(suite-native): add icon with network to accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
vytick committed Feb 5, 2025
1 parent d5e3480 commit 3178934
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback } from 'react';
import React, { useCallback, useMemo } from 'react';
import { useSelector } from 'react-redux';

import { useFormatters } from '@suite-common/formatters';
Expand All @@ -10,6 +10,7 @@ import {
CryptoToFiatAmountFormatter,
FiatAmountFormatter,
} from '@suite-native/formatters';
import { CryptoIconWithNetwork } from '@suite-native/icons';
import { Translation } from '@suite-native/intl';
import { NativeStakingRootState, selectAccountHasStaking } from '@suite-native/staking';
import {
Expand All @@ -27,10 +28,8 @@ import { OnSelectAccount } from '../../types';
export type AccountListItemProps = {
account: Account;
isInModal?: boolean;

onPress?: OnSelectAccount;
disabled?: boolean;

hasBackground?: boolean;
isFirst?: boolean;
isLast?: boolean;
Expand Down Expand Up @@ -87,6 +86,16 @@ export const AccountsListItem = ({
});
}, [account, accountHasAnyTokens, accountHasStaking, onPress]);

const icon = useMemo(
() =>
isInModal ? (
<CryptoIconWithNetwork symbol={account.symbol} preferNetworkSymbol={false} />
) : (
<RoundedIcon symbol={account.symbol} />
),
[account.symbol, isInModal],
);

const doesCoinSupportTokens = isCoinWithTokens(account.symbol);
const shouldShowAccountLabel = !doesCoinSupportTokens || !isInModal;
const shouldShowTokenBadge = accountHasAnyTokens && !isInModal;
Expand All @@ -100,7 +109,7 @@ export const AccountsListItem = ({
showDivider={showDivider}
onPress={handleOnPress}
disabled={disabled}
icon={<RoundedIcon symbol={account.symbol} />}
icon={icon}
title={
shouldShowAccountLabel ? (
accountLabel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useSelector } from 'react-redux';

import { Account, TokenInfoBranded } from '@suite-common/wallet-types';
import { RoundedIcon } from '@suite-native/atoms';
import { TokenAmountFormatter, TokenToFiatAmountFormatter } from '@suite-native/formatters';
import { TokensRootState, getTokenName, selectAccountTokenSymbol } from '@suite-native/tokens';
import { getTokenName, selectAccountTokenSymbol, TokensRootState } from '@suite-native/tokens';

Check warning on line 5 in suite-native/accounts/src/components/AccountsList/AccountsListTokenItem.tsx

View workflow job for this annotation

GitHub Actions / Linting and formatting

Member 'TokensRootState' of the import declaration should be sorted alphabetically
import { CryptoIconWithNetwork } from '@suite-native/icons';

Check warning on line 6 in suite-native/accounts/src/components/AccountsList/AccountsListTokenItem.tsx

View workflow job for this annotation

GitHub Actions / Linting and formatting

`@suite-native/icons` import should occur before import of `@suite-native/tokens`

import { AccountsListItemBase } from './AccountsListItemBase';

Expand Down Expand Up @@ -36,7 +36,9 @@ export const AccountsListTokenItem = ({
isFirst={isFirst}
isLast={isLast}
onPress={onSelectAccount}
icon={<RoundedIcon symbol={account.symbol} contractAddress={token.contract} />}
icon={
<CryptoIconWithNetwork symbol={account.symbol} contractAddress={token.contract} />
}
title={getTokenName(token.name)}
mainValue={
<TokenToFiatAmountFormatter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NetworkIcon } from '@suite-native/icons';
import { getNetwork, type NetworkSymbol } from '@suite-common/wallet-config';
import { type NetworkSymbol, getNetwork } from '@suite-common/wallet-config';
import { Card, HStack, Text } from '@suite-native/atoms';
import { CryptoIcon } from '@suite-native/icons';
import { NetworkIcon } from '@suite-native/icons';
import { Translation } from '@suite-native/intl';
import { Link } from '@suite-native/link';
import { isCoinWithTokens } from '@suite-native/tokens';
Expand Down
7 changes: 3 additions & 4 deletions suite-native/module-send/src/screens/SendOutputsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
updateFeeInfoThunk,
} from '@suite-common/wallet-core';
import { TokenAddress } from '@suite-common/wallet-types';
import { CoinPriceCard } from '@suite-native/accounts';
import { Box, Button } from '@suite-native/atoms';
import { Form, useForm } from '@suite-native/forms';
import { Translation } from '@suite-native/intl';
Expand All @@ -33,10 +34,8 @@ import {
StackNavigationProps,
StackProps,
} from '@suite-native/navigation';
import { getNetwork } from '@suite-common/wallet-config';
import { Box, Button } from '@suite-native/atoms';
import { CoinPriceCard } from '@suite-native/accounts';
import { Translation } from '@suite-native/intl';
import { SettingsSliceRootState, selectIsAmountInSats } from '@suite-native/settings';
import { TokensRootState, selectAccountTokenInfo } from '@suite-native/tokens';
import { useDebounce } from '@trezor/react-utils';

import { AccountBalanceScreenHeader } from '../components/AccountBalanceScreenHeader';
Expand Down

0 comments on commit 3178934

Please sign in to comment.