-
Notifications
You must be signed in to change notification settings - Fork 111
/
Root.tsx
38 lines (32 loc) · 1.18 KB
/
Root.tsx
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
import { StatusBar } from "expo-status-bar";
import React from "react";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { ContextNavigator } from "../ContextNavigator";
import { RequireContext } from "../types";
function getGestureHandlerRootView() {
try {
const { GestureHandlerRootView } =
require("react-native-gesture-handler") as typeof import("react-native-gesture-handler");
return function GestureHandler(props: any) {
return <GestureHandlerRootView style={{ flex: 1 }} {...props} />;
};
} catch {
return React.Fragment;
}
}
const GestureHandlerRootView = getGestureHandlerRootView();
const INITIAL_METRICS = {
frame: { x: 0, y: 0, width: 0, height: 0 },
insets: { top: 0, left: 0, right: 0, bottom: 0 },
};
export function ExpoRoot({ context }: { context: RequireContext }) {
return (
<GestureHandlerRootView>
<SafeAreaProvider initialMetrics={INITIAL_METRICS}>
<ContextNavigator context={context} />
{/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}
<StatusBar style="auto" />
</SafeAreaProvider>
</GestureHandlerRootView>
);
}