@sqliteai/todoapp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +3 -0
- package/App.js +32 -0
- package/README.md +52 -0
- package/app.json +39 -0
- package/assets/adaptive-icon.png +0 -0
- package/assets/icon.png +0 -0
- package/assets/splash.png +0 -0
- package/babel.config.js +16 -0
- package/components/AddTaskModal.js +120 -0
- package/components/DropdownMenu.js +67 -0
- package/components/SyncContext.js +119 -0
- package/components/TaskRow.js +103 -0
- package/db/dbConnection.js +3 -0
- package/hooks/useCategories.js +94 -0
- package/hooks/useTasks.js +99 -0
- package/package.json +42 -0
- package/plugins/CloudSyncSetup.js +284 -0
- package/screens/Categories.js +220 -0
- package/screens/Cover.js +54 -0
- package/screens/Home.js +90 -0
- package/to-do-app.sql +3 -0
package/screens/Home.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { View, Text, StyleSheet, FlatList, Alert } from "react-native";
|
|
3
|
+
import { Button } from "react-native-paper";
|
|
4
|
+
import Icon from "react-native-vector-icons/FontAwesome";
|
|
5
|
+
import TaskRow from "../components/TaskRow";
|
|
6
|
+
import AddTaskModal from "../components/AddTaskModal";
|
|
7
|
+
import useTasks from "../hooks/useTasks"
|
|
8
|
+
|
|
9
|
+
export default Home = ({ route }) => {
|
|
10
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
11
|
+
|
|
12
|
+
const tag = route.params?.category;
|
|
13
|
+
|
|
14
|
+
const { taskList, updateTask, addTaskTag, deleteTask } = useTasks(tag)
|
|
15
|
+
|
|
16
|
+
const today = new Date();
|
|
17
|
+
const options = { year: "numeric", month: "long", day: "numeric" };
|
|
18
|
+
const formattedDate = today.toLocaleDateString("en-US", options);
|
|
19
|
+
|
|
20
|
+
const handleDelete = (taskUuid) => {
|
|
21
|
+
Alert.alert(
|
|
22
|
+
"Confirm Delete",
|
|
23
|
+
"Are you sure you want to delete this task?",
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
text: "Cancel",
|
|
27
|
+
style: "cancel",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
text: "Delete",
|
|
31
|
+
onPress: () => deleteTask(taskUuid),
|
|
32
|
+
style: "destructive",
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View style={styles.container}>
|
|
40
|
+
<Text style={styles.date}>{formattedDate}</Text>
|
|
41
|
+
<FlatList
|
|
42
|
+
style={styles.taskList}
|
|
43
|
+
data={taskList}
|
|
44
|
+
keyExtractor={(item, index) => index}
|
|
45
|
+
renderItem={({ item }) => (
|
|
46
|
+
<TaskRow
|
|
47
|
+
task={item}
|
|
48
|
+
updateTask={updateTask}
|
|
49
|
+
handleDelete={handleDelete}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
/>
|
|
53
|
+
<Button
|
|
54
|
+
style={styles.button}
|
|
55
|
+
onPress={() => {
|
|
56
|
+
setModalVisible(true);
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
<Icon name="plus" color={"white"} />
|
|
60
|
+
</Button>
|
|
61
|
+
<AddTaskModal
|
|
62
|
+
modalVisible={modalVisible}
|
|
63
|
+
addTaskTag={addTaskTag}
|
|
64
|
+
setModalVisible={setModalVisible}
|
|
65
|
+
/>
|
|
66
|
+
</View>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const styles = StyleSheet.create({
|
|
71
|
+
container: {
|
|
72
|
+
flex: 1,
|
|
73
|
+
backgroundColor: "white",
|
|
74
|
+
padding: 20,
|
|
75
|
+
},
|
|
76
|
+
date: {
|
|
77
|
+
color: "gray",
|
|
78
|
+
marginTop: 50,
|
|
79
|
+
fontSize: 16,
|
|
80
|
+
},
|
|
81
|
+
button: {
|
|
82
|
+
backgroundColor: "#6BA2EA",
|
|
83
|
+
position: "absolute",
|
|
84
|
+
bottom: 70,
|
|
85
|
+
right: 20,
|
|
86
|
+
},
|
|
87
|
+
taskList: {
|
|
88
|
+
paddingTop: 40,
|
|
89
|
+
},
|
|
90
|
+
});
|
package/to-do-app.sql
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
CREATE TABLE tasks (uuid TEXT NOT NULL PRIMARY KEY, title TEXT, isCompleted INT NOT NULL DEFAULT 0);
|
|
2
|
+
CREATE TABLE tags (uuid TEXT NOT NULL PRIMARY KEY, name TEXT, UNIQUE(name));
|
|
3
|
+
CREATE TABLE tasks_tags (uuid TEXT NOT NULL PRIMARY KEY, task_uuid TEXT, tag_uuid TEXT, FOREIGN KEY (task_uuid) REFERENCES tasks(uuid), FOREIGN KEY (tag_uuid) REFERENCES tags(uuid));
|