-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModalPicker.tsx
170 lines (166 loc) · 4.35 KB
/
ModalPicker.tsx
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import React, {FC, useState} from 'react';
import {
View,
Text,
Pressable,
Modal,
StyleSheet,
TextInput,
} from 'react-native';
import {Picker} from '@react-native-picker/picker';
import {storeData} from './App';
const ModalPicker: FC<ModalPickerProps> = ({
isSet,
modalVisible,
setIsSet,
setModalVisible,
}) => {
const [selectedValue, setSelectedValue] = useState('SafeGasPrice');
const [smallerNumber, setSmallerNumber] = useState('');
// const [biggerNumber, setBiggerNumber] = useState("");
return (
<Modal
animationType="fade"
transparent={true}
visible={modalVisible}
onRequestClose={() => setModalVisible()}>
<View style={styles.centeredView}>
<View style={styles.modalView}>
<Text style={{color: '#fff', fontWeight: 'bold', fontSize: 17}}>
Select Gas Speed
</Text>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
}}>
<View style={styles.pickerView}>
<Picker
selectedValue={selectedValue}
onValueChange={(itemValue: string) => {
setSelectedValue(itemValue);
}}
style={styles.picker}
mode="dropdown">
<Picker.Item label="Slow" value="SafeGasPrice" />
<Picker.Item label="Normal" value="ProposeGasPrice" />
<Picker.Item label="Fast" value="FastGasPrice" />
{/* <Picker.Item label="Instant" value="fastest" /> */}
</Picker>
</View>
<Text style={styles.buttonText}>{'<'}</Text>
<TextInput
style={styles.textInput}
keyboardType="numeric"
value={smallerNumber}
onChangeText={value => {
setSmallerNumber(value);
}}
placeholder="0"
placeholderTextColor="#fff"
/>
</View>
<View style={styles.buttonsView}>
<Pressable style={styles.button} onPress={() => setModalVisible()}>
<Text style={styles.buttonText}>Cancel</Text>
</Pressable>
<Pressable
style={styles.button}
onPress={async () => {
setModalVisible();
await storeData('push_notifications', 'true');
await storeData('selected', selectedValue);
await storeData('limit', `${smallerNumber}`);
setIsSet();
}}>
<Text style={styles.buttonText}>Set</Text>
</Pressable>
</View>
{isSet ? (
<Pressable
style={styles.clearButton}
onPress={async () => {
setSmallerNumber('');
await storeData('isSet', 'false');
await storeData('push_notifications', 'false');
setModalVisible();
}}>
<Text style={styles.buttonText}>Clear</Text>
</Pressable>
) : null}
</View>
</View>
</Modal>
);
};
export default ModalPicker;
const styles = StyleSheet.create({
centeredView: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
modalView: {
margin: 20,
backgroundColor: '#383E4D',
borderRadius: 20,
padding: 35,
alignItems: 'center',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,
},
picker: {
height: 40,
width: 120,
color: '#fff',
},
button: {
borderRadius: 10,
padding: 15,
elevation: 2,
backgroundColor: '#4e75b5',
margin: 10,
},
buttonsView: {
flexDirection: 'row',
alignItems: 'center',
},
buttonText: {
color: '#fff',
},
textInput: {
height: 45,
margin: 10,
width: 50,
borderWidth: 1,
padding: 10,
borderRadius: 10,
borderColor: '#fff',
color: '#fff',
},
pickerView: {
borderWidth: 1,
borderRadius: 20,
margin: 10,
borderColor: '#fff',
},
clearButton: {
borderRadius: 10,
padding: 15,
elevation: 2,
backgroundColor: '#bd2424',
margin: 10,
},
});
interface ModalPickerProps {
isSet: boolean;
modalVisible: boolean;
setIsSet: () => void;
setModalVisible: () => void;
}