import React from 'react'; import { View, Pressable, Modal } from 'react-native'; import { Icon } from '../ui/Icon'; import { Text } from '../ui/Text'; import { Button } from '../ui/Button'; import { Card } from '../ui/Card'; import { useThemeColors } from '~/utils/themeUtils'; export type StudyMode = 'all' | 'new' | 'review' | 'favorites' | 'random'; interface StudyModeSelectorProps { visible: boolean; onClose: () => void; onSelectMode: (mode: StudyMode) => void; cardStats?: { total: number; favorites: number; new: number; review: number; }; } interface StudyModeOption { id: StudyMode; name: string; description: string; icon: string; getColor: (colors: ReturnType) => string; disabled?: boolean; } const getStudyModes = (colors: ReturnType): StudyModeOption[] => [ { id: 'all' as StudyMode, name: 'Alle Karten', description: 'Alle Karten der Reihe nach durchgehen', icon: 'albums-outline', getColor: (c) => c.primary, }, { id: 'random' as StudyMode, name: 'Zufällig', description: 'Karten in zufälliger Reihenfolge', icon: 'shuffle-outline', getColor: (c) => c.secondary, }, { id: 'favorites' as StudyMode, name: 'Favoriten', description: 'Nur als Favorit markierte Karten', icon: 'heart-outline', getColor: (c) => c.destructive, }, { id: 'new' as StudyMode, name: 'Neue Karten', description: 'Noch nicht gelernte Karten', icon: 'sparkles-outline', getColor: (c) => c.accent, disabled: false, }, { id: 'review' as StudyMode, name: 'Wiederholung', description: 'Fällige Karten wiederholen', icon: 'refresh-outline', getColor: (c) => c.secondary, disabled: false, }, ]; export const StudyModeSelector: React.FC = ({ visible, onClose, onSelectMode, cardStats, }) => { const colors = useThemeColors(); const studyModes = getStudyModes(colors); return ( Lernmodus wählen pressed && { opacity: 0.7 }}> {studyModes.map((mode) => ( { if (!mode.disabled) { onSelectMode(mode.id); onClose(); } }} disabled={mode.disabled} style={({ pressed }) => ({ opacity: pressed && !mode.disabled ? 0.7 : 1 })}> {mode.name} {mode.disabled && ( Bald verfügbar )} {mode.description} {cardStats && mode.id === 'all' && ( {cardStats.total} Karten verfügbar )} {cardStats && mode.id === 'favorites' && ( {cardStats.favorites} Favoriten verfügbar )} {!mode.disabled && ( )} ))} ); };