-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
66 lines (61 loc) · 1.49 KB
/
App.js
File metadata and controls
66 lines (61 loc) · 1.49 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
54
55
56
57
58
59
60
61
62
63
64
65
66
import { useState } from "react";
import { Button, StyleSheet, Text, TextInput, View } from "react-native";
export default function App() {
const [enteredGoalText, setEnteredGoalText] = useState("");
const [courseGoals, setCourseGoals] = useState([]);
function goalInputHandler(enteredText) {
setEnteredGoalText(enteredText);
}
function addGoalHandler() {
setCourseGoals((currentCourseGoals) => [
...currentCourseGoals,
enteredGoalText,
]);
}
return (
<View style={styles.rootContainer}>
<View style={styles.inputContainer}>
<TextInput
style={styles.textInput}
placeholder="Enter Goal Here..."
onChangeText={goalInputHandler}
/>
<Button title="Add Goal" onPress={addGoalHandler} />
</View>
<View style={styles.goalsContainer}>
{courseGoals.map((goal) => (
<Text key={goal}>{goal}</Text>
))}
</View>
</View>
);
}
const styles = StyleSheet.create({
rootContainer: {
flex: 1,
paddingTop: 50,
paddingHorizontal: 16,
},
inputContainer: {
flex: 1,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
marginBottom: 20,
borderBottomWidth: 1,
borderBottomColor: "#cccccc",
},
textInput: {
// height: 40,
marginRight: 20,
paddingLeft: 10,
paddingTop: 6,
paddingBottom: 6,
width: "70%",
borderColor: "#cccccc",
borderWidth: 1,
},
goalsContainer: {
flex: 4,
},
});