diff --git a/native/navigation/root-navigator.react.js b/native/navigation/root-navigator.react.js index cfca8e066..5044cb65b 100644 --- a/native/navigation/root-navigator.react.js +++ b/native/navigation/root-navigator.react.js @@ -1,193 +1,194 @@ // @flow import { createNavigatorFactory, useNavigationBuilder, type StackNavigationState, type StackOptions, type StackNavigationEventMap, type StackNavigatorProps, type ExtraStackNavigatorProps, } from '@react-navigation/native'; import { StackView, TransitionPresets } from '@react-navigation/stack'; import * as React from 'react'; import { Platform } from 'react-native'; import { enableScreens } from 'react-native-screens'; import LoggedOutModal from '../account/logged-out-modal.react'; import VerificationModal from '../account/verification-modal.react'; import ThreadPickerModal from '../calendar/thread-picker-modal.react'; import AddUsersModal from '../chat/settings/add-users-modal.react'; import ColorPickerModal from '../chat/settings/color-picker-modal.react'; import ComposeSubthreadModal from '../chat/settings/compose-subthread-modal.react'; import SidebarListModal from '../chat/sidebar-list-modal.react'; import CustomServerModal from '../more/custom-server-modal.react'; import AppNavigator from './app-navigator.react'; import { RootNavigatorContext } from './root-navigator-context'; import RootRouter, { type RootRouterNavigationProp } from './root-router'; import { LoggedOutModalRouteName, VerificationModalRouteName, AppRouteName, ThreadPickerModalRouteName, AddUsersModalRouteName, CustomServerModalRouteName, ColorPickerModalRouteName, ComposeSubthreadModalRouteName, SidebarListModalRouteName, type ScreenParamList, type RootParamList, } from './route-names'; if (Platform.OS !== 'android' || Platform.Version >= 21) { // Older Android devices get stack overflows when trying to draw deeply nested // view structures. We've tried to get our draw depth down as much as possible // without going into React Navigation internals or creating a separate render // path for these old Android devices. Because react-native-screens increases // the draw depth enough to cause crashes in some scenarios, we disable it // here for those devices enableScreens(); } type RootNavigatorProps = StackNavigatorProps>; function RootNavigator({ initialRouteName, children, screenOptions, ...rest }: RootNavigatorProps) { const { state, descriptors, navigation } = useNavigationBuilder(RootRouter, { initialRouteName, children, screenOptions, }); const [keyboardHandlingEnabled, setKeyboardHandlingEnabled] = React.useState( true, ); const rootNavigationContext = React.useMemo( () => ({ setKeyboardHandlingEnabled }), [setKeyboardHandlingEnabled], ); return ( ); } const createRootNavigator = createNavigatorFactory< StackNavigationState, StackOptions, StackNavigationEventMap, RootRouterNavigationProp<>, ExtraStackNavigatorProps, >(RootNavigator); const baseTransitionPreset = Platform.select({ ios: TransitionPresets.ModalSlideFromBottomIOS, default: TransitionPresets.FadeFromBottomAndroid, }); const transitionPreset = { ...baseTransitionPreset, cardStyleInterpolator: (interpolatorProps) => { const baseCardStyleInterpolator = baseTransitionPreset.cardStyleInterpolator( interpolatorProps, ); const overlayOpacity = interpolatorProps.current.progress.interpolate({ inputRange: [0, 1], outputRange: ([0, 0.7]: number[]), // Flow... extrapolate: 'clamp', }); return { ...baseCardStyleInterpolator, overlayStyle: [ baseCardStyleInterpolator.overlayStyle, { opacity: overlayOpacity }, ], }; }, }; const defaultScreenOptions = { gestureEnabled: Platform.OS === 'ios', animationEnabled: Platform.OS !== 'web' && Platform.OS !== 'windows' && Platform.OS !== 'macos', cardStyle: { backgroundColor: 'transparent' }, ...transitionPreset, }; const disableGesturesScreenOptions = { gestureEnabled: false, }; const modalOverlayScreenOptions = { cardOverlayEnabled: true, }; export type RootNavigationProp< RouteName: $Keys = $Keys, > = RootRouterNavigationProp; const Root = createRootNavigator< ScreenParamList, RootParamList, RootNavigationProp<>, >(); const RootComponent = () => { return ( ); }; export default RootComponent;