From 96b635bccb4d9efc613b59872d70f6b868ff8538 Mon Sep 17 00:00:00 2001 From: Ismail Ali Date: Tue, 15 Jul 2025 20:53:11 +0200 Subject: [PATCH] =?UTF-8?q?Eintrag=20in=20SQlite=20einf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(tabs)/_layout.tsx | 37 ++++++++------- app/(tabs)/calendar.tsx | 101 ++++++++++++++++++++++++++++++++++++++++ app/(tabs)/index.tsx | 11 ++--- 3 files changed, 126 insertions(+), 23 deletions(-) diff --git a/app/(tabs)/_layout.tsx b/app/(tabs)/_layout.tsx index cfbc1e2..d4744a8 100644 --- a/app/(tabs)/_layout.tsx +++ b/app/(tabs)/_layout.tsx @@ -1,12 +1,12 @@ -import { Tabs } from 'expo-router'; -import React from 'react'; -import { Platform } from 'react-native'; +import { Tabs } from "expo-router"; +import React from "react"; +import { Platform } from "react-native"; -import { HapticTab } from '@/components/HapticTab'; -import { IconSymbol } from '@/components/ui/IconSymbol'; -import TabBarBackground from '@/components/ui/TabBarBackground'; -import { Colors } from '@/constants/Colors'; -import { useColorScheme } from '@/hooks/useColorScheme'; +import { HapticTab } from "@/components/HapticTab"; +import { IconSymbol } from "@/components/ui/IconSymbol"; +import TabBarBackground from "@/components/ui/TabBarBackground"; +import { Colors } from "@/constants/Colors"; +import { useColorScheme } from "@/hooks/useColorScheme"; export default function TabLayout() { const colorScheme = useColorScheme(); @@ -14,30 +14,35 @@ export default function TabLayout() { return ( + }} + > , + title: "Home", + tabBarIcon: ({ color }) => ( + + ), }} /> , + title: "Kalender", + tabBarIcon: ({ color }) => ( + + ), }} /> diff --git a/app/(tabs)/calendar.tsx b/app/(tabs)/calendar.tsx index d7f40d5..719dfca 100644 --- a/app/(tabs)/calendar.tsx +++ b/app/(tabs)/calendar.tsx @@ -1,11 +1,15 @@ +import { Ionicons } from "@expo/vector-icons"; import * as Calendar from "expo-calendar"; import * as SQLite from "expo-sqlite"; import React, { useEffect, useState } from "react"; import { + Button, FlatList, + Modal, SafeAreaView, StyleSheet, Text, + TextInput, TouchableOpacity, View, } from "react-native"; @@ -30,6 +34,10 @@ export default function CalendarTab() { const [calendarType, setCalendarType] = useState<"calendar" | "reminder">( "calendar" ); + const [modalVisible, setModalVisible] = useState(false); + const [newTitle, setNewTitle] = useState(""); + const [newStart, setNewStart] = useState(""); + const [newEnd, setNewEnd] = useState(""); useEffect(() => { if (source === "sqlite") { @@ -129,6 +137,21 @@ export default function CalendarTab() { } }; + const addEventToDB = async () => { + if (!newTitle || !newStart || !newEnd) return; + await db.execAsync( + `INSERT INTO events (id, title, startDate, endDate) VALUES ('${Date.now()}', '${newTitle.replace( + /'/g, + "''" + )}', '${newStart}', '${newEnd}');` + ); + setModalVisible(false); + setNewTitle(""); + setNewStart(""); + setNewEnd(""); + await loadEventsFromDB(); + }; + const renderItem = ({ item }: { item: EventItem }) => ( {item.title} @@ -141,6 +164,20 @@ export default function CalendarTab() { return ( + + setModalVisible(true)} + style={{ padding: 10 }} + > + + + + setModalVisible(false)} + > + + + Neuer SQLite-Eintrag + + + + +