import { View, Text, Pressable, Modal } from 'react-native'; import { useRouter, type RelativePathString } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { useTranslation } from 'react-i18next'; import { useAuthStore } from '../../stores/auth'; // Controlled-Modal-Pattern. Trigger ist NICHT in dieser Komponente — der // Avatar im AppHeader öffnet das Modal via `visible`-Prop (User-Anweisung // 2026-05-07: kein separates 3-Punkte-Icon). // // Card-Style mit: // - SOS prominent oben (nur Wort "SOS" rot, Tagline neutral; ernste Sache, // nicht mit Gaming/Profile in eine Liste werfen) // - Profile · Settings · Games · [Debug DEV] in der Mitte // - Abmelden unten, neutral (nicht rot — Recovery-tonal, kein Alarm) type ItemKey = 'profile' | 'settings' | 'games' | 'debug'; type Item = { key: ItemKey; label: string; icon: React.ComponentProps['name']; onSelect: () => void | Promise; }; type Props = { visible: boolean; onClose: () => void; topOffset?: number; }; export function HeaderDropdownMenu({ visible, onClose, topOffset = 80 }: Props) { const router = useRouter(); const { t } = useTranslation(); const { signOut } = useAuthStore(); function nav(path: RelativePathString) { onClose(); router.push(path); } async function handleLogout() { onClose(); await signOut(); router.replace('/' as RelativePathString); } const items: Item[] = [ { key: 'profile', label: t('headerMenu.profile'), icon: 'person-outline', onSelect: () => nav('/profile' as RelativePathString), }, { key: 'settings', label: t('headerMenu.settings'), icon: 'settings-outline', onSelect: () => nav('/settings' as RelativePathString), }, { key: 'games', label: t('headerMenu.games'), icon: 'game-controller-outline', onSelect: () => nav('/games' as RelativePathString), }, ]; if (__DEV__) { items.push({ key: 'debug', label: t('headerMenu.debug'), icon: 'bug-outline', onSelect: () => nav('/debug' as RelativePathString), }); } return ( true} style={{ position: 'absolute', top: topOffset, right: 12, backgroundColor: '#ffffff', borderRadius: 18, shadowColor: '#000', shadowOffset: { width: 0, height: 8 }, shadowOpacity: 0.18, shadowRadius: 20, elevation: 12, minWidth: 170, overflow: 'hidden', }} > {/* SOS prominent — separat, ernst-tonal, nur "SOS" rot */} { onClose(); router.push('/urge' as RelativePathString); }} android_ripple={{ color: '#fee2e2' }} > {t('appHeader.sosLabel')} {t('appHeader.sosTagline')} {/* Profile · Settings · Games · [Debug DEV] */} {items.map((item) => ( { onClose(); void item.onSelect(); }} android_ripple={{ color: '#e5e7eb' }} style={({ pressed }) => ({ backgroundColor: pressed ? '#f5f5f5' : 'transparent', })} > {item.label} ))} {/* Abmelden — neutral, nicht rot */} ({ backgroundColor: pressed ? '#f5f5f5' : 'transparent', })} > {t('headerMenu.logout')} ); }