1+ import { gt , mul } from 'biggystring'
12import { EdgeCurrencyWallet , EdgeTokenId , EdgeTokenMap , EdgeTransaction } from 'edge-core-js'
23import * as React from 'react'
34import { ListRenderItemInfo , Platform , RefreshControl , View } from 'react-native'
@@ -12,24 +13,26 @@ import { useHandler } from '../../hooks/useHandler'
1213import { useIconColor } from '../../hooks/useIconColor'
1314import { useTransactionList } from '../../hooks/useTransactionList'
1415import { useWatch } from '../../hooks/useWatch'
16+ import { formatNumber } from '../../locales/intl'
1517import { lstrings } from '../../locales/strings'
1618import { getExchangeDenomByCurrencyCode } from '../../selectors/DenominationSelectors'
1719import { FooterRender } from '../../state/SceneFooterState'
1820import { useSceneScrollHandler } from '../../state/SceneScrollState'
1921import { useDispatch , useSelector } from '../../types/reactRedux'
2022import { NavigationBase , WalletsTabSceneProps } from '../../types/routerTypes'
2123import { coinrankListData , infoServerData } from '../../util/network'
22- import { calculateSpamThreshold , darkenHexColor , unixToLocaleDateTime , zeroString } from '../../util/utils'
24+ import { calculateSpamThreshold , convertNativeToDenomination , darkenHexColor , unixToLocaleDateTime , zeroString } from '../../util/utils'
25+ import { EdgeCard } from '../cards/EdgeCard'
2326import { InfoCardCarousel } from '../cards/InfoCardCarousel'
2427import { SwipeChart } from '../charts/SwipeChart'
2528import { AccentColors } from '../common/DotsBackground'
2629import { EdgeAnim , fadeInDown10 , MAX_LIST_ITEMS_ANIM } from '../common/EdgeAnim'
27- import { EdgeTouchableOpacity } from '../common/EdgeTouchableOpacity'
2830import { SceneWrapper } from '../common/SceneWrapper'
31+ import { SectionHeader as SectionHeaderUi4 } from '../common/SectionHeader'
2932import { withWallet } from '../hoc/withWallet'
3033import { cacheStyles , useTheme } from '../services/ThemeContext'
3134import { BuyCrypto } from '../themed/BuyCrypto'
32- import { EdgeText } from '../themed/EdgeText'
35+ import { EdgeText , Paragraph } from '../themed/EdgeText'
3336import { ExplorerCard } from '../themed/ExplorerCard'
3437import { SearchFooter } from '../themed/SearchFooter'
3538import { EmptyLoader , SectionHeader , SectionHeaderCentered } from '../themed/TransactionListComponents'
@@ -59,6 +62,7 @@ function TransactionListComponent(props: Props) {
5962 const tokenId = checkToken ( route . params . tokenId , wallet . currencyConfig . allTokens )
6063 const { pluginId } = wallet . currencyInfo
6164 const { currencyCode } = tokenId == null ? wallet . currencyInfo : wallet . currencyConfig . allTokens [ tokenId ]
65+ const { displayName } = tokenId == null ? wallet . currencyInfo : wallet . currencyConfig . allTokens [ tokenId ]
6266
6367 // State:
6468 const flashListRef = React . useRef < Animated . FlatList < ListItem > | null > ( null )
@@ -83,6 +87,13 @@ function TransactionListComponent(props: Props) {
8387 // Derived values
8488 // ---------------------------------------------------------------------------
8589
90+ // Fiat Balance Formatting
91+ const exchangeAmount = convertNativeToDenomination ( exchangeDenom . multiplier ) ( exchangeDenom . multiplier )
92+ const fiatRate = mul ( exchangeAmount , exchangeRate )
93+ const fiatRateFormat = `${ formatNumber ( fiatRate && gt ( fiatRate , '0.000001' ) ? fiatRate : 0 , {
94+ toFixed : gt ( fiatRate , '1000' ) ? 0 : 2
95+ } ) } ${ fiatCurrencyCode } /${ currencyCode } `
96+
8697 const spamThreshold = React . useMemo < string | undefined > ( ( ) => {
8798 if ( spamFilterOn && ! zeroString ( exchangeRate ) ) {
8899 return calculateSpamThreshold ( exchangeRate , exchangeDenom )
@@ -185,6 +196,12 @@ function TransactionListComponent(props: Props) {
185196 setFooterHeight ( height )
186197 } )
187198
199+ const assetId = coinrankListData . coins [ currencyCode ]
200+
201+ const handlePressCoinRanking = useHandler ( ( ) => {
202+ navigation . navigate ( 'coinRankingDetails' , { assetId, fiatCurrencyCode } )
203+ } )
204+
188205 //
189206 // Renderers
190207 //
@@ -206,12 +223,6 @@ function TransactionListComponent(props: Props) {
206223 )
207224 } , [ ] )
208225
209- const assetId = coinrankListData . coins [ currencyCode ]
210-
211- const handlePressCoinRanking = useHandler ( ( ) => {
212- navigation . navigate ( 'coinRankingDetails' , { assetId, fiatCurrencyCode } )
213- } )
214-
215226 const topArea = React . useMemo ( ( ) => {
216227 return (
217228 < >
@@ -232,12 +243,20 @@ function TransactionListComponent(props: Props) {
232243 countryCode = { route . params . countryCode }
233244 screenWidth = { screenWidth }
234245 />
246+ { assetId != null && < SectionHeaderUi4 leftTitle = { displayName } rightNode = { lstrings . coin_rank_see_more } onRightPress = { handlePressCoinRanking } /> }
235247 { assetId != null && (
236- < EdgeTouchableOpacity onPress = { handlePressCoinRanking } >
237- < EdgeText > See More</ EdgeText >
238- </ EdgeTouchableOpacity >
248+ < EdgeCard >
249+ < Paragraph >
250+ < EdgeText > { fiatRateFormat } </ EdgeText >
251+ </ Paragraph >
252+ < SwipeChart cardAdjust assetId = { assetId } currencyCode = { currencyCode } fiatCurrencyCode = { fiatCurrencyCode } />
253+ </ EdgeCard >
239254 ) }
240- { assetId != null && < SwipeChart assetId = { assetId } currencyCode = { currencyCode } fiatCurrencyCode = { fiatCurrencyCode } /> }
255+ < SectionHeaderUi4
256+ leftTitle = { lstrings . transaction_list_recent_transactions }
257+ rightNode = { lstrings . coin_rank_see_more }
258+ onRightPress = { handlePressCoinRanking }
259+ />
241260 </ >
242261 )
243262 } , [
@@ -251,9 +270,11 @@ function TransactionListComponent(props: Props) {
251270 route . params . countryCode ,
252271 screenWidth ,
253272 assetId ,
273+ displayName ,
274+ handlePressCoinRanking ,
275+ fiatRateFormat ,
254276 currencyCode ,
255- fiatCurrencyCode ,
256- handlePressCoinRanking
277+ fiatCurrencyCode
257278 ] )
258279
259280 const emptyComponent = React . useMemo ( ( ) => {
0 commit comments