import { Stack, useRouter } from 'expo-router'; import { StyleSheet, View, Text, TouchableOpacity, ScrollView, Alert, Switch } from 'react-native'; import { useTheme } from '~/utils/ThemeContext'; import { ThemeName, ThemeMode } from '~/utils/themes'; import { useAuth } from '~/utils/AuthContext'; import FontAwesome from '@expo/vector-icons/FontAwesome'; import { ThemedView, ThemedText } from '~/components/ThemedView'; export default function Settings() { const { themeName, themeMode, setThemeName, setThemeMode, theme, isDark, debugBorders, setDebugBorders, } = useTheme(); const { signOut, user } = useAuth(); const router = useRouter(); // Theme options const themeOptions: ThemeName[] = ['default', 'pastel', 'vibrant']; const themeModeOptions: ThemeMode[] = ['system', 'light', 'dark']; // Theme option labels const themeLabels: Record = { default: 'Default', pastel: 'Pastel', vibrant: 'Vibrant', }; const themeModeLabels: Record = { system: 'System', light: 'Light', dark: 'Dark', }; const handleSignOut = async () => { Alert.alert('Abmelden', 'Möchtest du dich wirklich abmelden?', [ { text: 'Abbrechen', style: 'cancel', }, { text: 'Abmelden', onPress: async () => { try { console.log('Logging out...'); const { error } = await signOut(); if (error) { console.error('Logout error:', error); Alert.alert('Fehler', 'Es gab ein Problem beim Abmelden: ' + error.message); } else { console.log('Logout successful, navigating to login screen'); // Navigate to login screen after successful logout router.replace('/login'); } } catch (e) { console.error('Unexpected error during logout:', e); Alert.alert('Fehler', 'Ein unerwarteter Fehler ist aufgetreten.'); } }, }, ]); }; return ( <> Appearance {/* Theme Selection */} Theme {themeOptions.map((option) => ( setThemeName(option)} > {themeLabels[option]} ))} {/* Mode Selection */} Mode {themeModeOptions.map((option) => ( setThemeMode(option)} > {themeModeLabels[option]} ))} {/* Theme Preview */} Preview Current Theme: {themeLabels[themeName]} Mode: {themeModeLabels[themeMode]} Button {/* Developer Options Section */} Entwickleroptionen Debug Borders anzeigen Zeigt Rahmen um UI-Elemente an, um das Layout zu debuggen {/* Account Section */} {user && ( <> Account {user.email} Abmelden )} ); } const styles = StyleSheet.create({ settingRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', padding: 16, borderRadius: 12, borderWidth: 1, marginBottom: 8, }, settingLabelContainer: { flexDirection: 'row', alignItems: 'center', }, settingLabel: { fontSize: 16, fontWeight: '500', }, settingDescription: { fontSize: 14, marginLeft: 4, marginBottom: 16, opacity: 0.7, }, settingIcon: { marginRight: 12, }, accountInfo: { padding: 16, borderRadius: 12, borderWidth: 1, marginBottom: 16, }, accountInfoRow: { flexDirection: 'row', alignItems: 'center', paddingVertical: 4, }, accountInfoText: { fontSize: 16, marginLeft: 12, }, logoutButton: { flexDirection: 'row', height: 50, borderRadius: 10, justifyContent: 'center', alignItems: 'center', }, logoutButtonText: { color: '#fff', fontSize: 16, fontWeight: 'bold', }, buttonIcon: { marginRight: 10, }, container: { flex: 1, }, contentContainer: { padding: 24, paddingBottom: 40, }, sectionTitle: { fontSize: 22, fontWeight: 'bold', marginBottom: 16, }, section: { marginBottom: 24, }, sectionHeader: { fontSize: 18, fontWeight: '600', marginBottom: 12, }, optionsContainer: { flexDirection: 'row', flexWrap: 'wrap', marginHorizontal: -6, }, optionButton: { paddingVertical: 10, paddingHorizontal: 16, borderRadius: 8, borderWidth: 1, marginHorizontal: 6, marginBottom: 12, minWidth: 100, alignItems: 'center', }, optionText: { fontSize: 16, fontWeight: '500', }, previewCard: { padding: 16, borderRadius: 12, borderWidth: 1, }, previewTitle: { fontSize: 16, fontWeight: 'bold', marginBottom: 8, }, previewSubtitle: { fontSize: 14, marginBottom: 16, }, colorSamples: { flexDirection: 'row', marginBottom: 16, }, colorSample: { width: 30, height: 30, borderRadius: 15, marginRight: 8, }, previewButton: { paddingVertical: 8, paddingHorizontal: 16, borderRadius: 8, alignItems: 'center', }, previewButtonText: { color: 'white', fontWeight: '600', }, });