-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddCheckboxModal.js
More file actions
53 lines (47 loc) · 1.34 KB
/
AddCheckboxModal.js
File metadata and controls
53 lines (47 loc) · 1.34 KB
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
import React, { useState } from 'react';
import { View, Modal, TextInput, StyleSheet, Button } from 'react-native';
import IconPicker from "react-native-icon-picker";
import Spacer from './Spacer';
const AddCheckboxModal = ({ navigation, route }) => {
const [label, setLabel] = useState('');
const [icon, setIcon] = useState('');
const handleAdd = () => {
if (label && icon) {
route.params.onAdd({ label, icon });
setLabel('');
setIcon('');
navigation.goBack();
}
};
const onSelect = (icon) => {
setIcon(icon.icon);
};
return (
<Modal animationType="fade" visible={true} onRequestClose={() => navigation.goBack()}>
<View style={styles.modalContent}>
<TextInput
placeholder="Task name..."
value={label}
onChangeText={text => setLabel(text)}
/>
<Spacer height={20} />
<IconPicker
//... (your IconPicker props)
onSelect={onSelect}
/>
<Spacer height={100} />
<Button title="Add" onPress={handleAdd} />
<Spacer height={10} />
<Button title="Cancel" onPress={() => navigation.goBack()} />
</View>
</Modal>
);
};
const styles = StyleSheet.create({
modalContent: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
export default AddCheckboxModal;