-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoalModal.js
More file actions
52 lines (47 loc) · 1.26 KB
/
GoalModal.js
File metadata and controls
52 lines (47 loc) · 1.26 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
import React, { useState } from "react";
import { View, Text, TextInput, Button, Modal, StyleSheet } from "react-native";
const GoalModal = ({ visible, onClose, onConfirm }) => {
const [inputValue, setInputValue] = useState("");
const handleConfirm = () => {
if (inputValue.trim() !== "") {
onConfirm(inputValue);
setInputValue("");
}
};
return (
<Modal visible={visible} animationType="slide">
<View style={styles.modalContainer}>
<TextInput
style={styles.input}
placeholder="Ajouter un nouvel objectif"
onChangeText={(text) => setInputValue(text)}
value={inputValue}
/>
<View style={styles.buttonContainer}>
<Button title="Confirmer" onPress={handleConfirm} />
<Button title="Annuler" onPress={onClose} color="red" />
</View>
</View>
</Modal>
);
};
const styles = StyleSheet.create({
modalContainer: {
flex: 1,
justifyContent: "center",
alignItems: "center",
},
input: {
width: "80%",
marginBottom: 10,
borderBottomWidth: 1,
borderColor: "#ccc",
padding: 8,
},
buttonContainer: {
flexDirection: "row",
justifyContent: "space-around",
width: "60%",
},
});
export default GoalModal;