mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
coin card calculations tuning
This commit is contained in:
parent
4cf5664d09
commit
e7cdf9c8a4
@ -44,7 +44,7 @@ export const CoinCard = ({
|
||||
</View>
|
||||
<Text
|
||||
style={styles.textCurValue}>
|
||||
<Text style={{fontWeight:'500'}}>{`${ownedTokens} ${symbol}`}</Text>
|
||||
<Text style={{fontWeight:'500'}}>{`${ownedTokens.toFixed(3)} ${symbol}`}</Text>
|
||||
{`/${(ownedTokens * currentValue).toFixed(2)}${currencySymbol}`}
|
||||
</Text>
|
||||
</View>
|
||||
|
@ -90,14 +90,17 @@ const WalletScreen = ({navigation}) => {
|
||||
|
||||
const coinData = coinsData[item.id] || {};
|
||||
|
||||
const _tokenMarketData = priceHistories[item.id] ? priceHistories[item.id].data : [];
|
||||
const _tokenMarketData:number[] = priceHistories[item.id] ? priceHistories[item.id].data : [];
|
||||
const _currentValue = item.id == 'ecency' ? 1/150 : (coinData.currentPrice || 0);
|
||||
const _balance = item.id === 'ececny' ? 3 : (coinData.balance + coinData.savings);
|
||||
const _changePercent =
|
||||
_tokenMarketData.length > 0 ?
|
||||
((_tokenMarketData[_tokenMarketData.length - 1] - _tokenMarketData[0])/(_tokenMarketData[_tokenMarketData.length - 1]))*100
|
||||
:
|
||||
0;
|
||||
|
||||
//calculate percentage change
|
||||
//TODO: verify or find a way to get exact percent change. current change value slightly differs from coingecko wep app values
|
||||
const _pastPrice = _tokenMarketData.length > 0 && _tokenMarketData[0];
|
||||
const _latestPrice = _tokenMarketData.length > 0 && _tokenMarketData.lastItem;
|
||||
const _changePercent = _pastPrice && _latestPrice
|
||||
? ((_latestPrice - _pastPrice)/(_latestPrice)) * 100 : 0;
|
||||
|
||||
return (
|
||||
<CoinCard
|
||||
chartData={_tokenMarketData || []}
|
||||
|
Loading…
Reference in New Issue
Block a user