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>
171 lines
4.4 KiB
TypeScript
171 lines
4.4 KiB
TypeScript
import { useEffect } from 'react';
|
|
import { Stack } from 'expo-router';
|
|
import { StatusBar } from 'expo-status-bar';
|
|
import * as Notifications from 'expo-notifications';
|
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
import { ActionSheetProvider } from '@expo/react-native-action-sheet';
|
|
import * as SplashScreen from 'expo-splash-screen';
|
|
import {
|
|
useFonts,
|
|
Nunito_400Regular,
|
|
Nunito_600SemiBold,
|
|
Nunito_700Bold,
|
|
Nunito_800ExtraBold,
|
|
} from '@expo-google-fonts/nunito';
|
|
import { useAuthStore } from '../stores/auth';
|
|
import { useThemeStore } from '../stores/theme';
|
|
import { useColors } from '../lib/theme';
|
|
import { useLanguageStore } from '../stores/language';
|
|
import { BrandSplash } from '../components/BrandSplash';
|
|
import { DeviceLimitReachedSheet } from '../components/DeviceLimitReachedSheet';
|
|
import '../lib/i18n'; // i18next-Init via Side-Effect
|
|
import '../global.css';
|
|
|
|
SplashScreen.preventAutoHideAsync();
|
|
|
|
Notifications.setNotificationHandler({
|
|
handleNotification: async () => ({
|
|
shouldShowBanner: true,
|
|
shouldShowList: true,
|
|
shouldPlaySound: true,
|
|
shouldSetBadge: false,
|
|
}),
|
|
});
|
|
|
|
const queryClient = new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
retry: 2,
|
|
staleTime: 1000 * 60,
|
|
},
|
|
},
|
|
});
|
|
|
|
function RootLayoutInner() {
|
|
const { loading, init } = useAuthStore();
|
|
const initTheme = useThemeStore((s) => s.init);
|
|
const colorScheme = useThemeStore((s) => s.colorScheme);
|
|
const initLanguage = useLanguageStore((s) => s.init);
|
|
const colors = useColors();
|
|
const [fontsLoaded] = useFonts({
|
|
Nunito_400Regular,
|
|
Nunito_600SemiBold,
|
|
Nunito_700Bold,
|
|
Nunito_800ExtraBold,
|
|
});
|
|
|
|
useEffect(() => {
|
|
init();
|
|
initTheme();
|
|
initLanguage();
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (fontsLoaded && !loading) {
|
|
SplashScreen.hideAsync();
|
|
}
|
|
}, [fontsLoaded, loading]);
|
|
|
|
if (!fontsLoaded || loading) {
|
|
return <BrandSplash />;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<StatusBar style={colorScheme === 'dark' ? 'light' : 'dark'} />
|
|
<DeviceLimitReachedSheet />
|
|
<Stack
|
|
screenOptions={{
|
|
headerShown: false,
|
|
animation: 'slide_from_right',
|
|
contentStyle: { backgroundColor: colors.bg },
|
|
}}
|
|
>
|
|
<Stack.Screen name="index" />
|
|
<Stack.Screen name="(auth)" />
|
|
<Stack.Screen name="(app)" />
|
|
<Stack.Screen
|
|
name="lyra"
|
|
options={{
|
|
headerShown: false,
|
|
presentation: 'card',
|
|
animation: 'slide_from_right',
|
|
}}
|
|
/>
|
|
<Stack.Screen
|
|
name="urge"
|
|
options={{
|
|
headerShown: false,
|
|
presentation: 'card',
|
|
animation: 'slide_from_bottom',
|
|
}}
|
|
/>
|
|
<Stack.Screen
|
|
name="dm"
|
|
options={{
|
|
headerShown: false,
|
|
presentation: 'card',
|
|
animation: 'slide_from_right',
|
|
}}
|
|
/>
|
|
<Stack.Screen
|
|
name="settings"
|
|
options={{
|
|
headerShown: false,
|
|
presentation: 'card',
|
|
animation: 'slide_from_right',
|
|
}}
|
|
/>
|
|
<Stack.Screen
|
|
name="profile/index"
|
|
options={{
|
|
headerShown: false,
|
|
presentation: 'card',
|
|
animation: 'slide_from_right',
|
|
}}
|
|
/>
|
|
<Stack.Screen
|
|
name="profile/[userId]"
|
|
options={{
|
|
headerShown: false,
|
|
presentation: 'card',
|
|
animation: 'slide_from_right',
|
|
}}
|
|
/>
|
|
<Stack.Screen
|
|
name="games"
|
|
options={{
|
|
headerShown: false,
|
|
presentation: 'card',
|
|
animation: 'slide_from_right',
|
|
}}
|
|
/>
|
|
<Stack.Screen
|
|
name="debug"
|
|
options={{
|
|
headerShown: false,
|
|
presentation: 'card',
|
|
animation: 'slide_from_right',
|
|
}}
|
|
/>
|
|
</Stack>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default function RootLayout() {
|
|
return (
|
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
<QueryClientProvider client={queryClient}>
|
|
<ActionSheetProvider>
|
|
<SafeAreaProvider>
|
|
<RootLayoutInner />
|
|
</SafeAreaProvider>
|
|
</ActionSheetProvider>
|
|
</QueryClientProvider>
|
|
</GestureHandlerRootView>
|
|
);
|
|
}
|