Update react-navigation (#5967)
This commit is contained in:
@@ -1,25 +1,29 @@
|
||||
import * as React from 'react'
|
||||
import {View} from 'react-native'
|
||||
// Based on @react-navigation/native-stack/src/createNativeStackNavigator.ts
|
||||
// Based on @react-navigation/native-stack/src/navigators/createNativeStackNavigator.ts
|
||||
// MIT License
|
||||
// Copyright (c) 2017 React Navigation Contributors
|
||||
import {
|
||||
createNavigatorFactory,
|
||||
type EventArg,
|
||||
type NavigatorTypeBagBase,
|
||||
type ParamListBase,
|
||||
type StackActionHelpers,
|
||||
StackActions,
|
||||
type StackNavigationState,
|
||||
StackRouter,
|
||||
type StackRouterOptions,
|
||||
type StaticConfig,
|
||||
type TypedNavigator,
|
||||
useNavigationBuilder,
|
||||
} from '@react-navigation/native'
|
||||
import {NativeStackView} from '@react-navigation/native-stack'
|
||||
import {
|
||||
type NativeStackNavigationEventMap,
|
||||
type NativeStackNavigationOptions,
|
||||
type NativeStackNavigationProp,
|
||||
type NativeStackNavigatorProps,
|
||||
} from '@react-navigation/native-stack'
|
||||
import {NativeStackView} from '@react-navigation/native-stack'
|
||||
import {type NativeStackNavigatorProps} from '@react-navigation/native-stack/src/types'
|
||||
|
||||
import {PWI_ENABLED} from '#/lib/build-flags'
|
||||
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
||||
@@ -48,12 +52,14 @@ function NativeStackNavigator({
|
||||
id,
|
||||
initialRouteName,
|
||||
children,
|
||||
layout,
|
||||
screenListeners,
|
||||
screenOptions,
|
||||
screenLayout,
|
||||
...rest
|
||||
}: NativeStackNavigatorProps) {
|
||||
// --- this is copy and pasted from the original native stack navigator ---
|
||||
const {state, descriptors, navigation, NavigationContent} =
|
||||
const {state, describe, descriptors, navigation, NavigationContent} =
|
||||
useNavigationBuilder<
|
||||
StackNavigationState<ParamListBase>,
|
||||
StackRouterOptions,
|
||||
@@ -64,9 +70,12 @@ function NativeStackNavigator({
|
||||
id,
|
||||
initialRouteName,
|
||||
children,
|
||||
layout,
|
||||
screenListeners,
|
||||
screenOptions,
|
||||
screenLayout,
|
||||
})
|
||||
|
||||
React.useEffect(
|
||||
() =>
|
||||
// @ts-expect-error: there may not be a tab navigator in parent
|
||||
@@ -148,7 +157,8 @@ function NativeStackNavigator({
|
||||
{...rest}
|
||||
state={state}
|
||||
navigation={navigation}
|
||||
descriptors={newDescriptors}
|
||||
descriptors={descriptors}
|
||||
describe={describe}
|
||||
/>
|
||||
</View>
|
||||
{isWeb && (
|
||||
@@ -161,9 +171,25 @@ function NativeStackNavigator({
|
||||
)
|
||||
}
|
||||
|
||||
export const createNativeStackNavigatorWithAuth = createNavigatorFactory<
|
||||
StackNavigationState<ParamListBase>,
|
||||
NativeStackNavigationOptionsWithAuth,
|
||||
NativeStackNavigationEventMap,
|
||||
typeof NativeStackNavigator
|
||||
>(NativeStackNavigator)
|
||||
export function createNativeStackNavigatorWithAuth<
|
||||
const ParamList extends ParamListBase,
|
||||
const NavigatorID extends string | undefined = undefined,
|
||||
const TypeBag extends NavigatorTypeBagBase = {
|
||||
ParamList: ParamList
|
||||
NavigatorID: NavigatorID
|
||||
State: StackNavigationState<ParamList>
|
||||
ScreenOptions: NativeStackNavigationOptionsWithAuth
|
||||
EventMap: NativeStackNavigationEventMap
|
||||
NavigationList: {
|
||||
[RouteName in keyof ParamList]: NativeStackNavigationProp<
|
||||
ParamList,
|
||||
RouteName,
|
||||
NavigatorID
|
||||
>
|
||||
}
|
||||
Navigator: typeof NativeStackNavigator
|
||||
},
|
||||
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
|
||||
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
||||
return createNavigatorFactory(NativeStackNavigator)(config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user