forked from karakeep-app/karakeep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_layout.tsx
More file actions
152 lines (147 loc) · 5.05 KB
/
_layout.tsx
File metadata and controls
152 lines (147 loc) · 5.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import "@/globals.css";
import "expo-dev-client";
import type React from "react";
import { useEffect } from "react";
import { Platform } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { KeyboardProvider } from "react-native-keyboard-controller";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { useRouter } from "expo-router";
import { Stack } from "expo-router/stack";
import { ShareIntentProvider, useShareIntent } from "expo-share-intent";
import { StatusBar } from "expo-status-bar";
import { StyledStack } from "@/components/navigation/stack";
import SplashScreenController from "@/components/SplashScreenController";
import { Providers } from "@/lib/providers";
import { useColorScheme, useInitialAndroidBarSync } from "@/lib/useColorScheme";
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();
const { hasShareIntent } = useShareIntent();
const { colorScheme, isDarkColorScheme } = useColorScheme();
useEffect(() => {
if (hasShareIntent) {
router.replace({
pathname: "sharing",
});
}
}, [hasShareIntent]);
return (
<SafeAreaProvider>
<RootKeyboardProvider>
<NavThemeProvider value={NAV_THEME[colorScheme]}>
<SplashScreenController />
<StyledStack
layout={(props) => {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<ShareIntentProvider>
<Providers>{props.children}</Providers>
</ShareIntentProvider>
</GestureHandlerRootView>
);
}}
contentClassName={cn(
"w-full flex-1 bg-gray-100 text-foreground dark:bg-background",
colorScheme == "dark" ? "dark" : "light",
)}
screenOptions={{
...Platform.select({
ios: {
headerTransparent: true,
headerBlurEffect: "systemMaterial",
headerLargeTitle: true,
headerLargeTitleShadowVisible: false,
headerLargeStyle: { backgroundColor: "transparent" },
},
}),
headerShadowVisible: false,
}}
>
<Stack.Screen
name="dashboard"
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="index"
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="signin"
options={{
headerShown: true,
headerBackVisible: true,
headerBackTitle: "Back",
title: "",
}}
/>
<Stack.Screen
name="sharing"
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="+not-found"
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="server-address"
options={{
title: "Server Address",
headerShown: true,
headerTransparent: false,
headerLargeTitle: false,
presentation: Platform.select({
ios: "formSheet" as const,
default: "modal" as const,
}),
}}
/>
<Stack.Screen
name="test-connection"
options={{
title: "Test Connection",
headerShown: true,
headerTransparent: false,
headerLargeTitle: false,
presentation: Platform.select({
ios: "formSheet" as const,
default: "modal" as const,
}),
}}
/>
</StyledStack>
</NavThemeProvider>
</RootKeyboardProvider>
<StatusBar
key={`root-status-bar-${isDarkColorScheme ? "light" : "dark"}`}
style={isDarkColorScheme ? "light" : "dark"}
/>
</SafeAreaProvider>
);
}