@amazon-devices/react-navigation__stack 7.0.9000000000 → 8.0.9000000000-rn-83

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.
Files changed (275) hide show
  1. package/SystemBundles/03e0ad8b8bcf16e659904adab730cbe9c1832c4a36017809f129fea7fb07b4fc.bundle +13453 -0
  2. package/SystemBundles/03e0ad8b8bcf16e659904adab730cbe9c1832c4a36017809f129fea7fb07b4fc.map +4627 -0
  3. package/SystemModules/amzn__react-navigation__stack-8.modules.txt +32 -0
  4. package/SystemModules/amzn__react-navigation__stack-8.private.modules.txt +91 -0
  5. package/SystemModules/keplerscript-system-bundle-config.json +4 -4
  6. package/kepler-compatibility.json +2 -2
  7. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +57 -1
  8. package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  9. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +30 -16
  10. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
  11. package/lib/module/TransitionConfigs/TransitionPresets.js +32 -4
  12. package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
  13. package/lib/module/TransitionConfigs/TransitionSpecs.js +32 -2
  14. package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -1
  15. package/lib/module/index.js +13 -11
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/module/navigators/createStackNavigator.js +46 -48
  18. package/lib/module/navigators/createStackNavigator.js.map +1 -1
  19. package/lib/module/package.json +1 -0
  20. package/lib/module/types.js +2 -0
  21. package/lib/module/types.js.map +1 -1
  22. package/lib/module/utils/CardAnimationContext.js +3 -1
  23. package/lib/module/utils/CardAnimationContext.js.map +1 -1
  24. package/lib/module/utils/GestureHandlerRefContext.js +3 -1
  25. package/lib/module/utils/GestureHandlerRefContext.js.map +1 -1
  26. package/lib/module/utils/ModalPresentationContext.js +3 -2
  27. package/lib/module/utils/ModalPresentationContext.js.map +1 -1
  28. package/lib/module/utils/conditional.js +3 -1
  29. package/lib/module/utils/conditional.js.map +1 -1
  30. package/lib/module/utils/findLastIndex.js +4 -2
  31. package/lib/module/utils/findLastIndex.js.map +1 -1
  32. package/lib/module/utils/gestureActivationCriteria.js +60 -0
  33. package/lib/module/utils/gestureActivationCriteria.js.map +1 -0
  34. package/lib/module/utils/getDistanceForDirection.js +5 -3
  35. package/lib/module/utils/getDistanceForDirection.js.map +1 -1
  36. package/lib/module/utils/getInvertedMultiplier.js +5 -4
  37. package/lib/module/utils/getInvertedMultiplier.js.map +1 -1
  38. package/lib/module/utils/getModalRoutesKeys.js +12 -0
  39. package/lib/module/utils/getModalRoutesKeys.js.map +1 -0
  40. package/lib/module/utils/getShadowStyle.js +24 -0
  41. package/lib/module/utils/getShadowStyle.js.map +1 -0
  42. package/lib/module/utils/{debounce.js → throttle.js} +5 -4
  43. package/lib/module/utils/throttle.js.map +1 -0
  44. package/lib/module/utils/useCardAnimation.js +4 -2
  45. package/lib/module/utils/useCardAnimation.js.map +1 -1
  46. package/lib/module/utils/useGestureHandlerRef.js +5 -3
  47. package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
  48. package/lib/module/utils/useKeyboardManager.js +8 -6
  49. package/lib/module/utils/useKeyboardManager.js.map +1 -1
  50. package/lib/module/views/GestureHandler.android.js +3 -1
  51. package/lib/module/views/GestureHandler.android.js.map +1 -1
  52. package/lib/module/views/GestureHandler.ios.js +3 -1
  53. package/lib/module/views/GestureHandler.ios.js.map +1 -1
  54. package/lib/module/views/GestureHandler.js +6 -1
  55. package/lib/module/views/GestureHandler.js.map +1 -1
  56. package/lib/module/views/GestureHandler.kepler.js +4 -0
  57. package/lib/module/views/GestureHandler.kepler.js.map +1 -0
  58. package/lib/module/views/GestureHandlerNative.js +13 -9
  59. package/lib/module/views/GestureHandlerNative.js.map +1 -1
  60. package/lib/module/views/Header/Header.js +12 -8
  61. package/lib/module/views/Header/Header.js.map +1 -1
  62. package/lib/module/views/Header/HeaderContainer.js +103 -93
  63. package/lib/module/views/Header/HeaderContainer.js.map +1 -1
  64. package/lib/module/views/Header/HeaderSegment.js +43 -31
  65. package/lib/module/views/Header/HeaderSegment.js.map +1 -1
  66. package/lib/module/views/Screens.js +17 -9
  67. package/lib/module/views/Screens.js.map +1 -1
  68. package/lib/module/views/Stack/Card.js +313 -338
  69. package/lib/module/views/Stack/Card.js.map +1 -1
  70. package/lib/module/views/Stack/CardA11yWrapper.js +43 -0
  71. package/lib/module/views/Stack/CardA11yWrapper.js.map +1 -0
  72. package/lib/module/views/Stack/CardContainer.js +116 -90
  73. package/lib/module/views/Stack/CardContainer.js.map +1 -1
  74. package/lib/module/views/Stack/CardContent.js +74 -0
  75. package/lib/module/views/Stack/CardContent.js.map +1 -0
  76. package/lib/module/views/Stack/CardStack.js +246 -181
  77. package/lib/module/views/Stack/CardStack.js.map +1 -1
  78. package/lib/module/views/Stack/StackView.js +80 -64
  79. package/lib/module/views/Stack/StackView.js.map +1 -1
  80. package/lib/typescript/package.json +1 -0
  81. package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts +8 -0
  82. package/lib/typescript/src/TransitionConfigs/CardStyleInterpolators.d.ts.map +1 -1
  83. package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts +3 -3
  84. package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -1
  85. package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts +8 -0
  86. package/lib/typescript/src/TransitionConfigs/TransitionPresets.d.ts.map +1 -1
  87. package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts +10 -0
  88. package/lib/typescript/src/TransitionConfigs/TransitionSpecs.d.ts.map +1 -1
  89. package/lib/typescript/src/index.d.ts +8 -8
  90. package/lib/typescript/src/index.d.ts.map +1 -1
  91. package/lib/typescript/src/navigators/createStackNavigator.d.ts +15 -7
  92. package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
  93. package/lib/typescript/src/types.d.ts +84 -24
  94. package/lib/typescript/src/types.d.ts.map +1 -1
  95. package/lib/typescript/src/utils/CardAnimationContext.d.ts +1 -2
  96. package/lib/typescript/src/utils/CardAnimationContext.d.ts.map +1 -1
  97. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts +1 -2
  98. package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts.map +1 -1
  99. package/lib/typescript/src/utils/ModalPresentationContext.d.ts +1 -2
  100. package/lib/typescript/src/utils/ModalPresentationContext.d.ts.map +1 -1
  101. package/lib/typescript/src/utils/conditional.d.ts +1 -1
  102. package/lib/typescript/src/utils/conditional.d.ts.map +1 -1
  103. package/lib/typescript/src/utils/findLastIndex.d.ts +1 -1
  104. package/lib/typescript/src/utils/findLastIndex.d.ts.map +1 -1
  105. package/lib/typescript/src/utils/gestureActivationCriteria.d.ts +57 -0
  106. package/lib/typescript/src/utils/gestureActivationCriteria.d.ts.map +1 -0
  107. package/lib/typescript/src/utils/getDistanceForDirection.d.ts +1 -1
  108. package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +1 -1
  109. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts +1 -1
  110. package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +1 -1
  111. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts +4 -0
  112. package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +1 -0
  113. package/lib/typescript/src/utils/getShadowStyle.d.ts +27 -0
  114. package/lib/typescript/src/utils/getShadowStyle.d.ts.map +1 -0
  115. package/lib/typescript/src/utils/throttle.d.ts +2 -0
  116. package/lib/typescript/src/utils/throttle.d.ts.map +1 -0
  117. package/lib/typescript/src/utils/useCardAnimation.d.ts +1 -1
  118. package/lib/typescript/src/utils/useCardAnimation.d.ts.map +1 -1
  119. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts +1 -1
  120. package/lib/typescript/src/utils/useGestureHandlerRef.d.ts.map +1 -1
  121. package/lib/typescript/src/utils/useKeyboardManager.d.ts +1 -1
  122. package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +1 -1
  123. package/lib/typescript/src/views/GestureHandler.d.ts +3 -2
  124. package/lib/typescript/src/views/GestureHandler.d.ts.map +1 -1
  125. package/lib/typescript/src/views/GestureHandler.kepler.d.ts +2 -0
  126. package/lib/typescript/src/views/GestureHandler.kepler.d.ts.map +1 -0
  127. package/lib/typescript/src/views/GestureHandlerNative.d.ts +4 -5
  128. package/lib/typescript/src/views/GestureHandlerNative.d.ts.map +1 -1
  129. package/lib/typescript/src/views/Header/Header.d.ts +1 -2
  130. package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
  131. package/lib/typescript/src/views/Header/HeaderContainer.d.ts +4 -5
  132. package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
  133. package/lib/typescript/src/views/Header/HeaderSegment.d.ts +2 -2
  134. package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
  135. package/lib/typescript/src/views/Screens.d.ts +7 -5
  136. package/lib/typescript/src/views/Screens.d.ts.map +1 -1
  137. package/lib/typescript/src/views/Stack/Card.d.ts +14 -42
  138. package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
  139. package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts +15 -0
  140. package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts.map +1 -0
  141. package/lib/typescript/src/views/Stack/CardContainer.d.ts +6 -8
  142. package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
  143. package/lib/typescript/src/views/Stack/CardContent.d.ts +13 -0
  144. package/lib/typescript/src/views/Stack/CardContent.d.ts.map +1 -0
  145. package/lib/typescript/src/views/Stack/CardStack.d.ts +8 -7
  146. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
  147. package/lib/typescript/src/views/Stack/StackView.d.ts +10 -81
  148. package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
  149. package/oss-attribution/attribution.txt +76 -0
  150. package/oss-attribution/licenseInfos.json +27 -0
  151. package/package.json +105 -1
  152. package/src/TransitionConfigs/CardStyleInterpolators.tsx +72 -6
  153. package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +43 -25
  154. package/src/TransitionConfigs/TransitionPresets.tsx +35 -5
  155. package/src/TransitionConfigs/TransitionSpecs.tsx +30 -2
  156. package/src/index.tsx +12 -7
  157. package/src/navigators/createStackNavigator.tsx +47 -63
  158. package/src/types.tsx +116 -24
  159. package/src/utils/CardAnimationContext.tsx +3 -3
  160. package/src/utils/GestureHandlerRefContext.tsx +2 -2
  161. package/src/utils/ModalPresentationContext.tsx +1 -3
  162. package/src/utils/conditional.tsx +1 -1
  163. package/src/utils/findLastIndex.tsx +2 -5
  164. package/src/utils/gestureActivationCriteria.tsx +70 -0
  165. package/src/utils/getDistanceForDirection.tsx +5 -4
  166. package/src/utils/getInvertedMultiplier.tsx +5 -6
  167. package/src/utils/getModalRoutesKeys.ts +21 -0
  168. package/src/utils/getShadowStyle.tsx +37 -0
  169. package/src/utils/throttle.tsx +16 -0
  170. package/src/utils/useCardAnimation.tsx +2 -2
  171. package/src/utils/useGestureHandlerRef.tsx +3 -3
  172. package/src/utils/useKeyboardManager.tsx +5 -7
  173. package/src/views/GestureHandler.kepler.tsx +1 -0
  174. package/src/views/GestureHandler.tsx +2 -2
  175. package/src/views/GestureHandlerNative.tsx +5 -5
  176. package/src/views/Header/Header.tsx +8 -7
  177. package/src/views/Header/HeaderContainer.tsx +23 -18
  178. package/src/views/Header/HeaderSegment.tsx +41 -43
  179. package/src/views/Screens.tsx +4 -2
  180. package/src/views/Stack/Card.tsx +480 -462
  181. package/src/views/Stack/CardA11yWrapper.tsx +67 -0
  182. package/src/views/Stack/CardContainer.tsx +127 -108
  183. package/src/views/Stack/CardContent.tsx +92 -0
  184. package/src/views/Stack/CardStack.tsx +375 -243
  185. package/src/views/Stack/StackView.tsx +73 -62
  186. package/SystemBundles/c55a41e7975f46f901d6afe3b0331d043bdbf1f54f96209de0215cf6f6fd5377.bundle +0 -28130
  187. package/SystemBundles/c55a41e7975f46f901d6afe3b0331d043bdbf1f54f96209de0215cf6f6fd5377.map +0 -8489
  188. package/SystemModules/amzn__react-navigation__stack-7.modules.txt +0 -95
  189. package/SystemModules/amzn__react-navigation__stack-7.private.modules.txt +0 -191
  190. package/THIRD_PARTY_NOTICES.txt +0 -24
  191. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js +0 -353
  192. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js.map +0 -1
  193. package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js +0 -259
  194. package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js.map +0 -1
  195. package/lib/commonjs/TransitionConfigs/TransitionPresets.js +0 -134
  196. package/lib/commonjs/TransitionConfigs/TransitionPresets.js.map +0 -1
  197. package/lib/commonjs/TransitionConfigs/TransitionSpecs.js +0 -100
  198. package/lib/commonjs/TransitionConfigs/TransitionSpecs.js.map +0 -1
  199. package/lib/commonjs/index.js +0 -69
  200. package/lib/commonjs/index.js.map +0 -1
  201. package/lib/commonjs/navigators/createStackNavigator.js +0 -82
  202. package/lib/commonjs/navigators/createStackNavigator.js.map +0 -1
  203. package/lib/commonjs/types.js +0 -6
  204. package/lib/commonjs/types.js.map +0 -1
  205. package/lib/commonjs/utils/CardAnimationContext.js +0 -11
  206. package/lib/commonjs/utils/CardAnimationContext.js.map +0 -1
  207. package/lib/commonjs/utils/GestureHandlerRefContext.js +0 -11
  208. package/lib/commonjs/utils/GestureHandlerRefContext.js.map +0 -1
  209. package/lib/commonjs/utils/ModalPresentationContext.js +0 -12
  210. package/lib/commonjs/utils/ModalPresentationContext.js.map +0 -1
  211. package/lib/commonjs/utils/conditional.js +0 -32
  212. package/lib/commonjs/utils/conditional.js.map +0 -1
  213. package/lib/commonjs/utils/debounce.js +0 -19
  214. package/lib/commonjs/utils/debounce.js.map +0 -1
  215. package/lib/commonjs/utils/findLastIndex.js +0 -15
  216. package/lib/commonjs/utils/findLastIndex.js.map +0 -1
  217. package/lib/commonjs/utils/getDistanceForDirection.js +0 -20
  218. package/lib/commonjs/utils/getDistanceForDirection.js.map +0 -1
  219. package/lib/commonjs/utils/getInvertedMultiplier.js +0 -20
  220. package/lib/commonjs/utils/getInvertedMultiplier.js.map +0 -1
  221. package/lib/commonjs/utils/memoize.js +0 -33
  222. package/lib/commonjs/utils/memoize.js.map +0 -1
  223. package/lib/commonjs/utils/useCardAnimation.js +0 -19
  224. package/lib/commonjs/utils/useCardAnimation.js.map +0 -1
  225. package/lib/commonjs/utils/useGestureHandlerRef.js +0 -19
  226. package/lib/commonjs/utils/useGestureHandlerRef.js.map +0 -1
  227. package/lib/commonjs/utils/useKeyboardManager.js +0 -96
  228. package/lib/commonjs/utils/useKeyboardManager.js.map +0 -1
  229. package/lib/commonjs/views/GestureHandler.android.js +0 -17
  230. package/lib/commonjs/views/GestureHandler.android.js.map +0 -1
  231. package/lib/commonjs/views/GestureHandler.ios.js +0 -17
  232. package/lib/commonjs/views/GestureHandler.ios.js.map +0 -1
  233. package/lib/commonjs/views/GestureHandler.js +0 -24
  234. package/lib/commonjs/views/GestureHandler.js.map +0 -1
  235. package/lib/commonjs/views/GestureHandlerNative.js +0 -34
  236. package/lib/commonjs/views/GestureHandlerNative.js.map +0 -1
  237. package/lib/commonjs/views/Header/Header.js +0 -61
  238. package/lib/commonjs/views/Header/Header.js.map +0 -1
  239. package/lib/commonjs/views/Header/HeaderContainer.js +0 -127
  240. package/lib/commonjs/views/Header/HeaderContainer.js.map +0 -1
  241. package/lib/commonjs/views/Header/HeaderSegment.js +0 -139
  242. package/lib/commonjs/views/Header/HeaderSegment.js.map +0 -1
  243. package/lib/commonjs/views/ModalStatusBarManager.js +0 -42
  244. package/lib/commonjs/views/ModalStatusBarManager.js.map +0 -1
  245. package/lib/commonjs/views/Screens.js +0 -44
  246. package/lib/commonjs/views/Screens.js.map +0 -1
  247. package/lib/commonjs/views/Stack/Card.js +0 -469
  248. package/lib/commonjs/views/Stack/Card.js.map +0 -1
  249. package/lib/commonjs/views/Stack/CardContainer.js +0 -259
  250. package/lib/commonjs/views/Stack/CardContainer.js.map +0 -1
  251. package/lib/commonjs/views/Stack/CardSheet.js +0 -54
  252. package/lib/commonjs/views/Stack/CardSheet.js.map +0 -1
  253. package/lib/commonjs/views/Stack/CardStack.js +0 -443
  254. package/lib/commonjs/views/Stack/CardStack.js.map +0 -1
  255. package/lib/commonjs/views/Stack/StackView.js +0 -333
  256. package/lib/commonjs/views/Stack/StackView.js.map +0 -1
  257. package/lib/module/utils/debounce.js.map +0 -1
  258. package/lib/module/utils/memoize.js +0 -27
  259. package/lib/module/utils/memoize.js.map +0 -1
  260. package/lib/module/views/ModalStatusBarManager.js +0 -34
  261. package/lib/module/views/ModalStatusBarManager.js.map +0 -1
  262. package/lib/module/views/Stack/CardSheet.js +0 -46
  263. package/lib/module/views/Stack/CardSheet.js.map +0 -1
  264. package/lib/typescript/src/utils/debounce.d.ts +0 -2
  265. package/lib/typescript/src/utils/debounce.d.ts.map +0 -1
  266. package/lib/typescript/src/utils/memoize.d.ts +0 -2
  267. package/lib/typescript/src/utils/memoize.d.ts.map +0 -1
  268. package/lib/typescript/src/views/ModalStatusBarManager.d.ts +0 -12
  269. package/lib/typescript/src/views/ModalStatusBarManager.d.ts.map +0 -1
  270. package/lib/typescript/src/views/Stack/CardSheet.d.ts +0 -15
  271. package/lib/typescript/src/views/Stack/CardSheet.d.ts.map +0 -1
  272. package/src/utils/debounce.tsx +0 -17
  273. package/src/utils/memoize.tsx +0 -33
  274. package/src/views/ModalStatusBarManager.tsx +0 -50
  275. 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
- ParamListBase,
7
- Route,
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 HeaderContainer, {
26
- Props as HeaderContainerProps,
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 === b[index]);
68
+ a.length === b.length && a.every((it, index) => Object.is(it, b[index]));
62
69
 
63
- export default class StackView extends React.Component<Props, State> {
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
- let {
127
- openingRouteKeys,
128
- closingRouteKeys,
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 ? descriptor.options.animationEnabled !== false : true;
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 (!previousRoutes.some((r) => r.key === nextFocusedRoute.key)) {
158
- // A new route has come to the focus, we treat this as a push
159
- // A replace can also trigger this, the animation should look like push
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.navigate(route);
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 as EdgeInsets}
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
  )}