import Constants from './constants'
import React, { Fragment, useMemo, type FunctionComponent, type ReactNode } from 'react'
import { Platform } from 'react-native'
// import { GestureHandlerRootView as _GestureHandlerRootView } from 'react-native-gesture-handler'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import type { NavigationAction, NavigationContainerProps } from '@react-navigation/native'
import UpstreamNavigationContainer from './fork/NavigationContainer'
import { useInitializeExpoRouter } from './global-state/useInitializeExpoRouter'
import { ServerLocationContext } from './global-state/serverLocationContext'
import { Head, HeadProvider } from './head'
import type { RequireContext } from './types'
import { SplashScreen } from './views/Splash'
export type ExpoRootProps = {
context: RequireContext
location?: URL
wrapper?: FunctionComponent<{ children: ReactNode }>
navigationContainerProps?: NavigationContainerProps & {
theme?: {
dark: boolean
colors: {
primary: string
background: string
card: string
text: string
border: string
notification: string
}
}
}
}
// function getGestureHandlerRootView() {
// try {
// if (!_GestureHandlerRootView) {
// return React.Fragment
// }
// // eslint-disable-next-line no-inner-declarations
// function GestureHandler(props: any) {
// return <_GestureHandlerRootView style={{ flex: 1 }} {...props} />
// }
// if (process.env.NODE_ENV === 'development') {
// // @ts-expect-error
// GestureHandler.displayName = 'GestureHandlerRootView'
// }
// return GestureHandler
// } 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 },
}
const hasViewControllerBasedStatusBarAppearance =
Platform.OS === 'ios' &&
!!Constants.expoConfig?.ios?.infoPlist?.UIViewControllerBasedStatusBarAppearance
export function ExpoRoot({
wrapper = Fragment,
navigationContainerProps,
...props
}: ExpoRootProps) {
return (