Skip to content

Commit 8352b02

Browse files
committed
WIP
1 parent 65055ef commit 8352b02

File tree

5 files changed

+50
-20
lines changed

5 files changed

+50
-20
lines changed

src/components/charts/SwipeChart.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ type Timespan = 'year' | 'month' | 'week' | 'day' | 'hour'
2525
type CoinGeckoDataPair = number[]
2626

2727
interface Props {
28-
assetId: string // The asset's 'id' as defined by CoinGecko
28+
/** The asset's 'id' as defined by CoinGecko */
29+
assetId: string
2930
currencyCode: string
3031
fiatCurrencyCode: string
32+
/** Modify positioning to fit properly in a card */
33+
cardAdjust?: boolean
3134
}
3235
interface ChartDataPoint {
3336
x: Date
@@ -129,7 +132,7 @@ const reduceChartData = (chartData: ChartDataPoint[], timespan: Timespan): Chart
129132
const SwipeChartComponent = (params: Props) => {
130133
const theme = useTheme()
131134
const styles = getStyles(theme)
132-
const { assetId, currencyCode, fiatCurrencyCode } = params
135+
const { assetId, cardAdjust, currencyCode, fiatCurrencyCode } = params
133136

134137
// #region Chart setup
135138

@@ -567,7 +570,7 @@ const SwipeChartComponent = (params: Props) => {
567570
toolTipProps={tooltipProps}
568571
// #endregion ToolTip
569572

570-
style={styles.baseChart}
573+
style={[styles.baseChart, cardAdjust ? styles.cardAdjust : undefined]}
571574
/>
572575

573576
{/* Min/Max price labels */}
@@ -614,6 +617,9 @@ const getStyles = cacheStyles((theme: Theme) => {
614617
alignSelf: 'flex-start',
615618
position: 'absolute'
616619
},
620+
cardAdjust: {
621+
marginLeft: theme.rem(-1)
622+
},
617623
container: {
618624
margin: theme.rem(0.5)
619625
},

src/components/scenes/CoinRankingDetailsScene.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const CoinRankingDetailsSceneComponent = (props: Props) => {
8383
const styles = getStyles(theme)
8484
const { route, navigation } = props
8585
const { assetId, coinRankingData: initCoinRankingData, fiatCurrencyCode } = route.params
86+
8687
const [coinRankingData, setCoinRankingData] = React.useState<CoinRankingData | undefined>(initCoinRankingData)
8788
const { currencyCode, currencyName } = coinRankingData ?? {}
8889
const currencyCodeUppercase = currencyCode?.toUpperCase() ?? ''
@@ -108,7 +109,7 @@ const CoinRankingDetailsSceneComponent = (props: Props) => {
108109
if (assetId == null) {
109110
throw new Error('No currencyCode or coinRankingData provided')
110111
}
111-
const response = await fetchRates(`v2/coinrankAsset/${assetId}?fiatCode=${supportedFiat}`)
112+
const response = await fetchRates(`v2/coinrankAsset/${assetId}?fiatCode=iso:${supportedFiat}`)
112113
if (!response.ok) {
113114
const text = await response.text()
114115
throw new Error(`Unable to fetch coin ranking data. ${text}`)

src/components/scenes/TransactionListScene.tsx

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { gt, mul } from 'biggystring'
12
import { EdgeCurrencyWallet, EdgeTokenId, EdgeTokenMap, EdgeTransaction } from 'edge-core-js'
23
import * as React from 'react'
34
import { ListRenderItemInfo, Platform, RefreshControl, View } from 'react-native'
@@ -12,24 +13,26 @@ import { useHandler } from '../../hooks/useHandler'
1213
import { useIconColor } from '../../hooks/useIconColor'
1314
import { useTransactionList } from '../../hooks/useTransactionList'
1415
import { useWatch } from '../../hooks/useWatch'
16+
import { formatNumber } from '../../locales/intl'
1517
import { lstrings } from '../../locales/strings'
1618
import { getExchangeDenomByCurrencyCode } from '../../selectors/DenominationSelectors'
1719
import { FooterRender } from '../../state/SceneFooterState'
1820
import { useSceneScrollHandler } from '../../state/SceneScrollState'
1921
import { useDispatch, useSelector } from '../../types/reactRedux'
2022
import { NavigationBase, WalletsTabSceneProps } from '../../types/routerTypes'
2123
import { 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'
2326
import { InfoCardCarousel } from '../cards/InfoCardCarousel'
2427
import { SwipeChart } from '../charts/SwipeChart'
2528
import { AccentColors } from '../common/DotsBackground'
2629
import { EdgeAnim, fadeInDown10, MAX_LIST_ITEMS_ANIM } from '../common/EdgeAnim'
27-
import { EdgeTouchableOpacity } from '../common/EdgeTouchableOpacity'
2830
import { SceneWrapper } from '../common/SceneWrapper'
31+
import { SectionHeader as SectionHeaderUi4 } from '../common/SectionHeader'
2932
import { withWallet } from '../hoc/withWallet'
3033
import { cacheStyles, useTheme } from '../services/ThemeContext'
3134
import { BuyCrypto } from '../themed/BuyCrypto'
32-
import { EdgeText } from '../themed/EdgeText'
35+
import { EdgeText, Paragraph } from '../themed/EdgeText'
3336
import { ExplorerCard } from '../themed/ExplorerCard'
3437
import { SearchFooter } from '../themed/SearchFooter'
3538
import { 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(() => {

src/locales/en_US.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ const strings = {
225225
transaction_list_no_tx_support_yet: 'Transaction history is not yet supported',
226226
transaction_list_search: 'Search Transactions',
227227
transaction_list_search_no_result: 'Search returned no results',
228+
transaction_list_recent_transactions: 'Recent Transactions',
228229
fragment_wallets_balance_text: 'Total Balance',
229230
fragment_wallets_delete_wallet: 'Archive Wallet',
230231
fragment_wallets_delete_token: 'Disable Token',
@@ -1532,6 +1533,7 @@ const strings = {
15321533
coin_rank_week: '7D',
15331534
coin_rank_month: '30D',
15341535
coin_rank_year: '1Y',
1536+
coin_rank_see_more: 'See More',
15351537

15361538
// #endregion CoinRanking
15371539

src/util/network.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { config } from '../theme/appConfig'
88
import { asyncWaterfall, getOsVersion, shuffleArray } from './utils'
99
const INFO_SERVERS = ['https://info1.edge.app', 'https://info2.edge.app']
1010
// const RATES_SERVERS = ['https://rates1.edge.app', 'https://rates2.edge.app']
11-
const RATES_SERVERS = ['http://localhost:8008']
11+
const RATES_SERVERS = ['http://localhost:8087']
1212

1313
const INFO_FETCH_INTERVAL = 5 * 60 * 1000 // 5 minutes
1414

0 commit comments

Comments
 (0)