@amazon-devices/react-navigation__stack 7.0.1758683737 → 8.0.9000000000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SystemBundles/98ca5eeb45684e3e5615c766e1d3a956fee53d14cd6c2318098c23c210bd76d7.bundle +13464 -0
- package/SystemBundles/98ca5eeb45684e3e5615c766e1d3a956fee53d14cd6c2318098c23c210bd76d7.map +4638 -0
- package/SystemModules/amzn__react-navigation__stack-8.modules.txt +32 -0
- package/SystemModules/amzn__react-navigation__stack-8.private.modules.txt +92 -0
- package/SystemModules/keplerscript-system-bundle-config.json +4 -4
- package/kepler-compatibility.json +2 -4
- package/lib/module/TransitionConfigs/CardStyleInterpolators.js +57 -1
- package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
- package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +30 -16
- package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
- package/lib/module/TransitionConfigs/TransitionPresets.js +32 -4
- package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
- package/lib/module/TransitionConfigs/TransitionSpecs.js +32 -2
- package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -1
- package/lib/module/index.js +13 -11
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createStackNavigator.js +46 -48
- package/lib/module/navigators/createStackNavigator.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/CardAnimationContext.js +3 -1
- package/lib/module/utils/CardAnimationContext.js.map +1 -1
- package/lib/module/utils/GestureHandlerRefContext.js +3 -1
- package/lib/module/utils/GestureHandlerRefContext.js.map +1 -1
- package/lib/module/utils/ModalPresentationContext.js +3 -2
- package/lib/module/utils/ModalPresentationContext.js.map +1 -1
- package/lib/module/utils/conditional.js +3 -1
- package/lib/module/utils/conditional.js.map +1 -1
- package/lib/module/utils/findLastIndex.js +4 -2
- package/lib/module/utils/findLastIndex.js.map +1 -1
- package/lib/module/utils/gestureActivationCriteria.js +60 -0
- package/lib/module/utils/gestureActivationCriteria.js.map +1 -0
- package/lib/module/utils/getDistanceForDirection.js +5 -3
- package/lib/module/utils/getDistanceForDirection.js.map +1 -1
- package/lib/module/utils/getInvertedMultiplier.js +5 -4
- package/lib/module/utils/getInvertedMultiplier.js.map +1 -1
- package/lib/module/utils/getModalRoutesKeys.js +12 -0
- package/lib/module/utils/getModalRoutesKeys.js.map +1 -0
- package/lib/module/utils/getShadowStyle.js +24 -0
- package/lib/module/utils/getShadowStyle.js.map +1 -0
- package/lib/module/utils/{debounce.js → throttle.js} +5 -4
- package/lib/module/utils/throttle.js.map +1 -0
- package/lib/module/utils/useCardAnimation.js +4 -2
- package/lib/module/utils/useCardAnimation.js.map +1 -1
- package/lib/module/utils/useGestureHandlerRef.js +5 -3
- package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
- package/lib/module/utils/useKeyboardManager.js +8 -6
- package/lib/module/utils/useKeyboardManager.js.map +1 -1
- package/lib/module/views/GestureHandler.android.js +3 -1
- package/lib/module/views/GestureHandler.android.js.map +1 -1
- package/lib/module/views/GestureHandler.ios.js +3 -1
- package/lib/module/views/GestureHandler.ios.js.map +1 -1
- package/lib/module/views/GestureHandler.js +6 -1
- package/lib/module/views/GestureHandler.js.map +1 -1
- package/lib/module/views/GestureHandler.kepler.js +4 -0
- package/lib/module/views/GestureHandler.kepler.js.map +1 -0
- package/lib/module/views/GestureHandlerNative.js +13 -9
- package/lib/module/views/GestureHandlerNative.js.map +1 -1
- package/lib/module/views/Header/Header.js +12 -8
- package/lib/module/views/Header/Header.js.map +1 -1
- package/lib/module/views/Header/HeaderContainer.js +103 -93
- package/lib/module/views/Header/HeaderContainer.js.map +1 -1
- package/lib/module/views/Header/HeaderSegment.js +43 -31
- package/lib/module/views/Header/HeaderSegment.js.map +1 -1
- package/lib/module/views/Screens.js +17 -9
- package/lib/module/views/Screens.js.map +1 -1
- package/lib/module/views/Stack/Card.js +313 -338
- package/lib/module/views/Stack/Card.js.map +1 -1
- package/lib/module/views/Stack/CardA11yWrapper.js +43 -0
- package/lib/module/views/Stack/CardA11yWrapper.js.map +1 -0
- package/lib/module/views/Stack/CardContainer.js +116 -90
- package/lib/module/views/Stack/CardContainer.js.map +1 -1
- package/lib/module/views/Stack/CardContent.js +74 -0
- package/lib/module/views/Stack/CardContent.js.map +1 -0
- package/lib/module/views/Stack/CardStack.js +241 -180
- package/lib/module/views/Stack/CardStack.js.map +1 -1
- package/lib/module/views/Stack/StackView.js +80 -64
- package/lib/module/views/Stack/StackView.js.map +1 -1
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts +8 -0
- package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +1 -1
- package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts +3 -3
- package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -1
- package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts +8 -0
- package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -1
- package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts +10 -0
- package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +8 -8
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createStackNavigator.d.ts +15 -7
- package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +84 -24
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/CardAnimationContext.d.ts +1 -2
- package/lib/typescript/src/utils/CardAnimationContext.d.ts.map +1 -1
- package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts +1 -2
- package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts.map +1 -1
- package/lib/typescript/src/utils/ModalPresentationContext.d.ts +1 -2
- package/lib/typescript/src/utils/ModalPresentationContext.d.ts.map +1 -1
- package/lib/typescript/src/utils/conditional.d.ts +1 -1
- package/lib/typescript/src/utils/conditional.d.ts.map +1 -1
- package/lib/typescript/src/utils/findLastIndex.d.ts +1 -1
- package/lib/typescript/src/utils/findLastIndex.d.ts.map +1 -1
- package/lib/typescript/src/utils/gestureActivationCriteria.d.ts +57 -0
- package/lib/typescript/src/utils/gestureActivationCriteria.d.ts.map +1 -0
- package/lib/typescript/src/utils/getDistanceForDirection.d.ts +1 -1
- package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +1 -1
- package/lib/typescript/src/utils/getInvertedMultiplier.d.ts +1 -1
- package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +1 -1
- package/lib/typescript/src/utils/getModalRoutesKeys.d.ts +4 -0
- package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +1 -0
- package/lib/typescript/src/utils/getShadowStyle.d.ts +27 -0
- package/lib/typescript/src/utils/getShadowStyle.d.ts.map +1 -0
- package/lib/typescript/src/utils/throttle.d.ts +2 -0
- package/lib/typescript/src/utils/throttle.d.ts.map +1 -0
- package/lib/typescript/src/utils/useCardAnimation.d.ts +1 -1
- package/lib/typescript/src/utils/useCardAnimation.d.ts.map +1 -1
- package/lib/typescript/src/utils/useGestureHandlerRef.d.ts +1 -1
- package/lib/typescript/src/utils/useGestureHandlerRef.d.ts.map +1 -1
- package/lib/typescript/src/utils/useKeyboardManager.d.ts +1 -1
- package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +1 -1
- package/lib/typescript/src/views/GestureHandler.d.ts +3 -2
- package/lib/typescript/src/views/GestureHandler.d.ts.map +1 -1
- package/lib/typescript/src/views/GestureHandler.kepler.d.ts +2 -0
- package/lib/typescript/src/views/GestureHandler.kepler.d.ts.map +1 -0
- package/lib/typescript/src/views/GestureHandlerNative.d.ts +4 -5
- package/lib/typescript/src/views/GestureHandlerNative.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/Header.d.ts +1 -2
- package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderContainer.d.ts +4 -5
- package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts +2 -2
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
- package/lib/typescript/src/views/Screens.d.ts +7 -5
- package/lib/typescript/src/views/Screens.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/Card.d.ts +14 -42
- package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts +15 -0
- package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts.map +1 -0
- package/lib/typescript/src/views/Stack/CardContainer.d.ts +6 -8
- package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardContent.d.ts +13 -0
- package/lib/typescript/src/views/Stack/CardContent.d.ts.map +1 -0
- package/lib/typescript/src/views/Stack/CardStack.d.ts +8 -7
- package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/StackView.d.ts +10 -81
- package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TransitionConfigs/CardStyleInterpolators.tsx +72 -6
- package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +43 -25
- package/src/TransitionConfigs/TransitionPresets.tsx +35 -5
- package/src/TransitionConfigs/TransitionSpecs.tsx +30 -2
- package/src/index.tsx +12 -7
- package/src/navigators/createStackNavigator.tsx +47 -63
- package/src/types.tsx +116 -24
- package/src/utils/CardAnimationContext.tsx +3 -3
- package/src/utils/GestureHandlerRefContext.tsx +2 -2
- package/src/utils/ModalPresentationContext.tsx +1 -3
- package/src/utils/conditional.tsx +1 -1
- package/src/utils/findLastIndex.tsx +2 -5
- package/src/utils/gestureActivationCriteria.tsx +70 -0
- package/src/utils/getDistanceForDirection.tsx +5 -4
- package/src/utils/getInvertedMultiplier.tsx +5 -6
- package/src/utils/getModalRoutesKeys.ts +21 -0
- package/src/utils/getShadowStyle.tsx +37 -0
- package/src/utils/throttle.tsx +16 -0
- package/src/utils/useCardAnimation.tsx +2 -2
- package/src/utils/useGestureHandlerRef.tsx +3 -3
- package/src/utils/useKeyboardManager.tsx +5 -7
- package/src/views/GestureHandler.kepler.tsx +1 -0
- package/src/views/GestureHandler.tsx +2 -2
- package/src/views/GestureHandlerNative.tsx +5 -5
- package/src/views/Header/Header.tsx +8 -7
- package/src/views/Header/HeaderContainer.tsx +23 -18
- package/src/views/Header/HeaderSegment.tsx +41 -43
- package/src/views/Screens.tsx +4 -2
- package/src/views/Stack/Card.tsx +480 -462
- package/src/views/Stack/CardA11yWrapper.tsx +67 -0
- package/src/views/Stack/CardContainer.tsx +127 -108
- package/src/views/Stack/CardContent.tsx +92 -0
- package/src/views/Stack/CardStack.tsx +370 -243
- package/src/views/Stack/StackView.tsx +73 -62
- package/SystemBundles/b598f9dfffcd611d6cd7d6a3c5ab3d66234659a03b40b6579fddb628e61b8313.bundle +0 -28538
- package/SystemBundles/b598f9dfffcd611d6cd7d6a3c5ab3d66234659a03b40b6579fddb628e61b8313.map +0 -1
- package/SystemModules/amzn__react-navigation__stack-7.modules.txt +0 -95
- package/SystemModules/amzn__react-navigation__stack-7.private.modules.txt +0 -185
- package/THIRD_PARTY_NOTICES.txt +0 -24
- package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js +0 -353
- package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js.map +0 -1
- package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js +0 -259
- package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js.map +0 -1
- package/lib/commonjs/TransitionConfigs/TransitionPresets.js +0 -134
- package/lib/commonjs/TransitionConfigs/TransitionPresets.js.map +0 -1
- package/lib/commonjs/TransitionConfigs/TransitionSpecs.js +0 -100
- package/lib/commonjs/TransitionConfigs/TransitionSpecs.js.map +0 -1
- package/lib/commonjs/index.js +0 -69
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/navigators/createStackNavigator.js +0 -82
- package/lib/commonjs/navigators/createStackNavigator.js.map +0 -1
- package/lib/commonjs/types.js +0 -6
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/CardAnimationContext.js +0 -11
- package/lib/commonjs/utils/CardAnimationContext.js.map +0 -1
- package/lib/commonjs/utils/GestureHandlerRefContext.js +0 -11
- package/lib/commonjs/utils/GestureHandlerRefContext.js.map +0 -1
- package/lib/commonjs/utils/ModalPresentationContext.js +0 -12
- package/lib/commonjs/utils/ModalPresentationContext.js.map +0 -1
- package/lib/commonjs/utils/conditional.js +0 -32
- package/lib/commonjs/utils/conditional.js.map +0 -1
- package/lib/commonjs/utils/debounce.js +0 -19
- package/lib/commonjs/utils/debounce.js.map +0 -1
- package/lib/commonjs/utils/findLastIndex.js +0 -15
- package/lib/commonjs/utils/findLastIndex.js.map +0 -1
- package/lib/commonjs/utils/getDistanceForDirection.js +0 -20
- package/lib/commonjs/utils/getDistanceForDirection.js.map +0 -1
- package/lib/commonjs/utils/getInvertedMultiplier.js +0 -20
- package/lib/commonjs/utils/getInvertedMultiplier.js.map +0 -1
- package/lib/commonjs/utils/memoize.js +0 -33
- package/lib/commonjs/utils/memoize.js.map +0 -1
- package/lib/commonjs/utils/useCardAnimation.js +0 -19
- package/lib/commonjs/utils/useCardAnimation.js.map +0 -1
- package/lib/commonjs/utils/useGestureHandlerRef.js +0 -19
- package/lib/commonjs/utils/useGestureHandlerRef.js.map +0 -1
- package/lib/commonjs/utils/useKeyboardManager.js +0 -96
- package/lib/commonjs/utils/useKeyboardManager.js.map +0 -1
- package/lib/commonjs/views/GestureHandler.android.js +0 -17
- package/lib/commonjs/views/GestureHandler.android.js.map +0 -1
- package/lib/commonjs/views/GestureHandler.ios.js +0 -17
- package/lib/commonjs/views/GestureHandler.ios.js.map +0 -1
- package/lib/commonjs/views/GestureHandler.js +0 -24
- package/lib/commonjs/views/GestureHandler.js.map +0 -1
- package/lib/commonjs/views/GestureHandlerNative.js +0 -34
- package/lib/commonjs/views/GestureHandlerNative.js.map +0 -1
- package/lib/commonjs/views/Header/Header.js +0 -61
- package/lib/commonjs/views/Header/Header.js.map +0 -1
- package/lib/commonjs/views/Header/HeaderContainer.js +0 -127
- package/lib/commonjs/views/Header/HeaderContainer.js.map +0 -1
- package/lib/commonjs/views/Header/HeaderSegment.js +0 -139
- package/lib/commonjs/views/Header/HeaderSegment.js.map +0 -1
- package/lib/commonjs/views/ModalStatusBarManager.js +0 -42
- package/lib/commonjs/views/ModalStatusBarManager.js.map +0 -1
- package/lib/commonjs/views/Screens.js +0 -44
- package/lib/commonjs/views/Screens.js.map +0 -1
- package/lib/commonjs/views/Stack/Card.js +0 -469
- package/lib/commonjs/views/Stack/Card.js.map +0 -1
- package/lib/commonjs/views/Stack/CardContainer.js +0 -259
- package/lib/commonjs/views/Stack/CardContainer.js.map +0 -1
- package/lib/commonjs/views/Stack/CardSheet.js +0 -54
- package/lib/commonjs/views/Stack/CardSheet.js.map +0 -1
- package/lib/commonjs/views/Stack/CardStack.js +0 -442
- package/lib/commonjs/views/Stack/CardStack.js.map +0 -1
- package/lib/commonjs/views/Stack/StackView.js +0 -333
- package/lib/commonjs/views/Stack/StackView.js.map +0 -1
- package/lib/module/utils/debounce.js.map +0 -1
- package/lib/module/utils/memoize.js +0 -27
- package/lib/module/utils/memoize.js.map +0 -1
- package/lib/module/views/ModalStatusBarManager.js +0 -34
- package/lib/module/views/ModalStatusBarManager.js.map +0 -1
- package/lib/module/views/Stack/CardSheet.js +0 -46
- package/lib/module/views/Stack/CardSheet.js.map +0 -1
- package/lib/typescript/src/utils/debounce.d.ts +0 -2
- package/lib/typescript/src/utils/debounce.d.ts.map +0 -1
- package/lib/typescript/src/utils/memoize.d.ts +0 -2
- package/lib/typescript/src/utils/memoize.d.ts.map +0 -1
- package/lib/typescript/src/views/ModalStatusBarManager.d.ts +0 -12
- package/lib/typescript/src/views/ModalStatusBarManager.d.ts.map +0 -1
- package/lib/typescript/src/views/Stack/CardSheet.d.ts +0 -15
- package/lib/typescript/src/views/Stack/CardSheet.d.ts.map +0 -1
- package/src/utils/debounce.tsx +0 -17
- package/src/utils/memoize.tsx +0 -33
- package/src/views/ModalStatusBarManager.tsx +0 -50
- package/src/views/Stack/CardSheet.tsx +0 -61
|
@@ -3,34 +3,41 @@ import {
|
|
|
3
3
|
SafeAreaProviderCompat,
|
|
4
4
|
} from '@amazon-devices/react-navigation__elements';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
CommonActions,
|
|
7
|
+
type LocaleDirection,
|
|
8
|
+
type ParamListBase,
|
|
9
|
+
type Route,
|
|
10
|
+
type RouteProp,
|
|
8
11
|
StackActions,
|
|
9
|
-
StackNavigationState,
|
|
12
|
+
type StackNavigationState,
|
|
10
13
|
} from '@amazon-devices/react-navigation__native';
|
|
11
14
|
import * as React from 'react';
|
|
12
15
|
import { StyleSheet, View } from 'react-native';
|
|
13
|
-
import {
|
|
14
|
-
EdgeInsets,
|
|
15
|
-
SafeAreaInsetsContext,
|
|
16
|
-
} from '@amazon-devices/react-native-safe-area-context';
|
|
16
|
+
import { SafeAreaInsetsContext } from '@amazon-devices/react-native-safe-area-context';
|
|
17
17
|
|
|
18
18
|
import type {
|
|
19
|
+
StackDescriptor,
|
|
19
20
|
StackDescriptorMap,
|
|
20
21
|
StackNavigationConfig,
|
|
21
22
|
StackNavigationHelpers,
|
|
22
23
|
} from '../../types';
|
|
23
|
-
import ModalPresentationContext from '../../utils/ModalPresentationContext';
|
|
24
|
+
import { ModalPresentationContext } from '../../utils/ModalPresentationContext';
|
|
24
25
|
import { GestureHandlerRootView } from '../GestureHandler';
|
|
25
|
-
import
|
|
26
|
-
|
|
26
|
+
import {
|
|
27
|
+
HeaderContainer,
|
|
28
|
+
type Props as HeaderContainerProps,
|
|
27
29
|
} from '../Header/HeaderContainer';
|
|
28
|
-
import CardStack from './CardStack';
|
|
30
|
+
import { CardStack, getAnimationEnabled } from './CardStack';
|
|
29
31
|
|
|
30
32
|
type Props = StackNavigationConfig & {
|
|
33
|
+
direction: LocaleDirection;
|
|
31
34
|
state: StackNavigationState<ParamListBase>;
|
|
32
35
|
navigation: StackNavigationHelpers;
|
|
33
36
|
descriptors: StackDescriptorMap;
|
|
37
|
+
describe: (
|
|
38
|
+
route: RouteProp<ParamListBase>,
|
|
39
|
+
placeholder: boolean
|
|
40
|
+
) => StackDescriptor;
|
|
34
41
|
};
|
|
35
42
|
|
|
36
43
|
type State = {
|
|
@@ -58,9 +65,9 @@ const GestureHandlerWrapper = GestureHandlerRootView ?? View;
|
|
|
58
65
|
* We need to make sure that both values and order match.
|
|
59
66
|
*/
|
|
60
67
|
const isArrayEqual = (a: any[], b: any[]) =>
|
|
61
|
-
a.length === b.length && a.every((it, index) => it
|
|
68
|
+
a.length === b.length && a.every((it, index) => Object.is(it, b[index]));
|
|
62
69
|
|
|
63
|
-
export
|
|
70
|
+
export class StackView extends React.Component<Props, State> {
|
|
64
71
|
static getDerivedStateFromProps(
|
|
65
72
|
props: Readonly<Props>,
|
|
66
73
|
state: Readonly<State>
|
|
@@ -123,12 +130,9 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
123
130
|
: props.state.routes;
|
|
124
131
|
|
|
125
132
|
// Now we need to determine which routes were added and removed
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
replacingRouteKeys,
|
|
130
|
-
previousRoutes,
|
|
131
|
-
} = state;
|
|
133
|
+
const { previousRoutes } = state;
|
|
134
|
+
|
|
135
|
+
let { openingRouteKeys, closingRouteKeys, replacingRouteKeys } = state;
|
|
132
136
|
|
|
133
137
|
const previousFocusedRoute = previousRoutes[previousRoutes.length - 1] as
|
|
134
138
|
| Route<string>
|
|
@@ -138,7 +142,7 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
138
142
|
const isAnimationEnabled = (key: string) => {
|
|
139
143
|
const descriptor = props.descriptors[key] || state.descriptors[key];
|
|
140
144
|
|
|
141
|
-
return descriptor
|
|
145
|
+
return getAnimationEnabled(descriptor?.options.animation);
|
|
142
146
|
};
|
|
143
147
|
|
|
144
148
|
const getAnimationTypeForReplace = (key: string) => {
|
|
@@ -154,9 +158,35 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
154
158
|
// We only need to animate routes if the focused route changed
|
|
155
159
|
// Animating previous routes won't be visible coz the focused route is on top of everything
|
|
156
160
|
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
if (
|
|
162
|
+
previousRoutes.some((r) => r.key === nextFocusedRoute.key) &&
|
|
163
|
+
!routes.some((r) => r.key === previousFocusedRoute.key)
|
|
164
|
+
) {
|
|
165
|
+
// The previously focused route was removed, and the new focused route was already present
|
|
166
|
+
// We treat this as a pop
|
|
167
|
+
|
|
168
|
+
if (
|
|
169
|
+
isAnimationEnabled(previousFocusedRoute.key) &&
|
|
170
|
+
!closingRouteKeys.includes(previousFocusedRoute.key)
|
|
171
|
+
) {
|
|
172
|
+
closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];
|
|
173
|
+
|
|
174
|
+
// Sometimes a route can be closed before the opening animation finishes
|
|
175
|
+
// So we also need to remove it from the opening list
|
|
176
|
+
openingRouteKeys = openingRouteKeys.filter(
|
|
177
|
+
(key) => key !== previousFocusedRoute.key
|
|
178
|
+
);
|
|
179
|
+
replacingRouteKeys = replacingRouteKeys.filter(
|
|
180
|
+
(key) => key !== previousFocusedRoute.key
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
// Keep a copy of route being removed in the state to be able to animate it
|
|
184
|
+
routes = [...routes, previousFocusedRoute];
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
// A route has come to the focus, we treat this as a push
|
|
188
|
+
// A replace or rearranging can also trigger this
|
|
189
|
+
// The animation should look like push
|
|
160
190
|
|
|
161
191
|
if (
|
|
162
192
|
isAnimationEnabled(nextFocusedRoute.key) &&
|
|
@@ -213,31 +243,6 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
213
243
|
}
|
|
214
244
|
}
|
|
215
245
|
}
|
|
216
|
-
} else if (!routes.some((r) => r.key === previousFocusedRoute.key)) {
|
|
217
|
-
// The previously focused route was removed, we treat this as a pop
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
isAnimationEnabled(previousFocusedRoute.key) &&
|
|
221
|
-
!closingRouteKeys.includes(previousFocusedRoute.key)
|
|
222
|
-
) {
|
|
223
|
-
closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];
|
|
224
|
-
|
|
225
|
-
// Sometimes a route can be closed before the opening animation finishes
|
|
226
|
-
// So we also need to remove it from the opening list
|
|
227
|
-
openingRouteKeys = openingRouteKeys.filter(
|
|
228
|
-
(key) => key !== previousFocusedRoute.key
|
|
229
|
-
);
|
|
230
|
-
replacingRouteKeys = replacingRouteKeys.filter(
|
|
231
|
-
(key) => key !== previousFocusedRoute.key
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
// Keep a copy of route being removed in the state to be able to animate it
|
|
235
|
-
routes = [...routes, previousFocusedRoute];
|
|
236
|
-
}
|
|
237
|
-
} else {
|
|
238
|
-
// Looks like some routes were re-arranged and no focused routes were added/removed
|
|
239
|
-
// i.e. the currently focused route already existed and the previously focused route still exists
|
|
240
|
-
// We don't know how to animate this
|
|
241
246
|
}
|
|
242
247
|
} else if (replacingRouteKeys.length || closingRouteKeys.length) {
|
|
243
248
|
// Keep the routes we are closing or replacing if animation is enabled for them
|
|
@@ -301,17 +306,6 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
301
306
|
return routes[index - 1];
|
|
302
307
|
};
|
|
303
308
|
|
|
304
|
-
private renderScene = ({ route }: { route: Route<string> }) => {
|
|
305
|
-
const descriptor =
|
|
306
|
-
this.state.descriptors[route.key] || this.props.descriptors[route.key];
|
|
307
|
-
|
|
308
|
-
if (!descriptor) {
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return descriptor.render();
|
|
313
|
-
};
|
|
314
|
-
|
|
315
309
|
private renderHeader = (props: HeaderContainerProps) => {
|
|
316
310
|
return <HeaderContainer {...props} />;
|
|
317
311
|
};
|
|
@@ -328,7 +322,18 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
328
322
|
) {
|
|
329
323
|
// If route isn't present in current state, but was closing, assume that a close animation was cancelled
|
|
330
324
|
// So we need to add this route back to the state
|
|
331
|
-
navigation.
|
|
325
|
+
navigation.dispatch((state) => {
|
|
326
|
+
const routes = [
|
|
327
|
+
...state.routes.filter((r) => r.key !== route.key),
|
|
328
|
+
route,
|
|
329
|
+
];
|
|
330
|
+
|
|
331
|
+
return CommonActions.reset({
|
|
332
|
+
...state,
|
|
333
|
+
routes,
|
|
334
|
+
index: routes.length - 1,
|
|
335
|
+
});
|
|
336
|
+
});
|
|
332
337
|
} else {
|
|
333
338
|
this.setState((state) => ({
|
|
334
339
|
routes: state.replacingRouteKeys.length
|
|
@@ -425,6 +430,12 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
425
430
|
const { routes, descriptors, openingRouteKeys, closingRouteKeys } =
|
|
426
431
|
this.state;
|
|
427
432
|
|
|
433
|
+
const preloadedDescriptors =
|
|
434
|
+
state.preloadedRoutes.reduce<StackDescriptorMap>((acc, route) => {
|
|
435
|
+
acc[route.key] = acc[route.key] || this.props.describe(route, true);
|
|
436
|
+
return acc;
|
|
437
|
+
}, {});
|
|
438
|
+
|
|
428
439
|
return (
|
|
429
440
|
<GestureHandlerWrapper style={styles.container}>
|
|
430
441
|
<SafeAreaProviderCompat>
|
|
@@ -435,7 +446,7 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
435
446
|
<HeaderShownContext.Consumer>
|
|
436
447
|
{(isParentHeaderShown) => (
|
|
437
448
|
<CardStack
|
|
438
|
-
insets={insets
|
|
449
|
+
insets={insets!}
|
|
439
450
|
isParentHeaderShown={isParentHeaderShown}
|
|
440
451
|
isParentModal={isParentModal}
|
|
441
452
|
getPreviousRoute={this.getPreviousRoute}
|
|
@@ -447,12 +458,12 @@ export default class StackView extends React.Component<Props, State> {
|
|
|
447
458
|
onTransitionStart={this.handleTransitionStart}
|
|
448
459
|
onTransitionEnd={this.handleTransitionEnd}
|
|
449
460
|
renderHeader={this.renderHeader}
|
|
450
|
-
renderScene={this.renderScene}
|
|
451
461
|
state={state}
|
|
452
462
|
descriptors={descriptors}
|
|
453
463
|
onGestureStart={this.handleGestureStart}
|
|
454
464
|
onGestureEnd={this.handleGestureEnd}
|
|
455
465
|
onGestureCancel={this.handleGestureCancel}
|
|
466
|
+
preloadedDescriptors={preloadedDescriptors}
|
|
456
467
|
{...rest}
|
|
457
468
|
/>
|
|
458
469
|
)}
|