-
Notifications
You must be signed in to change notification settings - Fork 589
/
TokenExpandedState.js
77 lines (73 loc) Β· 1.72 KB
/
TokenExpandedState.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { get } from 'lodash';
import PropTypes from 'prop-types';
import React from 'react';
import { InteractionManager } from 'react-native';
import {
compose,
onlyUpdateForKeys,
withHandlers,
withProps,
} from 'recompact';
import { withAccountData, withAccountSettings } from '../../hoc';
import { ethereumUtils } from '../../utils';
import { AssetPanel, AssetPanelAction, AssetPanelHeader } from './asset-panel';
import FloatingPanels from './FloatingPanels';
const TokenExpandedState = ({
onPressSend,
price,
subtitle,
title,
}) => (
<FloatingPanels
width={100}
>
<AssetPanel>
<AssetPanelHeader
price={price}
subtitle={subtitle}
title={title}
/>
<AssetPanelAction
icon="send"
label="Send to..."
onPress={onPressSend}
/>
</AssetPanel>
</FloatingPanels>
);
TokenExpandedState.propTypes = {
onPressSend: PropTypes.func,
price: PropTypes.string,
subtitle: PropTypes.string,
title: PropTypes.string,
};
export default compose(
withAccountData,
withAccountSettings,
withProps(({
asset: {
address,
name,
symbol,
...asset
},
assets,
nativeCurrencySymbol,
}) => {
const selectedAsset = ethereumUtils.getAsset(assets, address);
return {
price: get(selectedAsset, 'native.price.display', null),
subtitle: get(selectedAsset, 'balance.display', symbol),
title: name,
};
}),
withHandlers({
onPressSend: ({ navigation, asset }) => () => {
navigation.goBack();
InteractionManager.runAfterInteractions(() => {
navigation.navigate('SendSheet', { asset });
});
},
}),
onlyUpdateForKeys(['price', 'subtitle']),
)(TokenExpandedState);