forked from BlueWallet/BlueWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputAccessoryAllFunds.js
126 lines (116 loc) · 3.14 KB
/
InputAccessoryAllFunds.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import React from 'react';
import PropTypes from 'prop-types';
import { Text } from 'react-native-elements';
import { InputAccessoryView, StyleSheet, Keyboard, Platform, View } from 'react-native';
import { useTheme } from '@react-navigation/native';
import loc from '../loc';
import { BitcoinUnit } from '../models/bitcoinUnits';
import { BlueButtonLink } from '../BlueComponents';
const InputAccessoryAllFunds = ({ balance, canUseAll, onUseAllPressed }) => {
const { colors } = useTheme();
const stylesHook = StyleSheet.create({
root: {
backgroundColor: colors.inputBackgroundColor,
},
totalLabel: {
color: colors.alternativeTextColor,
},
totalCanNot: {
color: colors.alternativeTextColor,
},
});
const inputView = (
<View style={[styles.root, stylesHook.root]}>
<View style={styles.left}>
<Text style={[styles.totalLabel, stylesHook.totalLabel]}>{loc.send.input_total}</Text>
{canUseAll ? (
<BlueButtonLink onPress={onUseAllPressed} style={styles.totalCan} title={`${balance} ${BitcoinUnit.BTC}`} />
) : (
<Text style={[styles.totalCanNot, stylesHook.totalCanNot]}>
{balance} {BitcoinUnit.BTC}
</Text>
)}
</View>
<View style={styles.right}>
<BlueButtonLink style={styles.done} title={loc.send.input_done} onPress={Keyboard.dismiss} />
</View>
</View>
);
if (Platform.OS === 'ios') {
return <InputAccessoryView nativeID={InputAccessoryAllFunds.InputAccessoryViewID}>{inputView}</InputAccessoryView>;
}
// androidPlaceholder View is needed to force shrink screen (KeyboardAvoidingView) where this component is used
return (
<>
<View style={styles.androidPlaceholder} />
<View style={styles.androidAbsolute}>{inputView}</View>
</>
);
};
InputAccessoryAllFunds.InputAccessoryViewID = 'useMaxInputAccessoryViewID';
InputAccessoryAllFunds.propTypes = {
balance: PropTypes.string.isRequired,
canUseAll: PropTypes.bool.isRequired,
onUseAllPressed: PropTypes.func.isRequired,
};
const styles = StyleSheet.create({
root: {
flex: 1,
flexDirection: 'row',
maxHeight: 44,
justifyContent: 'space-between',
alignItems: 'center',
},
left: {
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'flex-start',
},
totalLabel: {
fontSize: 16,
marginLeft: 8,
marginRight: 0,
paddingRight: 0,
paddingLeft: 0,
paddingTop: 12,
paddingBottom: 12,
},
totalCan: {
marginLeft: 8,
paddingRight: 0,
paddingLeft: 0,
paddingTop: 12,
paddingBottom: 12,
},
totalCanNot: {
fontSize: 16,
marginLeft: 8,
marginRight: 0,
paddingRight: 0,
paddingLeft: 0,
paddingTop: 12,
paddingBottom: 12,
},
right: {
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'flex-end',
},
done: {
paddingRight: 8,
paddingLeft: 0,
paddingTop: 12,
paddingBottom: 12,
},
androidPlaceholder: {
height: 44,
},
androidAbsolute: {
height: 44,
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
},
});
export default InputAccessoryAllFunds;