import React from 'react'; import { View, Pressable } from 'react-native'; import { Text } from './Text'; import { Icon } from './Icon'; import { useTheme } from '~/components/ThemeProvider'; import { themeList, themes } from '~/themes'; import { ThemeName, ThemeMode } from '~/types/theme'; import { useThemeColors } from '~/utils/themeUtils'; import { spacing } from '~/utils/spacing'; export function ThemeSwitcher() { const { theme, mode, setTheme, setMode } = useTheme(); const colors = useThemeColors(); const modeOptions: { value: ThemeMode; label: string; icon: string }[] = [ { value: 'light', label: 'Hell', icon: 'sunny' }, { value: 'dark', label: 'Dunkel', icon: 'moon' }, { value: 'system', label: 'System', icon: 'phone-portrait' }, ]; return ( {/* Theme Selection */} Farbschema {themeList.map((themeItem) => { const isSelected = theme === themeItem.name; const themeColors = mode === 'dark' || (mode === 'system' && colors.background === 'rgb(3, 7, 18)') ? themes[themeItem.name as ThemeName].dark : themes[themeItem.name as ThemeName].light; return ( setTheme(themeItem.name as ThemeName)} style={({ pressed }) => ({ flexDirection: 'row', alignItems: 'center', padding: spacing.content.small, borderRadius: 12, borderWidth: 2, borderColor: isSelected ? colors.primary : colors.border, backgroundColor: isSelected ? `${colors.primary}10` : colors.surface, opacity: pressed ? 0.7 : 1, })}> {/* Theme Preview Colors */} {/* Theme Info */} {themeItem.displayName} {themeItem.description} {/* Selection Indicator */} {isSelected && ( )} ); })} {/* Mode Selection */} Helligkeit {modeOptions.map((option) => { const isSelected = mode === option.value; return ( setMode(option.value)} style={({ pressed }) => ({ flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingVertical: spacing.content.small, borderRadius: 8, backgroundColor: isSelected ? colors.surface : 'transparent', opacity: pressed ? 0.7 : 1, ...(isSelected && { shadowColor: '#000', shadowOffset: { width: 0, height: 1 }, shadowOpacity: 0.1, shadowRadius: 2, elevation: 2, }), })}> {option.label} ); })} ); }