[fix](client): give the navigator a dark theme and a light status bar

React Navigation paints every scene with its own theme background and defaults
to the light one, so a screen that did not paint `bg` itself sat on white while
the text tokens stayed light. Root-level background + a matching navigator theme
means no screen can fall through to a light surface again, and the status bar
icons are legible on the dark palette.
This commit is contained in:
2026-10-19 09:28:20 +01:00
parent 1f62137754
commit 6cd6bf3ed3
+24 -3
View File
@@ -1,8 +1,9 @@
import React, { useEffect, useRef } from 'react'; import React, { useEffect, useRef } from 'react';
import { StatusBar } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler'; import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { HeroUINativeProviderRaw } from 'heroui-native/provider-raw'; import { HeroUINativeProviderRaw } from 'heroui-native/provider-raw';
import { SafeAreaProvider } from 'react-native-safe-area-context'; import { SafeAreaProvider } from 'react-native-safe-area-context';
import { NavigationContainer, useNavigation } from '@react-navigation/native'; import { DarkTheme, NavigationContainer, useNavigation } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createNativeStackNavigator } from '@react-navigation/native-stack';
import type { NativeStackNavigationProp } from '@react-navigation/native-stack'; import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { ThemeProvider } from './src/state/ThemeContext'; import { ThemeProvider } from './src/state/ThemeContext';
@@ -17,13 +18,32 @@ import ScannerScreen from './src/screens/ScannerScreen';
import SettingsScreen from './src/screens/SettingsScreen'; import SettingsScreen from './src/screens/SettingsScreen';
import LiveAlarmScreen from './src/screens/LiveAlarmScreen'; import LiveAlarmScreen from './src/screens/LiveAlarmScreen';
import { LoadingView } from './src/components/ui'; import { LoadingView } from './src/components/ui';
import { bg } from './src/theme/tokens'; import { bg, border, focusRing, text } from './src/theme/tokens';
import { navigationRef, openLiveAlarm } from './src/navigationRef'; import { navigationRef, openLiveAlarm } from './src/navigationRef';
import { getLaunchAlert } from './src/services/alarmNative'; import { getLaunchAlert } from './src/services/alarmNative';
import type { RootStackParamList } from './src/navigation'; import type { RootStackParamList } from './src/navigation';
const Stack = createNativeStackNavigator<RootStackParamList>(); const Stack = createNativeStackNavigator<RootStackParamList>();
/**
* React Navigation paints each scene with its own theme background, and the
* default theme is light — that white surface is what showed through every
* screen that did not paint `bg` itself (the login page, the boot loader),
* producing light text on white. The app palette is dark by construction, so
* the navigator theme has to say so too.
*/
const NAV_THEME = {
...DarkTheme,
colors: {
...DarkTheme.colors,
background: bg,
card: bg,
text,
border,
primary: focusRing,
},
};
function Navigator({ initialRoute }: { initialRoute: 'Home' | 'Login' }) { function Navigator({ initialRoute }: { initialRoute: 'Home' | 'Login' }) {
return ( return (
<Stack.Navigator initialRouteName={initialRoute} screenOptions={{ headerShown: false }}> <Stack.Navigator initialRouteName={initialRoute} screenOptions={{ headerShown: false }}>
@@ -132,12 +152,13 @@ function Root() {
function App() { function App() {
return ( return (
<GestureHandlerRootView style={{ flex: 1, backgroundColor: bg }}> <GestureHandlerRootView style={{ flex: 1, backgroundColor: bg }}>
<StatusBar barStyle="light-content" backgroundColor={bg} />
<HeroUINativeProviderRaw> <HeroUINativeProviderRaw>
<SafeAreaProvider> <SafeAreaProvider>
<ThemeProvider> <ThemeProvider>
<ConnectionProvider> <ConnectionProvider>
<AuthProvider> <AuthProvider>
<NavigationContainer ref={navigationRef}> <NavigationContainer ref={navigationRef} theme={NAV_THEME}>
<Root /> <Root />
</NavigationContainer> </NavigationContainer>
</AuthProvider> </AuthProvider>