-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
106 lines (103 loc) · 2.3 KB
/
App.js
File metadata and controls
106 lines (103 loc) · 2.3 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
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
import React, { useState } from "react";
import {
StyleSheet,
Text,
View,
KeyboardAvoidingView,
Platform,
TextInput,
TouchableOpacity,
Keyboard,
} from "react-native";
import Tasks from "./app/screens/Tasks";
export default function App() {
const [task, setTask] = useState();
const [item, setItem] = useState([]);
const handleTask = () => {
Keyboard.dismiss();
setItem([...item, task]);
setTask(null);
};
const completes = (index) => {
let copy = [...item];
copy.splice(index, 1);
setItem(copy);
};
return (
<View style={styles.container}>
<View style={styles.task}>
<Text style={styles.header}>Today's Tasks</Text>
<View style={styles.items}>
{item.map((it, index) => {
return (
<TouchableOpacity key={index} onPress={() => completes(index)}>
<Tasks text={it} />
</TouchableOpacity>
);
})}
</View>
</View>
<KeyboardAvoidingView
behavior={Platform.OS === "ios" ? "padding" : "height"}
style={styles.write}
>
<TextInput
style={styles.input}
placeholder={"write a task"}
value={task}
onChangeText={(text) => setTask(text)}
/>
<TouchableOpacity onPress={() => handleTask()}>
<View style={styles.add}>
<Text style={styles.addtext}>+</Text>
</View>
</TouchableOpacity>
</KeyboardAvoidingView>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#E8EAED",
},
task: {
paddingTop: 80,
paddingHorizontal: 20,
},
header: {
fontSize: 30,
fontWeight: "bold",
},
items: {
marginTop: 30,
},
write: {
position: "absolute",
bottom: 60,
width: "100%",
flexDirection: "row",
justifyContent: "space-around",
alignItems: "center",
},
input: {
paddingVertical: 15,
width: 250,
paddingHorizontal: 15,
backgroundColor: "#FFF",
borderRadius: 60,
borderColor: "#C0C0C0",
borderWidth: 1,
},
add: {
height: 60,
width: 60,
backgroundColor: "#FFF",
borderRadius: 60,
borderColor: "#C0C0C0",
borderWidth: 1,
justifyContent: "center",
alignItems: "center",
},
addtext: {},
});