-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
92 lines (85 loc) · 2.06 KB
/
App.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
import { StatusBar } from "expo-status-bar";
import React, { useState } from "react";
import {
StyleSheet,
Text,
View,
Image,
Alert,
TextInput,
TouchableOpacity,
ScrollView,
FlatList,
} from "react-native";
import GoalItem from "./components/GoalItem.js";
import GoalInput from "./components/GoalInput.js";
export default function App() {
let x = 1;
const [enteredGoals, setEnteredGoals] = useState([]);
const Separator = () => <View style={styles.separator} />;
const handlePress = () => console.log("text pressed");
console.log("test in progress sir");
const addGoalHandler = (goalTitle) => {
setEnteredGoals((enteredGoals) => [
...enteredGoals,
{ key: Math.random().toString(), value: goalTitle },
]);
/*Alert.alert("New goal:" + enteredGoal);*/
};
return (
<View style={styles.container}>
<View style={styles.banner}>
<Text style={styles.bannerText}>Discipline</Text>
</View>
<Image
source={require("./assets/capturing-the-human-heart-TrhLCn1abMU-unsplash.jpg")}
style={styles.logo}
/>
<Separator />
<GoalInput onAddGoal={addGoalHandler} />
<Separator />
<FlatList
keyExtractor={(item, index) => item.key}
style={styles.scrollingArea}
data={enteredGoals}
renderItem={(itemData) => <GoalItem title={itemData.item.value} />}
></FlatList>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "white",
alignItems: "center",
justifyContent: "center",
padding: 0,
},
logo: {
width: "100%",
height: 200,
},
separator: {
marginVertical: 20,
borderBottomColor: "#737373",
borderBottomWidth: StyleSheet.hairlineWidth,
},
banner: {
width: "100%",
color: "white",
height: 100,
backgroundColor: "#eb3d3d",
flex: 1,
alignItems: "flex-start",
justifyContent: "center",
paddingLeft: 20,
paddingTop: 20,
},
bannerText: {
color: "white",
fontSize: 30,
},
scrollingArea: {
height: 100,
},
});