import React from 'react'; import { View, Text, Pressable, ScrollView } from 'react-native'; import { Stack, router } from 'expo-router'; import { useStore } from '~/store/store'; import { useAuth } from '~/hooks/useAuth'; import { useTexts } from '~/hooks/useTexts'; import { useTheme } from '~/hooks/useTheme'; import { Header } from '~/components/Header'; import { Dropdown } from '~/components/dropdown'; import { GERMAN_VOICES, QUALITY_LABELS, PROVIDER_LABELS, getVoiceById, LEGACY_VOICE_MAP, } from '~/constants/voices'; export default function SettingsScreen() { const { settings, updateSettings } = useStore(); const { user, signOut } = useAuth(); const { texts, getAllTags } = useTexts(); const { colors } = useTheme(); // Map legacy voice settings to new voice IDs const currentVoice = LEGACY_VOICE_MAP[settings.voice] || settings.voice || 'de-DE-Neural2-A'; const speeds = [ { value: 0.5, label: 'Langsam (0.5x)' }, { value: 0.75, label: 'Etwas langsam (0.75x)' }, { value: 1.0, label: 'Normal (1.0x)' }, { value: 1.25, label: 'Etwas schnell (1.25x)' }, { value: 1.5, label: 'Schnell (1.5x)' }, { value: 2.0, label: 'Sehr schnell (2.0x)' }, ]; const themes = [ { value: 'light', label: 'Hell' }, { value: 'dark', label: 'Dunkel' }, ]; const totalTexts = texts.length; const totalTags = getAllTags().length; const textsWithAudio = texts.filter((t) => t.data.audio?.hasLocalCache).length; const totalAudioSize = texts.reduce((sum, text) => { return sum + (text.data.audio?.totalSize || 0); }, 0); const handleLogout = async () => { await signOut(); router.replace('/(auth)/login'); }; return ( <>
{/* Statistics */} Statistiken Texte gesamt: {totalTexts} Tags: {totalTags} Texte mit Audio: {textsWithAudio} Audio-Speicher: {(totalAudioSize / 1024 / 1024).toFixed(2)} MB {/* Audio Settings */} Audio-Einstellungen Stimme updateSettings({ voice: newVoice })} placeholder="Stimme wählen" title="Stimme auswählen" groups={Object.entries( GERMAN_VOICES.reduce( (groups, voice) => { const provider = voice.provider; if (!groups[provider]) { groups[provider] = {}; } const quality = voice.quality; if (!groups[provider][quality]) { groups[provider][quality] = []; } groups[provider][quality].push(voice); return groups; }, {} as Record> ) ).map(([provider, qualityGroups]) => ({ title: PROVIDER_LABELS[provider as keyof typeof PROVIDER_LABELS], options: Object.entries(qualityGroups).flatMap(([quality, voices]) => voices.map((voice) => ({ label: `${QUALITY_LABELS[quality as keyof typeof QUALITY_LABELS]} - ${voice.label}`, value: voice.value, })) ), }))} /> Geschwindigkeit {speeds.map((speed) => ( updateSettings({ speed: speed.value })} className={`rounded-lg border p-3 ${ settings.speed === speed.value ? `border-blue-500 ${colors.primaryLight}` : colors.border }`} > {speed.label} ))} {/* App Settings */} App-Einstellungen Design {themes.map((theme) => ( updateSettings({ theme: theme.value as 'light' | 'dark' })} className={`rounded-lg border p-3 ${ settings.theme === theme.value ? `border-blue-500 ${colors.primaryLight}` : colors.border }`} > {theme.label} ))} {/* App Info */} App Info Version: 1.0.0 Build: 1 {/* User Info */} Konto {user?.email} Abmelden ); }