-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
118 lines (111 loc) · 3.25 KB
/
Copy pathApp.js
File metadata and controls
118 lines (111 loc) · 3.25 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
import React, { useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Task from './components/Task';
import { KeyboardAvoidingView } from 'react-native';
import { TextInput } from 'react-native';
import { Platform } from 'react-native';
import { TouchableOpacity } from 'react-native';
import { Keyboard } from 'react-native';
import { ScrollView } from 'react-native';
export default function App() {
const [task, setTask] = useState();
const [taskItems, setTaskItems] = useState([]);
const handleAddTask = () => {
Keyboard.dismiss();
setTaskItems([...taskItems, task]);
setTask(null);
}
const completeTask = (index) => {
let itemsCopy = [...taskItems];
itemsCopy.splice(index, 1);
setTaskItems(itemsCopy);
}
return (
<View style={styles.container}>
<View style={styles.tasksWrapper}>
<Text style={styles.sectionTitle}>Tasks</Text>
<ScrollView contentContainerStyle={{ flexGrow: 0.75 }}>
<View style={styles.items}>
{
taskItems.map((item, index) => {
return (
<TouchableOpacity key={index} onPress={() => completeTask(index)}>
<Task text={item} completeTask={completeTask} index={index} />
</TouchableOpacity>
)
})
}
</View>
</ScrollView>
</View>
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? "paddinng" : "height"}
style={[styles.writeTaskWrapper, { zIndex: 1000, elevation: 5 }]}
>
<TextInput style={styles.input} placeholder={'Write a task'} value={task} onChangeText={text => setTask(text)} />
<TouchableOpacity onPress={() => handleAddTask()}>
<View style={styles.addWrapper}>
<Text style={styles.addText}>+</Text>
</View>
</TouchableOpacity>
</KeyboardAvoidingView>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#E8EAED',
paddingBottom: 150,
},
tasksWrapper: {
paddingTop: 80,
paddingHorizontal: 20,
},
sectionTitle: {
fontSize: 24,
fontWeight: 'bold',
color: '#000000',
marginBottom: 20,
},
items: {
justifyContent: 'space-between',
},
input: {
paddingVertical: 15,
paddingHorizontal: 30,
width: 290,
height: 60,
backgroundColor: 'white',
borderRadius: 30,
borderWidth: 0,
borderColor: 'grey',
elevation: 5, // Adding elevation to input bar
},
addWrapper: {
width: 60,
height: 60,
backgroundColor: 'white',
borderRadius: 60,
borderWidth: 0,
justifyContent: 'center',
alignItems: 'center',
borderColor: 'grey',
elevation: 5, // Adding elevation to add button
},
addText: {
},
writeTaskWrapper: {
position: 'absolute',
flexDirection: 'row',
bottom: 30,
width: '100%',
justifyContent: 'space-around',
alignItems: 'center',
elevation: 10, // Increased elevation to create a more noticeable shadow
shadowColor: '#000', // Black shadow
shadowOffset: { width: 0, height: 2 }, // Horizontal and vertical offset
shadowOpacity: 0.5, // Opacity of the shadow
shadowRadius: 3.84, // Softens the shadow
},
});