Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions apps/mobile/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "@/globals.css";
import "expo-dev-client";

import type React from "react";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import type React from "react";
import type { ReactNode } from "react";

nitpick ^^

import { useEffect } from "react";
import { Platform } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
Expand All @@ -18,6 +19,22 @@ import { cn } from "@/lib/utils";
import { NAV_THEME } from "@/theme";
import { ThemeProvider as NavThemeProvider } from "@react-navigation/native";

// On Android, KeyboardProvider's EdgeToEdgeReactViewGroup intercepts window insets at
// the root view level, zeroing out the status bar top inset. This prevents the native
// navigation toolbar (react-native-screens' CustomToolbar) from receiving the correct
// system bar insets, resulting in headers appearing cramped against the status bar.
// We skip KeyboardProvider on Android entirely to let the toolbar handle its own insets.
function RootKeyboardProvider({ children }: { children: React.ReactNode }) {
if (Platform.OS === "android") {
return children;
}
return (
<KeyboardProvider statusBarTranslucent navigationBarTranslucent>
{children}
</KeyboardProvider>
);
}

export default function RootLayout() {
useInitialAndroidBarSync();
const router = useRouter();
Expand All @@ -34,10 +51,7 @@ export default function RootLayout() {

return (
<SafeAreaProvider>
<KeyboardProvider
statusBarTranslucent={Platform.OS !== "android" ? true : undefined}
navigationBarTranslucent={Platform.OS !== "android" ? true : undefined}
>
<RootKeyboardProvider>
<NavThemeProvider value={NAV_THEME[colorScheme]}>
<SplashScreenController />
<StyledStack
Expand Down Expand Up @@ -128,7 +142,7 @@ export default function RootLayout() {
/>
</StyledStack>
</NavThemeProvider>
</KeyboardProvider>
</RootKeyboardProvider>
<StatusBar
key={`root-status-bar-${isDarkColorScheme ? "light" : "dark"}`}
style={isDarkColorScheme ? "light" : "dark"}
Expand Down