Theme-switch in Settings (System/Light/Dark) jetzt App-weit wirksam für die
Core-Screens. Wave 2 dokumentiert (siehe unten).
Color-System:
- lib/theme.ts: refactored zu colors.light + colors.dark (gleiche keys)
Light: bg #fff, surface #fafafa, surfaceElevated #f5f5f5, border #e5e5e5,
text #0a0a0a, textMuted #737373
Dark: bg #000, surface #1c1c1e, surfaceElevated #2c2c2e, border #38383a,
text #fff, textMuted #8e8e93
brandOrange unverändert #007AFF (iOS system blue)
success/error variieren (light: #16a34a/#dc2626, dark: #30d158/#ff453a)
- legacy `colors` export bleibt als Light-Fallback für nicht-migrierte Files
- new `useColors()` hook → liest aktiven scheme aus useThemeStore
stores/theme.ts:
- Appearance.addChangeListener für live System-Theme-Updates (User schaltet
iOS Dark/Light → App reagiert sofort ohne Reload)
Wave 1 — migrated Files (Core Screens):
- app/_layout.tsx + app/(app)/_layout.tsx + app/(app)/index.tsx (root + home)
- app/settings.tsx (full theme-aware inkl. TrueSheet)
- app/profile/index.tsx (bg + dividers)
- app/devices.tsx (bg, surface, border, icons)
- app/lyra.tsx (chat container, backdrop, bubbles, ThinkingDots, LoadingPulse)
- components/AppHeader (Nativewind classes ersetzt durch theme-aware Styles)
- components/header/HeaderDropdownMenu
- components/profile/* (ProfileHeader, StatsBar, StreakSection, UrgeStatsCard,
ApprovedDomainsList, DemographicsAccordion)
Wave 2 (TODOs für separate Session):
- app/urge.tsx (~20 hardcoded colors, größter Screen)
- app/room.tsx, app/dm.tsx, app/(app)/chat.tsx, app/(app)/mail.tsx, app/(app)/coach.tsx
- app/games.tsx, app/profile/[userId].tsx
- Nativewind classes in PostCard, ComposeCard, PostCardSkeleton, NotificationsDropdown
StatusBar style dynamisch synchronisiert (light bei dark-mode, dark bei light).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
243 lines
7.3 KiB
TypeScript
243 lines
7.3 KiB
TypeScript
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';
|
|
import { useColors } from '../../lib/theme';
|
|
|
|
// 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<typeof Ionicons>['name'];
|
|
onSelect: () => void | Promise<void>;
|
|
};
|
|
|
|
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();
|
|
const colors = useColors();
|
|
|
|
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 (
|
|
<Modal
|
|
visible={visible}
|
|
transparent
|
|
animationType="fade"
|
|
statusBarTranslucent
|
|
onRequestClose={onClose}
|
|
>
|
|
<Pressable
|
|
onPress={onClose}
|
|
style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.18)' }}
|
|
>
|
|
<View
|
|
onStartShouldSetResponder={() => true}
|
|
style={{
|
|
position: 'absolute',
|
|
top: topOffset,
|
|
right: 12,
|
|
backgroundColor: colors.surface,
|
|
borderRadius: 18,
|
|
shadowColor: '#000',
|
|
shadowOffset: { width: 0, height: 8 },
|
|
shadowOpacity: 0.18,
|
|
shadowRadius: 20,
|
|
elevation: 12,
|
|
minWidth: 210,
|
|
overflow: 'hidden',
|
|
}}
|
|
>
|
|
{/* SOS prominent — separat, ernst-tonal, nur "SOS" rot */}
|
|
<Pressable
|
|
onPress={() => {
|
|
onClose();
|
|
router.push('/urge' as RelativePathString);
|
|
}}
|
|
android_ripple={{ color: '#fee2e2' }}
|
|
>
|
|
<View
|
|
style={{
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
paddingHorizontal: 18,
|
|
paddingVertical: 16,
|
|
}}
|
|
>
|
|
<View
|
|
style={{
|
|
width: 36,
|
|
height: 36,
|
|
borderRadius: 18,
|
|
backgroundColor: '#fee2e2',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
marginRight: 14,
|
|
}}
|
|
>
|
|
<Ionicons name="heart" size={18} color="#dc2626" />
|
|
</View>
|
|
<View style={{ flex: 1 }}>
|
|
<Text
|
|
style={{
|
|
fontSize: 15,
|
|
fontFamily: 'Nunito_700Bold',
|
|
color: '#dc2626',
|
|
}}
|
|
numberOfLines={1}
|
|
>
|
|
{t('appHeader.sosLabel')}
|
|
</Text>
|
|
<Text
|
|
style={{
|
|
fontSize: 12,
|
|
fontFamily: 'Nunito_400Regular',
|
|
color: colors.textMuted,
|
|
marginTop: 1,
|
|
}}
|
|
numberOfLines={1}
|
|
>
|
|
{t('appHeader.sosTagline')}
|
|
</Text>
|
|
</View>
|
|
<Ionicons name="chevron-forward" size={16} color={colors.border} />
|
|
</View>
|
|
</Pressable>
|
|
|
|
<View style={{ height: 1, backgroundColor: colors.border }} />
|
|
|
|
{/* Profile · Settings · Games · [Debug DEV] */}
|
|
{items.map((item) => (
|
|
<Pressable
|
|
key={item.key}
|
|
onPress={() => {
|
|
onClose();
|
|
void item.onSelect();
|
|
}}
|
|
android_ripple={{ color: colors.surfaceElevated }}
|
|
style={({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })}
|
|
>
|
|
<View
|
|
style={{
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
paddingHorizontal: 18,
|
|
paddingVertical: 14,
|
|
}}
|
|
>
|
|
<Ionicons
|
|
name={item.icon}
|
|
size={18}
|
|
color={colors.textMuted}
|
|
style={{ marginRight: 14 }}
|
|
/>
|
|
<Text
|
|
style={{
|
|
fontSize: 14,
|
|
fontFamily: 'Nunito_600SemiBold',
|
|
color: colors.text,
|
|
}}
|
|
>
|
|
{item.label}
|
|
</Text>
|
|
</View>
|
|
</Pressable>
|
|
))}
|
|
|
|
<View style={{ height: 1, backgroundColor: colors.border }} />
|
|
|
|
{/* Abmelden — neutral, nicht rot */}
|
|
<Pressable
|
|
onPress={handleLogout}
|
|
android_ripple={{ color: colors.surfaceElevated }}
|
|
style={({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })}
|
|
>
|
|
<View
|
|
style={{
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
paddingHorizontal: 18,
|
|
paddingVertical: 14,
|
|
}}
|
|
>
|
|
<Ionicons
|
|
name="log-out-outline"
|
|
size={18}
|
|
color={colors.textMuted}
|
|
style={{ marginRight: 14 }}
|
|
/>
|
|
<Text
|
|
style={{
|
|
fontSize: 14,
|
|
fontFamily: 'Nunito_600SemiBold',
|
|
color: colors.text,
|
|
}}
|
|
>
|
|
{t('headerMenu.logout')}
|
|
</Text>
|
|
</View>
|
|
</Pressable>
|
|
</View>
|
|
</Pressable>
|
|
</Modal>
|
|
);
|
|
}
|