import { createNavigatorFactory, createScreenFactory, type DrawerActionHelpers, type DrawerNavigationState, DrawerRouter, type DrawerRouterOptions, type NavigatorTypeBagBase, type ParamListBase, type StaticConfig, type TypedNavigator, useNavigationBuilder, } from '@react-navigation/native'; import type { DrawerNavigationEventMap, DrawerNavigationOptions, DrawerNavigationProp, DrawerNavigatorProps, } from '../types'; import { DrawerView } from '../views/DrawerView'; function DrawerNavigator({ id, initialRouteName, defaultStatus = 'closed', backBehavior, UNSTABLE_routeNamesChangeBehavior, children, layout, screenListeners, screenOptions, screenLayout, UNSTABLE_router, ...rest }: DrawerNavigatorProps) { const { state, descriptors, navigation, render } = useNavigationBuilder< DrawerNavigationState, DrawerRouterOptions, DrawerActionHelpers, DrawerNavigationOptions, DrawerNavigationEventMap >(DrawerRouter, { id, initialRouteName, defaultStatus, backBehavior, UNSTABLE_routeNamesChangeBehavior, children, layout, screenListeners, screenOptions, screenLayout, UNSTABLE_router, }); return render( ); } export type DrawerTypeBag< ParamList extends ParamListBase = ParamListBase, NavigatorID extends string | undefined = string | undefined, > = { ParamList: ParamList; NavigatorID: NavigatorID; State: DrawerNavigationState; ScreenOptions: DrawerNavigationOptions; EventMap: DrawerNavigationEventMap; NavigationList: { [RouteName in keyof ParamList]: DrawerNavigationProp< ParamList, RouteName, NavigatorID >; }; Navigator: typeof DrawerNavigator; }; export function createDrawerNavigator< const ParamList extends ParamListBase, const NavigatorID extends string | undefined = string | undefined, const TypeBag extends NavigatorTypeBagBase = DrawerTypeBag< ParamList, NavigatorID >, const Config extends StaticConfig = StaticConfig, >(config?: Config): TypedNavigator { return createNavigatorFactory(DrawerNavigator)(config); } export const createDrawerScreen = createScreenFactory();