forked from quanganh2810/Orbital22new
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTodoList.js
More file actions
181 lines (175 loc) · 4.88 KB
/
Copy pathTodoList.js
File metadata and controls
181 lines (175 loc) · 4.88 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import { StatusBar } from 'expo-status-bar';
import { KeyboardAvoidingView, Platform, StyleSheet, Text, View, TextInput, TouchableOpacity, Keyboard, ScrollView, ImageBackground } from 'react-native';
import Task from './components/task';
import React, { useState } from 'react';
export default function Todolist() {
const [task, setTask] = useState();
const [taskItems, setTaskItems] = useState([]);
const [Duration, setDuration] = useState();
const [taskDuration, setTaskDuration] = useState([])
const [Deadline, setDeadline] = useState();
const [taskDeadline, setTaskDeadline] = useState([]);
const handleAddTask = () => {
Keyboard.dismiss();
setTaskItems([...taskItems, task]);
setTaskDuration([...taskDuration, Duration]);
setTaskDeadline([...taskDeadline, Deadline]);
setTask(null);
setDuration(null);
setDeadline(null);
}
const completeTask = (index) => {
let itemsCopy = [...taskItems];
itemsCopy.splice(index, 1);
let DurationCopy = [...taskDuration];
DurationCopy.splice(index, 1);
let DeadlineCopy = [...taskDeadline];
DeadlineCopy.splice(index, 1);
setTaskItems(itemsCopy);
setTaskDuration(DurationCopy);
setTaskDeadline(DeadlineCopy);
}
return (
<ImageBackground style={styles.container} source={require('./assets/Background.png')}>
<View style={styles.bars}>
</View>
<View style={styles.tasksWrapper}>
<Text style={styles.sectionTitle}>AUTODO</Text>
<Text style={styles.sectionTitle}> </Text>
<TouchableOpacity>
<View style={styles.tabWrapper}>
<Text style={styles.tab}>What should I do today ?</Text>
</View>
</TouchableOpacity>
<TouchableOpacity>
<View style={styles.sortWrapper}>
<Text style={styles.sort}> List: </Text>
</View>
</TouchableOpacity>
<View style={styles.items}>
<ScrollView>
{
taskItems.map((item, index) => {
return (
<TouchableOpacity key={index} onPress = {() => completeTask(index)}>
<Task text={item}/>
</TouchableOpacity>
)
})
}
</ScrollView>
</View>
</View>
<KeyboardAvoidingView
behavior={Platform.OS === "ios" ? "padding" : "height"}
style={styles.writeTaskWrapper}>
<ScrollView style={styles.ScrollView} horizontal={true}>
<TextInput style={styles.inputtask} placeholder={'Task'} value={task} onChangeText={text => setTask(text)} />
<TextInput style={styles.inputDuration} placeholder={'Duration (in hours)'} onChangeText={howlong => setDuration(howlong)}/>
<TextInput style={styles.inputDeadline} placeholder={'Deadline (dd/mm/yy)'} onChangeText={bywhen => setDeadline(bywhen)}/>
<TouchableOpacity onPress={() => handleAddTask()}>
<View style={styles.addWrapper}>
<Text style={styles.addText}> + </Text>
</View>
</TouchableOpacity>
</ScrollView>
</KeyboardAvoidingView>
</ImageBackground>
);
}
const styles = StyleSheet.create({
bars: {
},
container: {
flex: 1,
height: 800,
width: 400,
},
tasksWrapper: {
paddingTop: 80,
paddingHorizontal: 10,
},
sectionTitle: {
fontSize: 20,
fontWeight: 'bold',
color: 'white'
},
tab: {
fontSize: 15,
fontWeight: 'bold',
color: '#000000',
fontSize: 20,
},
items: {
},
writeTaskWrapper: {
position: 'absolute',
bottom: 20,
width: '90%',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingHorizontal: 0,
},
inputtask: {
paddingVertical: 15,
paddingHorizontal: 15,
backgroundColor: '#FFF',
borderRadius: 60,
borderColor: '#C0C0C0',
borderWidth: 1,
width: 250,
},
inputDuration: {
paddingVertical: 15,
paddingHorizontal: 15,
backgroundColor: '#FFF',
borderRadius: 60,
borderColor: '#C0C0C0',
borderWidth: 1,
width: 250,
},
inputDeadline: {
paddingVertical: 15,
paddingHorizontal: 15,
backgroundColor: '#FFF',
borderRadius: 60,
borderColor: '#C0C0C0',
borderWidth: 1,
width: 250,
},
addWrapper: {
width: 60,
height: 60,
backgroundColor: '#FFF',
borderRadius: 16,
justifyContent: 'center',
alignItems: 'center',
},
tabWrapper:{
position: 'absolute',
top: 510,
width: 260,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingHorizontal: 15,
backgroundColor: '#FFF',
borderRadius: 16,
},
sortWrapper:{
position: 'absolute',
top: -30,
width: 90,
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
paddingHorizontal: 15,
backgroundColor: '#FFF',
borderRadius: 16,
},
sort:{
fontSize: 15,
fontWeight: 'bold',
}
});