import { createNavigatorFactory, type DefaultNavigatorOptions, type NavigatorTypeBagBase, type ParamListBase, type StaticConfig, type TabActionHelpers, type TabNavigationState, TabRouter, type TabRouterOptions, type TypedNavigator, useNavigationBuilder, useTheme, } from '@react-navigation/native'; import Color from 'color'; import type { NativeBottomTabNavigationConfig, NativeBottomTabNavigationEventMap, NativeBottomTabNavigationOptions, NativeBottomTabNavigationProp, } from '../types'; import NativeBottomTabView from '../views/NativeBottomTabView'; export type NativeBottomTabNavigatorProps = DefaultNavigatorOptions< ParamListBase, string | undefined, TabNavigationState, NativeBottomTabNavigationOptions, NativeBottomTabNavigationEventMap, NativeBottomTabNavigationProp > & TabRouterOptions & NativeBottomTabNavigationConfig; function NativeBottomTabNavigator({ id, initialRouteName, backBehavior, UNSTABLE_routeNamesChangeBehavior, children, layout, screenListeners, screenOptions, screenLayout, UNSTABLE_router, tabBarActiveTintColor: customActiveTintColor, tabBarInactiveTintColor: customInactiveTintColor, layoutDirection = 'locale', ...rest }: NativeBottomTabNavigatorProps) { const { colors } = useTheme(); const activeTintColor = customActiveTintColor === undefined ? colors.primary : customActiveTintColor; const inactiveTintColor = customInactiveTintColor === undefined ? Color(colors.text).mix(Color(colors.card), 0.5).hex() : customInactiveTintColor; const { state, descriptors, navigation, NavigationContent } = useNavigationBuilder< TabNavigationState, TabRouterOptions, TabActionHelpers, NativeBottomTabNavigationOptions, NativeBottomTabNavigationEventMap >(TabRouter, { id, initialRouteName, backBehavior, UNSTABLE_routeNamesChangeBehavior, children, layout, screenListeners, screenOptions, screenLayout, UNSTABLE_router, }); return ( ); } export default function createNativeBottomTabNavigator< const ParamList extends ParamListBase, const NavigatorID extends string | undefined = undefined, const TypeBag extends NavigatorTypeBagBase = { ParamList: ParamList; NavigatorID: NavigatorID; State: TabNavigationState; ScreenOptions: NativeBottomTabNavigationOptions; EventMap: NativeBottomTabNavigationEventMap; NavigationList: { [RouteName in keyof ParamList]: NativeBottomTabNavigationProp< ParamList, RouteName, NavigatorID >; }; Navigator: typeof NativeBottomTabNavigator; }, const Config extends StaticConfig = StaticConfig, >(config?: Config): TypedNavigator { return createNavigatorFactory(NativeBottomTabNavigator)(config); }