Skip to content

Commit

Permalink
Use localized percent handling for CoinRankRow
Browse files Browse the repository at this point in the history
Ensure localized decimal characters are used
  • Loading branch information
Jon-edge committed Apr 28, 2023
1 parent 1028910 commit d6dbc77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/data/row/CoinRankRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { cacheStyles } from 'react-native-patina'
import { getSymbolFromCurrency } from '../../../constants/WalletAndCurrencyConstants'
import { formatFiatString } from '../../../hooks/useFiatText'
import { useHandler } from '../../../hooks/useHandler'
import { toPercentString } from '../../../locales/intl'
import { getDefaultFiat } from '../../../selectors/SettingsSelectors'
import { AssetSubText, CoinRanking, CoinRankingData, PercentChangeTimeFrame } from '../../../types/coinrankTypes'
import { useState } from '../../../types/reactHooks'
Expand Down Expand Up @@ -129,15 +130,15 @@ const CoinRankRowComponent = (props: Props) => {
// Calculate percent change string
const percentChangeRaw = percentChange[percentChangeTimeFrame]
numDecimals = getNumDecimals(percentChangeRaw, 2)
const percentChangeString = round(percentChangeRaw.toString(), -numDecimals)
const percentChangeString = toPercentString(percentChangeRaw / 100, { noGrouping: true })
const negative = lt(percentChangeString, '0')

// Calculate price string
numDecimals = getNumDecimals(price)
const priceStyle = negative ? styles.negativeText : styles.positiveText
const plusMinus = negative ? '' : '+'
const priceString = `${fiatSymbol}${formatFiatString({ fiatAmount: price.toString() })}`
const percentString = `${plusMinus}${percentChangeString}%`
const percentString = `${plusMinus}${percentChangeString}`

return (
<TouchableOpacity style={styles.container} onPress={handlePress}>
Expand Down

0 comments on commit d6dbc77

Please sign in to comment.