integrated coin actions

This commit is contained in:
Nouman Tahir 2022-02-22 14:29:43 +05:00
parent 02d4245b22
commit 195280d764
6 changed files with 111 additions and 13 deletions

View File

@ -20,7 +20,9 @@ export interface CoinData {
unclaimedBalance:string, unclaimedBalance:string,
estimateValue?:number; estimateValue?:number;
vsCurrency:string; vsCurrency:string;
extraDataPairs?:DataPair[] actions:string[];
extraDataPairs?:DataPair[];
} }
export interface PriceHistory { export interface PriceHistory {

View File

@ -96,5 +96,27 @@ export default EStyleSheet.create({
paddingBottom:56, paddingBottom:56,
marginHorizontal:16 marginHorizontal:16
} as ViewStyle , } as ViewStyle ,
//COIN ACTIONS STYLES
actionBtnContainer:{
flexGrow:1
} as ViewStyle,
actionsContainer:{
flexDirection:'row',
flexWrap:'wrap'
} as ViewStyle,
actionContainer:{
paddingHorizontal:16,
marginVertical:8,
marginHorizontal:4,
backgroundColor:'$primaryLightBackground',
height: 40,
borderRadius:20,
justifyContent:'center',
alignItems:'center',
} as ViewStyle,
actionText:{
color: '$primaryBlack'
} as TextStyle
}); });

View File

@ -0,0 +1,43 @@
import React, { Fragment } from 'react'
import { useIntl } from 'react-intl'
import { View, Text, Alert } from 'react-native'
import { TouchableOpacity } from 'react-native-gesture-handler'
import styles from './children.styles'
interface CoinActionsProps {
coinId:string;
actions:string[];
}
const CoinActions = ({coinId, actions}:CoinActionsProps) => {
const intl = useIntl();
const _navigate = (action:string) => {
Alert.alert("Action Press", action)
}
const _renderItem = (item) => {
const _onPress = () => {
_navigate(item)
}
return (
<TouchableOpacity style={styles.actionContainer} containerStyle={styles.actionBtnContainer} onPress={_onPress}>
<Fragment>
<Text style={styles.actionText}>
{intl.formatMessage({id:`wallet.${item}`})}
</Text>
</Fragment>
</TouchableOpacity>
)
}
return (
<View style={styles.actionsContainer}>
{actions.map(_renderItem)}
</View>
)
}
export default CoinActions

View File

@ -3,18 +3,28 @@ import { View } from 'react-native'
import { CoinBasics, CoinChart } from '.' import { CoinBasics, CoinChart } from '.'
import { FormattedCurrency } from '../../../components' import { FormattedCurrency } from '../../../components'
import { COIN_IDS } from '../../../constants/defaultCoins' import { COIN_IDS } from '../../../constants/defaultCoins'
import { DataPair } from '../../../redux/reducers/walletReducer' import { CoinData, DataPair } from '../../../redux/reducers/walletReducer'
import CoinActions from './coinActions'
export interface CoinSummaryProps { export interface CoinSummaryProps {
balance:number;
estimateValue:number;
savings:number;
coinSymbol:string;
id:string; id:string;
extraData?:DataPair[] coinSymbol:string;
coinData:CoinData;
} }
export const CoinSummary = ({balance, estimateValue, savings, coinSymbol, id, extraData}:CoinSummaryProps) => { export const CoinSummary = ({
coinSymbol,
id,
coinData,
}:CoinSummaryProps) => {
const {
balance,
estimateValue,
savings,
extraDataPairs,
actions
} = coinData
const valuePairs = [ const valuePairs = [
{ {
label:'Balance', label:'Balance',
@ -38,7 +48,8 @@ export const CoinSummary = ({balance, estimateValue, savings, coinSymbol, id, ex
return ( return (
<View> <View>
<CoinBasics valuePairs={valuePairs} extraData={extraData} coinSymbol={coinSymbol} /> <CoinBasics valuePairs={valuePairs} extraData={extraDataPairs} coinSymbol={coinSymbol} />
<CoinActions actions={actions} />
{ {
id !== COIN_IDS.ECENCY && id !== COIN_IDS.HP && <CoinChart coinId={id} /> id !== COIN_IDS.ECENCY && id !== COIN_IDS.HP && <CoinChart coinId={id} />
} }

View File

@ -56,12 +56,9 @@ const CoinDetailsScreen = ({navigation}:CoinDetailsScreenProps) => {
const _renderHeaderComponent = ( const _renderHeaderComponent = (
<> <>
<CoinSummary {...{ <CoinSummary {...{
balance:coinData.balance,
estimateValue:coinData.estimateValue,
savings:coinData.savings,
id, id,
coinSymbol:symbol, coinSymbol:symbol,
extraData:coinData.extraDataPairs coinData,
}} /> }} />
<Text style={styles.textActivities}>Activities</Text> <Text style={styles.textActivities}>Activities</Text>
</> </>

View File

@ -34,6 +34,25 @@ export const transferTypes = [
'fill_vesting_withdraw', 'fill_vesting_withdraw',
]; ];
const ECENCY_ACTIONS = [
'dropdown_transfer', 'dropdown_promote', 'dropdown_boost'
];
const HIVE_ACTIONS = [
'purchase_estm',
'transfer_token',
'transfer_to_savings',
'transfer_to_vesting',
'withdraw_hive'
];
const HBD_ACTIONS = [
'purchase_estm',
'transfer_token',
'transfer_to_savings',
'convert',
'withdraw_hbd'
];
const HIVE_POWER_ACTIONS = ['delegate', 'power_down'];
export const groomingTransactionData = (transaction, hivePerMVests) => { export const groomingTransactionData = (transaction, hivePerMVests) => {
if (!transaction || !hivePerMVests) { if (!transaction || !hivePerMVests) {
@ -332,6 +351,7 @@ export const fetchCoinsData = async (
vsCurrency:vsCurrency, vsCurrency:vsCurrency,
currentPrice:ppEstm, currentPrice:ppEstm,
unclaimedBalance: unclaimedBalance, unclaimedBalance: unclaimedBalance,
actions:ECENCY_ACTIONS,
} }
break; break;
} }
@ -346,6 +366,7 @@ export const fetchCoinsData = async (
vsCurrency:vsCurrency, vsCurrency:vsCurrency,
currentPrice:ppHive, currentPrice:ppHive,
unclaimedBalance:'', unclaimedBalance:'',
actions:HIVE_ACTIONS,
} }
break; break;
} }
@ -361,6 +382,7 @@ export const fetchCoinsData = async (
vsCurrency:vsCurrency, vsCurrency:vsCurrency,
currentPrice:ppHbd, currentPrice:ppHbd,
unclaimedBalance:'', unclaimedBalance:'',
actions:HBD_ACTIONS,
} }
break; break;
} }
@ -396,6 +418,7 @@ export const fetchCoinsData = async (
unclaimedBalance, unclaimedBalance,
vsCurrency:vsCurrency, vsCurrency:vsCurrency,
currentPrice:ppHive, currentPrice:ppHive,
actions:HIVE_POWER_ACTIONS,
extraDataPairs:[ extraDataPairs:[
{ {
label:'Delegated Hive Power', label:'Delegated Hive Power',