import React, { useState } from 'react'; import { View, Pressable } from 'react-native'; import Text from '~/components/atoms/Text'; import { useTheme } from '~/features/theme/ThemeProvider'; import Icon from '~/components/atoms/Icon'; import Toggle from '~/components/atoms/Toggle'; import colors from '~/tailwind.config.js'; interface SettingsToggleProps { title: string; description: string; type: 'toggle' | 'dropdown' | 'button'; isOn?: boolean; onToggle?: (value: boolean) => void; options?: string[]; selectedOption?: string; onSelect?: (option: string) => void; onPress?: () => void; secondaryText?: string; } function SettingsToggle({ title, description, type, isOn = false, onToggle = undefined, options = undefined, selectedOption = '', onSelect = undefined, onPress = undefined, secondaryText = undefined, }: SettingsToggleProps) { const [isDropdownOpen, setIsDropdownOpen] = useState(false); const { isDark, themeVariant, tw } = useTheme(); const handlePress = () => { if (type === 'toggle' && onToggle) { onToggle(!isOn); } else if (type === 'dropdown') { setIsDropdownOpen(!isDropdownOpen); } else if (type === 'button' && onPress) { onPress(); } }; const handleSelect = (option: string) => { if (onSelect) { onSelect(option); } setIsDropdownOpen(false); }; // Farben aus dem Theme-System const textColor = isDark ? '#FFFFFF' : '#000000'; // Zugriff auf die Theme-Farben für die Dropdown-Optionen const themeColors = (colors as any).theme?.extend?.colors; // Primary-Farbe direkt aus der Tailwind-Konfiguration const primaryColor = isDark ? themeColors?.dark?.[themeVariant]?.primary || '#f8d62b' : themeColors?.[themeVariant]?.primary || '#f8d62b'; // Hintergrundfarbe für den Container aus der Tailwind-Konfiguration const containerBgColor = isDark ? themeColors?.dark?.[themeVariant]?.contentBackground || '#1E1E1E' : themeColors?.[themeVariant]?.contentBackground || '#FFFFFF'; // Randfarbe für den Container aus der Tailwind-Konfiguration const containerBorderColor = isDark ? themeColors?.dark?.[themeVariant]?.border || '#424242' : themeColors?.[themeVariant]?.border || '#e6e6e6'; return ( {title} {type === 'toggle' && onToggle && ( )} {type === 'dropdown' && options && onSelect && ( )} {type === 'button' && onPress && ( {secondaryText && ( {secondaryText} )} )} {description} {type === 'dropdown' && isDropdownOpen && options && onSelect && ( {options.map((option) => { const isSelected = option === selectedOption; return ( handleSelect(option)} > {option} ); })} )} ); } export default SettingsToggle;