修复主题切换导航栏和状态栏

This commit is contained in:
xianyi
2026-01-13 09:46:05 +08:00
parent 9c16586994
commit 98134c5be9
3 changed files with 36 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ export default function TabLayout() {
<Tabs
screenOptions={{
tabBarActiveTintColor: Colors[theme].tint,
tabBarInactiveTintColor: Colors[theme].tabIconDefault,
headerShown: false,
tabBarButton: HapticTab,
tabBarBackground: TabBarBackground,

View File

@@ -7,6 +7,7 @@ import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";
import "react-native-reanimated";
import { Colors } from "@/constants/theme";
import { ThemeProvider } from "@/context/ThemeContext";
import { useColorScheme } from "@/hooks/use-color-scheme";
import "@/i18n"; // Initialize i18n
@@ -25,11 +26,35 @@ export default function RootLayout() {
function RootLayoutNav() {
const colorScheme = useColorScheme();
const isDark = colorScheme === "dark";
// Custom navigation theme to ensure proper colors
const navigationTheme = isDark
? {
...DarkTheme,
colors: {
...DarkTheme.colors,
background: Colors.dark.background,
card: Colors.dark.background,
text: Colors.dark.text,
border: Colors.dark.background,
notification: Colors.dark.tint,
},
}
: {
...DefaultTheme,
colors: {
...DefaultTheme.colors,
background: Colors.light.background,
card: Colors.light.background,
text: Colors.light.text,
border: Colors.light.background,
notification: Colors.light.tint,
},
};
return (
<NavigationThemeProvider
value={colorScheme === "dark" ? DarkTheme : DefaultTheme}
>
<NavigationThemeProvider value={navigationTheme}>
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen