From 3b6c5d7f83b640d2157f92d99dc378bee6bed196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jirka=20Ba=C5=BEant?= Date: Mon, 13 Jan 2025 10:39:50 +0100 Subject: [PATCH 1/2] fix(suite-native): Coin price card translations --- suite-native/intl/src/en.ts | 6 ++++++ .../src/components/CoinPriceCard.tsx | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/suite-native/intl/src/en.ts b/suite-native/intl/src/en.ts index 60b6126940c..c2d861b0ed0 100644 --- a/suite-native/intl/src/en.ts +++ b/suite-native/intl/src/en.ts @@ -835,6 +835,12 @@ export const en = { coinLabel: 'Coin label', }, }, + accountDetailContentScreen: { + coinPriceCard: { + changeIn24h: '24h change', + coinPrice: '{coinName} price', + }, + }, }, moduleAccounts: { accountDetail: { diff --git a/suite-native/module-accounts-management/src/components/CoinPriceCard.tsx b/suite-native/module-accounts-management/src/components/CoinPriceCard.tsx index 37d6a660ea8..7de9a3d71a3 100644 --- a/suite-native/module-accounts-management/src/components/CoinPriceCard.tsx +++ b/suite-native/module-accounts-management/src/components/CoinPriceCard.tsx @@ -6,6 +6,7 @@ import { getNetworkDisplaySymbolName } from '@suite-common/wallet-config'; import { FiatAmountFormatter } from '@suite-native/formatters'; import { AccountKey } from '@suite-common/wallet-types'; import { AccountsRootState, selectAccountNetworkSymbol } from '@suite-common/wallet-core'; +import { Translation } from '@suite-native/intl'; import { useDayCoinPriceChange } from '../hooks/useDayCoinPriceChange'; @@ -53,7 +54,7 @@ const PriceChangeIndicator = ({ valuePercentageChange }: PriceChangeIndicatorPro return ( - 24h change + {valuePercentageChange ? ( @@ -92,7 +93,10 @@ export const CoinPriceCard = ({ accountKey }: CoinPriceCardProps) => { - {coinName} price + {currentValue && ( Date: Mon, 13 Jan 2025 11:48:03 +0100 Subject: [PATCH 2/2] fix(suite-native): We show network symbol in place of displaySymbol (#16190) This reverts commit ea3a752a8858f42c956dfa0bfe412fc567be00bc. --- .../prepareNetworkSymbolFormatter.ts | 6 ++-- .../prepareNetworkSymbolFormatter.test.ts | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 suite-common/formatters/src/formatters/tests/prepareNetworkSymbolFormatter.test.ts diff --git a/suite-common/formatters/src/formatters/prepareNetworkSymbolFormatter.ts b/suite-common/formatters/src/formatters/prepareNetworkSymbolFormatter.ts index 200410afcb4..5db3ebe3176 100644 --- a/suite-common/formatters/src/formatters/prepareNetworkSymbolFormatter.ts +++ b/suite-common/formatters/src/formatters/prepareNetworkSymbolFormatter.ts @@ -1,5 +1,5 @@ import { UNIT_ABBREVIATIONS } from '@suite-common/suite-constants'; -import { getNetwork, NetworkSymbol } from '@suite-common/wallet-config'; +import { getNetwork, getNetworkDisplaySymbol, NetworkSymbol } from '@suite-common/wallet-config'; import { FormatterConfig } from '../types'; import { makeFormatter } from '../makeFormatter'; @@ -14,13 +14,13 @@ export const prepareNetworkSymbolFormatter = (config: FormatterConfig) => const { features: networkFeatures, testnet: isTestnet } = getNetwork(symbol); const areAmountUnitsSupported = !!networkFeatures?.includes('amount-unit'); - let formattedSymbol = symbol.toUpperCase(); + let formattedSymbol = getNetworkDisplaySymbol(symbol); // convert to different units if needed if (areAmountUnitsEnabled && areAmountUnitsSupported) { const unitAbbreviation = UNIT_ABBREVIATIONS[bitcoinAmountUnit]; formattedSymbol = isTestnet - ? `${unitAbbreviation} ${symbol.toUpperCase()}` + ? `${unitAbbreviation} ${formattedSymbol}` : unitAbbreviation; } diff --git a/suite-common/formatters/src/formatters/tests/prepareNetworkSymbolFormatter.test.ts b/suite-common/formatters/src/formatters/tests/prepareNetworkSymbolFormatter.test.ts new file mode 100644 index 00000000000..0d0df3e2e5a --- /dev/null +++ b/suite-common/formatters/src/formatters/tests/prepareNetworkSymbolFormatter.test.ts @@ -0,0 +1,30 @@ +import { PROTO } from '@trezor/connect'; +import { NetworkSymbol } from '@suite-common/wallet-config'; + +import { prepareNetworkSymbolFormatter } from '../prepareNetworkSymbolFormatter'; + +describe('prepareNetworkSymbolFormatter', () => { + let networkSymbolFormatter: ReturnType; + + beforeEach(() => { + networkSymbolFormatter = prepareNetworkSymbolFormatter({ + coins: [], + locale: 'en', + bitcoinAmountUnit: PROTO.AmountUnit.BITCOIN, + // @ts-expect-error - no need to test it with Intl for now + intl: {}, + }); + }); + + it.each([ + ['bsc', 'BNB'], + ['arb', 'ETH'], + ['base', 'ETH'], + ['btc', 'BTC'], + ] as [NetworkSymbol, string][])( + 'should display symbolName (#16190) case %#', + (symbol: NetworkSymbol, expectedValue: string) => { + expect(networkSymbolFormatter.format(symbol, {})).toBe(expectedValue); + }, + ); +});