import { useState } from 'react'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity, Switch, Alert, } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { useAuthContext } from '../../lib/AuthContext'; import Constants from 'expo-constants'; export default function SettingsScreen() { const { user, logout } = useAuthContext(); const [darkMode, setDarkMode] = useState(false); const [notifications, setNotifications] = useState(true); const [language, setLanguage] = useState<'cs' | 'en'>('cs'); const handleLogout = () => { Alert.alert( 'Odhlaseni', 'Opravdu se chcete odhlasit?', [ { text: 'Zrusit', style: 'cancel' }, { text: 'Odhlasit', style: 'destructive', onPress: logout, }, ], ); }; const renderSection = (title: string, children: React.ReactNode) => ( {title} {children} ); const renderRow = ( icon: string, label: string, right?: React.ReactNode, onPress?: () => void, ) => ( {label} {right || (onPress && )} ); return ( {/* User card */} {(user?.name || 'U')[0].toUpperCase()} {user?.name || 'Uzivatel'} {user?.email || ''} {renderSection('Predvolby', ( <> {renderRow( 'moon-outline', 'Tmavy rezim', , )} {renderRow( 'notifications-outline', 'Oznameni', , )} {renderRow( 'language-outline', 'Jazyk', setLanguage(language === 'cs' ? 'en' : 'cs')} > {language === 'cs' ? 'Cestina' : 'English'} , )} ))} {renderSection('Ucet', ( <> {renderRow('person-outline', 'Upravit profil', undefined, () => Alert.alert('Info', 'Bude k dispozici brzy'), )} {renderRow('lock-closed-outline', 'Zmenit heslo', undefined, () => Alert.alert('Info', 'Bude k dispozici brzy'), )} ))} {renderSection('Informace', ( <> {renderRow('information-circle-outline', 'Verze', ( {Constants.expoConfig?.version || '1.0.0'} ))} {renderRow('document-text-outline', 'Podminky pouziti', undefined, () => Alert.alert('Info', 'Bude k dispozici brzy'), )} ))} {/* Logout */} Odhlasit se ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#F8FAFC' }, userCard: { flexDirection: 'row', alignItems: 'center', backgroundColor: '#fff', padding: 20, margin: 12, borderRadius: 12, shadowColor: '#000', shadowOffset: { width: 0, height: 1 }, shadowOpacity: 0.05, shadowRadius: 3, elevation: 2, }, userAvatar: { width: 56, height: 56, borderRadius: 28, backgroundColor: '#3B82F6', alignItems: 'center', justifyContent: 'center', }, userAvatarText: { color: '#fff', fontSize: 22, fontWeight: '700' }, userInfo: { marginLeft: 16, flex: 1 }, userName: { fontSize: 18, fontWeight: '600', color: '#1E293B' }, userEmail: { fontSize: 14, color: '#64748B', marginTop: 2 }, section: { marginTop: 12, marginHorizontal: 12 }, sectionTitle: { fontSize: 13, fontWeight: '600', color: '#64748B', textTransform: 'uppercase', marginBottom: 6, marginLeft: 4, }, sectionContent: { backgroundColor: '#fff', borderRadius: 12, overflow: 'hidden', }, row: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 16, paddingVertical: 14, borderBottomWidth: 1, borderBottomColor: '#F1F5F9', }, rowLeft: { flexDirection: 'row', alignItems: 'center', gap: 12 }, rowLabel: { fontSize: 15, color: '#1E293B' }, langToggle: { backgroundColor: '#F1F5F9', paddingHorizontal: 12, paddingVertical: 4, borderRadius: 8, }, langText: { fontSize: 13, color: '#3B82F6', fontWeight: '600' }, versionText: { fontSize: 14, color: '#94A3B8' }, logoutBtn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, marginTop: 24, marginHorizontal: 12, paddingVertical: 14, backgroundColor: '#FEF2F2', borderRadius: 12, }, logoutText: { color: '#EF4444', fontSize: 16, fontWeight: '600' }, });