@sqliteai/todoapp 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A simple Expo example demonstrating SQLite synchronization with CloudSync. Build cross-platform apps that sync data seamlessly across devices.
4
4
 
5
+ <img src="https://github.com/user-attachments/assets/86db5c25-d8ff-4c31-b157-8dff178e1720" width="40%" height="40%">
6
+
5
7
  ## 🚀 Quick Start
6
8
 
7
9
  ### 1. Clone the template
package/app.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "expo": {
3
3
  "name": "todoapp",
4
4
  "slug": "todoapp",
5
- "version": "1.0.2",
5
+ "version": "1.0.3",
6
6
  "orientation": "portrait",
7
7
  "icon": "./assets/icon.png",
8
8
  "userInterfaceStyle": "light",
@@ -30,6 +30,16 @@ const useCategories = () => {
30
30
  }
31
31
  }
32
32
 
33
+ const removeCategory = async categoryName => {
34
+ try {
35
+ await db.execute('DELETE FROM tags WHERE name = ?', [categoryName])
36
+ db.execute('SELECT cloudsync_network_send_changes();')
37
+ setMoreCategories(prevCategories => prevCategories.filter(cat => cat !== categoryName))
38
+ } catch (error) {
39
+ console.error('Error removing category', error)
40
+ }
41
+ }
42
+
33
43
  const initializeTables = async () => {
34
44
  let extensionPath;
35
45
 
@@ -86,6 +96,7 @@ const useCategories = () => {
86
96
  return {
87
97
  moreCategories,
88
98
  addCategory,
99
+ removeCategory,
89
100
  getCategories
90
101
  }
91
102
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqliteai/todoapp",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "An Expo template for building apps with the SQLite CloudSync extension",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from "react";
2
- import { ScrollView, StyleSheet, View } from "react-native";
2
+ import { ScrollView, StyleSheet, View, Alert } from "react-native";
3
3
  import { Avatar, Card, Text, Modal, Portal, Button, TextInput } from "react-native-paper";
4
4
  import { useFocusEffect } from '@react-navigation/native';
5
5
  import useCategories from "../hooks/useCategories";
@@ -22,7 +22,7 @@ const Categories = ({ navigation }) => {
22
22
  day: "numeric",
23
23
  });
24
24
 
25
- const { moreCategories, addCategory } = useCategories();
25
+ const { moreCategories, addCategory, removeCategory } = useCategories();
26
26
  const { setSync } = useSyncContext();
27
27
 
28
28
  const [newCategory, setNewCategory] = useState("");
@@ -45,6 +45,24 @@ const Categories = ({ navigation }) => {
45
45
  hideModal();
46
46
  }
47
47
 
48
+ function handleRemoveCategory(categoryName) {
49
+ Alert.alert(
50
+ "Delete Category",
51
+ `Are you sure you want to delete "${categoryName}"?`,
52
+ [
53
+ {
54
+ text: "Cancel",
55
+ style: "cancel"
56
+ },
57
+ {
58
+ text: "Delete",
59
+ style: "destructive",
60
+ onPress: () => removeCategory(categoryName)
61
+ }
62
+ ]
63
+ );
64
+ }
65
+
48
66
  return (
49
67
  <>
50
68
  <Portal>
@@ -127,6 +145,7 @@ const Categories = ({ navigation }) => {
127
145
  key={index}
128
146
  style={styles.card}
129
147
  onPress={() => navigation.navigate("Tasks", { category })}
148
+ onLongPress={() => handleRemoveCategory(category)}
130
149
  mode="contained"
131
150
  >
132
151
  <Card.Title