import React, { useCallback, useMemo, useState } from 'react'; import { View, Text, StyleSheet, SafeAreaView, KeyboardAvoidingView, TouchableOpacity, BackHandler } from 'react-native'; import { useFocusEffect } from 'expo-router'; import { Header } from '@/components/Header'; import { CategoryFilter } from '@/components/CategoryFilter'; import { TaskList } from '@/components/TaskList'; import { QuickAddBar } from '@/components/QuickAddBar'; import { useDatabase } from '@/hooks/useDatabase'; import { useSettings } from '@/theme'; import Svg, { Path, Circle } from 'react-native-svg'; export default function TasksScreen() { const { isReady } = useDatabase(); const { theme, showCompleted, setShowCompleted } = useSettings(); const [selectedCategories, setSelectedCategories] = useState([]); const categoryIds = useMemo(() => selectedCategories, [selectedCategories]); useFocusEffect( useCallback(() => { const sub = BackHandler.addEventListener('hardwareBackPress', () => false); return () => sub.remove(); }, []) ); if (!isReady) { return ( Loading... ); } return (
setShowCompleted(!showCompleted)} activeOpacity={0.8} accessibilityRole="switch" accessibilityLabel="Show completed tasks" accessibilityState={{ checked: showCompleted }} > {showCompleted && ( )} Completed ); } const styles = StyleSheet.create({ container: { flex: 1, }, categoryFilterWrapper: { justifyContent: 'center', flexDirection: 'row', alignItems: 'center', paddingRight: 12, }, completedToggle: { flexDirection: 'row', alignItems: 'center', gap: 5, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 18, borderWidth: 1.5, alignSelf: 'center', }, completedToggleText: { fontSize: 12, fontWeight: '600', }, kbAvoid: { flex: 1, }, });