@react-navigation/stack 6.0.11 → 6.1.0

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 (79) hide show
  1. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js +72 -64
  2. package/lib/commonjs/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  3. package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js +37 -32
  4. package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
  5. package/lib/commonjs/TransitionConfigs/TransitionPresets.js +1 -1
  6. package/lib/commonjs/TransitionConfigs/TransitionSpecs.js +1 -1
  7. package/lib/commonjs/index.js +13 -11
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/navigators/createStackNavigator.js +8 -7
  10. package/lib/commonjs/navigators/createStackNavigator.js.map +1 -1
  11. package/lib/commonjs/utils/debounce.js +5 -1
  12. package/lib/commonjs/utils/debounce.js.map +1 -1
  13. package/lib/commonjs/utils/memoize.js +5 -1
  14. package/lib/commonjs/utils/memoize.js.map +1 -1
  15. package/lib/commonjs/views/GestureHandler.js +7 -4
  16. package/lib/commonjs/views/GestureHandler.js.map +1 -1
  17. package/lib/commonjs/views/GestureHandlerNative.js +1 -1
  18. package/lib/commonjs/views/Header/Header.js +10 -9
  19. package/lib/commonjs/views/Header/Header.js.map +1 -1
  20. package/lib/commonjs/views/Header/HeaderContainer.js +10 -9
  21. package/lib/commonjs/views/Header/HeaderContainer.js.map +1 -1
  22. package/lib/commonjs/views/Header/HeaderSegment.js +5 -0
  23. package/lib/commonjs/views/Header/HeaderSegment.js.map +1 -1
  24. package/lib/commonjs/views/ModalStatusBarManager.js +11 -9
  25. package/lib/commonjs/views/ModalStatusBarManager.js.map +1 -1
  26. package/lib/commonjs/views/Screens.js +14 -10
  27. package/lib/commonjs/views/Screens.js.map +1 -1
  28. package/lib/commonjs/views/Stack/Card.js +32 -24
  29. package/lib/commonjs/views/Stack/Card.js.map +1 -1
  30. package/lib/commonjs/views/Stack/CardContainer.js +43 -40
  31. package/lib/commonjs/views/Stack/CardContainer.js.map +1 -1
  32. package/lib/commonjs/views/Stack/CardSheet.js +7 -6
  33. package/lib/commonjs/views/Stack/CardSheet.js.map +1 -1
  34. package/lib/commonjs/views/Stack/CardStack.js +19 -11
  35. package/lib/commonjs/views/Stack/CardStack.js.map +1 -1
  36. package/lib/commonjs/views/Stack/StackView.js +62 -46
  37. package/lib/commonjs/views/Stack/StackView.js.map +1 -1
  38. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +67 -59
  39. package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
  40. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +35 -30
  41. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
  42. package/lib/module/index.js.map +1 -1
  43. package/lib/module/navigators/createStackNavigator.js +8 -7
  44. package/lib/module/navigators/createStackNavigator.js.map +1 -1
  45. package/lib/module/utils/debounce.js +5 -1
  46. package/lib/module/utils/debounce.js.map +1 -1
  47. package/lib/module/utils/memoize.js +5 -1
  48. package/lib/module/utils/memoize.js.map +1 -1
  49. package/lib/module/views/GestureHandler.js +6 -3
  50. package/lib/module/views/GestureHandler.js.map +1 -1
  51. package/lib/module/views/Header/Header.js +10 -9
  52. package/lib/module/views/Header/Header.js.map +1 -1
  53. package/lib/module/views/Header/HeaderContainer.js +10 -9
  54. package/lib/module/views/Header/HeaderContainer.js.map +1 -1
  55. package/lib/module/views/Header/HeaderSegment.js +5 -0
  56. package/lib/module/views/Header/HeaderSegment.js.map +1 -1
  57. package/lib/module/views/ModalStatusBarManager.js +11 -9
  58. package/lib/module/views/ModalStatusBarManager.js.map +1 -1
  59. package/lib/module/views/Screens.js +13 -9
  60. package/lib/module/views/Screens.js.map +1 -1
  61. package/lib/module/views/Stack/Card.js +32 -24
  62. package/lib/module/views/Stack/Card.js.map +1 -1
  63. package/lib/module/views/Stack/CardContainer.js +43 -40
  64. package/lib/module/views/Stack/CardContainer.js.map +1 -1
  65. package/lib/module/views/Stack/CardSheet.js +7 -6
  66. package/lib/module/views/Stack/CardSheet.js.map +1 -1
  67. package/lib/module/views/Stack/CardStack.js +19 -11
  68. package/lib/module/views/Stack/CardStack.js.map +1 -1
  69. package/lib/module/views/Stack/StackView.js +62 -46
  70. package/lib/module/views/Stack/StackView.js.map +1 -1
  71. package/lib/typescript/src/index.d.ts +1 -1
  72. package/lib/typescript/src/types.d.ts +6 -2
  73. package/package.json +9 -9
  74. package/src/index.tsx +1 -0
  75. package/src/types.tsx +6 -1
  76. package/src/views/Header/HeaderSegment.tsx +16 -4
  77. package/src/views/Stack/Card.tsx +1 -1
  78. package/src/views/Stack/CardContainer.tsx +3 -2
  79. package/src/views/Stack/CardStack.tsx +6 -1
@@ -20,8 +20,8 @@ const GestureHandlerWrapper = GestureHandlerRootView !== null && GestureHandlerR
20
20
  const isArrayEqual = (a, b) => a.length === b.length && a.every((it, index) => it === b[index]);
21
21
 
22
22
  export default class StackView extends React.Component {
23
- constructor(...args) {
24
- super(...args);
23
+ constructor() {
24
+ super(...arguments);
25
25
 
26
26
  _defineProperty(this, "state", {
27
27
  routes: [],
@@ -33,9 +33,10 @@ export default class StackView extends React.Component {
33
33
  descriptors: {}
34
34
  });
35
35
 
36
- _defineProperty(this, "getPreviousRoute", ({
37
- route
38
- }) => {
36
+ _defineProperty(this, "getPreviousRoute", _ref => {
37
+ let {
38
+ route
39
+ } = _ref;
39
40
  const {
40
41
  closingRouteKeys,
41
42
  replacingRouteKeys
@@ -45,9 +46,10 @@ export default class StackView extends React.Component {
45
46
  return routes[index - 1];
46
47
  });
47
48
 
48
- _defineProperty(this, "renderScene", ({
49
- route
50
- }) => {
49
+ _defineProperty(this, "renderScene", _ref2 => {
50
+ let {
51
+ route
52
+ } = _ref2;
51
53
  const descriptor = this.state.descriptors[route.key] || this.props.descriptors[route.key];
52
54
 
53
55
  if (!descriptor) {
@@ -61,9 +63,10 @@ export default class StackView extends React.Component {
61
63
  return /*#__PURE__*/React.createElement(HeaderContainer, props);
62
64
  });
63
65
 
64
- _defineProperty(this, "handleOpenRoute", ({
65
- route
66
- }) => {
66
+ _defineProperty(this, "handleOpenRoute", _ref3 => {
67
+ let {
68
+ route
69
+ } = _ref3;
67
70
  const {
68
71
  state,
69
72
  navigation
@@ -87,9 +90,10 @@ export default class StackView extends React.Component {
87
90
  }
88
91
  });
89
92
 
90
- _defineProperty(this, "handleCloseRoute", ({
91
- route
92
- }) => {
93
+ _defineProperty(this, "handleCloseRoute", _ref4 => {
94
+ let {
95
+ route
96
+ } = _ref4;
93
97
  const {
94
98
  state,
95
99
  navigation
@@ -113,47 +117,56 @@ export default class StackView extends React.Component {
113
117
  }
114
118
  });
115
119
 
116
- _defineProperty(this, "handleTransitionStart", ({
117
- route
118
- }, closing) => this.props.navigation.emit({
119
- type: 'transitionStart',
120
- data: {
121
- closing
122
- },
123
- target: route.key
124
- }));
125
-
126
- _defineProperty(this, "handleTransitionEnd", ({
127
- route
128
- }, closing) => this.props.navigation.emit({
129
- type: 'transitionEnd',
130
- data: {
131
- closing
132
- },
133
- target: route.key
134
- }));
135
-
136
- _defineProperty(this, "handleGestureStart", ({
137
- route
138
- }) => {
120
+ _defineProperty(this, "handleTransitionStart", (_ref5, closing) => {
121
+ let {
122
+ route
123
+ } = _ref5;
124
+ return this.props.navigation.emit({
125
+ type: 'transitionStart',
126
+ data: {
127
+ closing
128
+ },
129
+ target: route.key
130
+ });
131
+ });
132
+
133
+ _defineProperty(this, "handleTransitionEnd", (_ref6, closing) => {
134
+ let {
135
+ route
136
+ } = _ref6;
137
+ return this.props.navigation.emit({
138
+ type: 'transitionEnd',
139
+ data: {
140
+ closing
141
+ },
142
+ target: route.key
143
+ });
144
+ });
145
+
146
+ _defineProperty(this, "handleGestureStart", _ref7 => {
147
+ let {
148
+ route
149
+ } = _ref7;
139
150
  this.props.navigation.emit({
140
151
  type: 'gestureStart',
141
152
  target: route.key
142
153
  });
143
154
  });
144
155
 
145
- _defineProperty(this, "handleGestureEnd", ({
146
- route
147
- }) => {
156
+ _defineProperty(this, "handleGestureEnd", _ref8 => {
157
+ let {
158
+ route
159
+ } = _ref8;
148
160
  this.props.navigation.emit({
149
161
  type: 'gestureEnd',
150
162
  target: route.key
151
163
  });
152
164
  });
153
165
 
154
- _defineProperty(this, "handleGestureCancel", ({
155
- route
156
- }) => {
166
+ _defineProperty(this, "handleGestureCancel", _ref9 => {
167
+ let {
168
+ route
169
+ } = _ref9;
157
170
  this.props.navigation.emit({
158
171
  type: 'gestureCancel',
159
172
  target: route.key
@@ -276,9 +289,12 @@ export default class StackView extends React.Component {
276
289
  } else if (replacingRouteKeys.length || closingRouteKeys.length) {
277
290
  // Keep the routes we are closing or replacing if animation is enabled for them
278
291
  routes = routes.slice();
279
- routes.splice(routes.length - 1, 0, ...state.routes.filter(({
280
- key
281
- }) => isAnimationEnabled(key) ? replacingRouteKeys.includes(key) || closingRouteKeys.includes(key) : false));
292
+ routes.splice(routes.length - 1, 0, ...state.routes.filter(_ref10 => {
293
+ let {
294
+ key
295
+ } = _ref10;
296
+ return isAnimationEnabled(key) ? replacingRouteKeys.includes(key) || closingRouteKeys.includes(key) : false;
297
+ }));
282
298
  }
283
299
 
284
300
  if (!routes.length) {
@@ -1 +1 @@
1
- {"version":3,"sources":["StackView.tsx"],"names":["HeaderShownContext","SafeAreaProviderCompat","StackActions","React","StyleSheet","View","SafeAreaInsetsContext","ModalPresentationContext","GestureHandlerRootView","HeaderContainer","CardStack","GestureHandlerWrapper","isArrayEqual","a","b","length","every","it","index","StackView","Component","routes","previousRoutes","previousDescriptors","openingRouteKeys","closingRouteKeys","replacingRouteKeys","descriptors","route","state","filter","r","key","includes","findIndex","descriptor","props","render","navigation","some","routeNames","name","navigate","setState","dispatch","pop","source","target","closing","emit","type","data","getDerivedStateFromProps","map","reduce","acc","slice","previousFocusedRoute","nextFocusedRoute","isAnimationEnabled","options","animationEnabled","getAnimationTypeForReplace","animationTypeForReplace","splice","Error","_","rest","styles","container","insets","isParentModal","isParentHeaderShown","getPreviousRoute","handleOpenRoute","handleCloseRoute","handleTransitionStart","handleTransitionEnd","renderHeader","renderScene","handleGestureStart","handleGestureEnd","handleGestureCancel","create","flex"],"mappings":";;;;AAAA,SACEA,kBADF,EAEEC,sBAFF,QAGO,4BAHP;AAIA,SAGEC,YAHF,QAKO,0BALP;AAMA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AACA,SAEEC,qBAFF,QAGO,gCAHP;AAUA,OAAOC,wBAAP,MAAqC,sCAArC;AACA,SAASC,sBAAT,QAAuC,mBAAvC;AACA,OAAOC,eAAP,MAEO,2BAFP;AAGA,OAAOC,SAAP,MAAsB,aAAtB;AA0BA,MAAMC,qBAAqB,GAAGH,sBAAH,aAAGA,sBAAH,cAAGA,sBAAH,GAA6BH,IAAxD;AAEA;AACA;AACA;AACA;;AACA,MAAMO,YAAY,GAAG,CAACC,CAAD,EAAWC,CAAX,KACnBD,CAAC,CAACE,MAAF,KAAaD,CAAC,CAACC,MAAf,IAAyBF,CAAC,CAACG,KAAF,CAAQ,CAACC,EAAD,EAAKC,KAAL,KAAeD,EAAE,KAAKH,CAAC,CAACI,KAAD,CAA/B,CAD3B;;AAGA,eAAe,MAAMC,SAAN,SAAwBhB,KAAK,CAACiB,SAA9B,CAAsD;AAAA;AAAA;;AAAA,mCAyNpD;AACbC,MAAAA,MAAM,EAAE,EADK;AAEbC,MAAAA,cAAc,EAAE,EAFH;AAGbC,MAAAA,mBAAmB,EAAE,EAHR;AAIbC,MAAAA,gBAAgB,EAAE,EAJL;AAKbC,MAAAA,gBAAgB,EAAE,EALL;AAMbC,MAAAA,kBAAkB,EAAE,EANP;AAObC,MAAAA,WAAW,EAAE;AAPA,KAzNoD;;AAAA,8CAmOxC,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAyC;AAClE,YAAM;AAA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BAAD,CAAoB,QAApB,QACIC,mBAAD,iBACC,oBAAC,SAAD;AACE,MAAA,MAAM,EAAEF,MADV;AAEE,MAAA,mBAAmB,EAAEE,mBAFvB;AAGE,MAAA,aAAa,EAAED,aAHjB;AAIE,MAAA,gBAAgB,EAAE,KAAKE,gBAJzB;AAKE,MAAA,MAAM,EAAEpD,MALV;AAME,MAAA,gBAAgB,EAAEG,gBANpB;AAOE,MAAA,gBAAgB,EAAEC,gBAPpB;AAQE,MAAA,WAAW,EAAE,KAAKiD,eARpB;AASE,MAAA,YAAY,EAAE,KAAKC,gBATrB;AAUE,MAAA,iBAAiB,EAAE,KAAKC,qBAV1B;AAWE,MAAA,eAAe,EAAE,KAAKC,mBAXxB;AAYE,MAAA,YAAY,EAAE,KAAKC,YAZrB;AAaE,MAAA,WAAW,EAAE,KAAKC,WAbpB;AAcE,MAAA,KAAK,EAAElD,KAdT;AAeE,MAAA,WAAW,EAAEF,WAff;AAgBE,MAAA,cAAc,EAAE,KAAKqD,kBAhBvB;AAiBE,MAAA,YAAY,EAAE,KAAKC,gBAjBrB;AAkBE,MAAA,eAAe,EAAE,KAAKC;AAlBxB,OAmBMf,IAnBN,EAFJ,CAFJ,CAFJ,CADF,CADF,CADF;AAuCD;;AApZkE;AAuZrE,MAAMC,MAAM,GAAGhE,UAAU,CAAC+E,MAAX,CAAkB;AAC/Bd,EAAAA,SAAS,EAAE;AACTe,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport {\n EdgeInsets,\n SafeAreaInsetsContext,\n} from 'react-native-safe-area-context';\n\nimport type {\n StackDescriptorMap,\n StackNavigationConfig,\n StackNavigationHelpers,\n} from '../../types';\nimport ModalPresentationContext from '../../utils/ModalPresentationContext';\nimport { GestureHandlerRootView } from '../GestureHandler';\nimport HeaderContainer, {\n Props as HeaderContainerProps,\n} from '../Header/HeaderContainer';\nimport CardStack from './CardStack';\n\ntype Props = StackNavigationConfig & {\n state: StackNavigationState<ParamListBase>;\n navigation: StackNavigationHelpers;\n descriptors: StackDescriptorMap;\n};\n\ntype State = {\n // Local copy of the routes which are actually rendered\n routes: Route<string>[];\n // Previous routes, to compare whether routes have changed or not\n previousRoutes: Route<string>[];\n // Previous descriptors, to compare whether descriptors have changed or not\n previousDescriptors: StackDescriptorMap;\n // List of routes being opened, we need to animate pushing of these new routes\n openingRouteKeys: string[];\n // List of routes being closed, we need to animate popping of these routes\n closingRouteKeys: string[];\n // List of routes being replaced, we need to keep a copy until the new route animates in\n replacingRouteKeys: string[];\n // Since the local routes can vary from the routes from props, we need to keep the descriptors for old routes\n // Otherwise we won't be able to access the options for routes that were removed\n descriptors: StackDescriptorMap;\n};\n\nconst GestureHandlerWrapper = GestureHandlerRootView ?? View;\n\n/**\n * Compare two arrays with primitive values as the content.\n * We need to make sure that both values and order match.\n */\nconst isArrayEqual = (a: any[], b: any[]) =>\n a.length === b.length && a.every((it, index) => it === b[index]);\n\nexport default class StackView extends React.Component<Props, State> {\n static getDerivedStateFromProps(\n props: Readonly<Props>,\n state: Readonly<State>\n ) {\n // If there was no change in routes, we don't need to compute anything\n if (\n (props.state.routes === state.previousRoutes ||\n isArrayEqual(\n props.state.routes.map((r) => r.key),\n state.previousRoutes.map((r) => r.key)\n )) &&\n state.routes.length\n ) {\n let routes = state.routes;\n let previousRoutes = state.previousRoutes;\n let descriptors = props.descriptors;\n let previousDescriptors = state.previousDescriptors;\n\n if (props.descriptors !== state.previousDescriptors) {\n descriptors = state.routes.reduce<StackDescriptorMap>((acc, route) => {\n acc[route.key] =\n props.descriptors[route.key] || state.descriptors[route.key];\n\n return acc;\n }, {});\n\n previousDescriptors = props.descriptors;\n }\n\n if (props.state.routes !== state.previousRoutes) {\n // if any route objects have changed, we should update them\n const map = props.state.routes.reduce<Record<string, Route<string>>>(\n (acc, route) => {\n acc[route.key] = route;\n return acc;\n },\n {}\n );\n\n routes = state.routes.map((route) => map[route.key] || route);\n previousRoutes = props.state.routes;\n }\n\n return {\n routes,\n previousRoutes,\n descriptors,\n previousDescriptors,\n };\n }\n\n // Here we determine which routes were added or removed to animate them\n // We keep a copy of the route being removed in local state to be able to animate it\n\n let routes =\n props.state.index < props.state.routes.length - 1\n ? // Remove any extra routes from the state\n // The last visible route should be the focused route, i.e. at current index\n props.state.routes.slice(0, props.state.index + 1)\n : props.state.routes;\n\n // Now we need to determine which routes were added and removed\n let {\n openingRouteKeys,\n closingRouteKeys,\n replacingRouteKeys,\n previousRoutes,\n } = state;\n\n const previousFocusedRoute = previousRoutes[previousRoutes.length - 1] as\n | Route<string>\n | undefined;\n const nextFocusedRoute = routes[routes.length - 1];\n\n const isAnimationEnabled = (key: string) => {\n const descriptor = props.descriptors[key] || state.descriptors[key];\n\n return descriptor ? descriptor.options.animationEnabled !== false : true;\n };\n\n const getAnimationTypeForReplace = (key: string) => {\n const descriptor = props.descriptors[key] || state.descriptors[key];\n\n return descriptor.options.animationTypeForReplace ?? 'push';\n };\n\n if (\n previousFocusedRoute &&\n previousFocusedRoute.key !== nextFocusedRoute.key\n ) {\n // We only need to animate routes if the focused route changed\n // Animating previous routes won't be visible coz the focused route is on top of everything\n\n if (!previousRoutes.some((r) => r.key === nextFocusedRoute.key)) {\n // A new route has come to the focus, we treat this as a push\n // A replace can also trigger this, the animation should look like push\n\n if (\n isAnimationEnabled(nextFocusedRoute.key) &&\n !openingRouteKeys.includes(nextFocusedRoute.key)\n ) {\n // In this case, we need to animate pushing the focused route\n // We don't care about animating any other added routes because they won't be visible\n openingRouteKeys = [...openingRouteKeys, nextFocusedRoute.key];\n\n closingRouteKeys = closingRouteKeys.filter(\n (key) => key !== nextFocusedRoute.key\n );\n replacingRouteKeys = replacingRouteKeys.filter(\n (key) => key !== nextFocusedRoute.key\n );\n\n if (!routes.some((r) => r.key === previousFocusedRoute.key)) {\n // The previous focused route isn't present in state, we treat this as a replace\n\n openingRouteKeys = openingRouteKeys.filter(\n (key) => key !== previousFocusedRoute.key\n );\n\n if (getAnimationTypeForReplace(nextFocusedRoute.key) === 'pop') {\n closingRouteKeys = [\n ...closingRouteKeys,\n previousFocusedRoute.key,\n ];\n\n // By default, new routes have a push animation, so we add it to `openingRouteKeys` before\n // But since user configured it to animate the old screen like a pop, we need to add this without animation\n // So remove it from `openingRouteKeys` which will remove the animation\n openingRouteKeys = openingRouteKeys.filter(\n (key) => key !== nextFocusedRoute.key\n );\n\n // Keep the route being removed at the end to animate it out\n routes = [...routes, previousFocusedRoute];\n } else {\n replacingRouteKeys = [\n ...replacingRouteKeys,\n previousFocusedRoute.key,\n ];\n\n closingRouteKeys = closingRouteKeys.filter(\n (key) => key !== previousFocusedRoute.key\n );\n\n // Keep the old route in the state because it's visible under the new route, and removing it will feel abrupt\n // We need to insert it just before the focused one (the route being pushed)\n // After the push animation is completed, routes being replaced will be removed completely\n routes = routes.slice();\n routes.splice(routes.length - 1, 0, previousFocusedRoute);\n }\n }\n }\n } else if (!routes.some((r) => r.key === previousFocusedRoute.key)) {\n // The previously focused route was removed, we treat this as a pop\n\n if (\n isAnimationEnabled(previousFocusedRoute.key) &&\n !closingRouteKeys.includes(previousFocusedRoute.key)\n ) {\n closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];\n\n // Sometimes a route can be closed before the opening animation finishes\n // So we also need to remove it from the opening list\n openingRouteKeys = openingRouteKeys.filter(\n (key) => key !== previousFocusedRoute.key\n );\n replacingRouteKeys = replacingRouteKeys.filter(\n (key) => key !== previousFocusedRoute.key\n );\n\n // Keep a copy of route being removed in the state to be able to animate it\n routes = [...routes, previousFocusedRoute];\n }\n } else {\n // Looks like some routes were re-arranged and no focused routes were added/removed\n // i.e. the currently focused route already existed and the previously focused route still exists\n // We don't know how to animate this\n }\n } else if (replacingRouteKeys.length || closingRouteKeys.length) {\n // Keep the routes we are closing or replacing if animation is enabled for them\n routes = routes.slice();\n routes.splice(\n routes.length - 1,\n 0,\n ...state.routes.filter(({ key }) =>\n isAnimationEnabled(key)\n ? replacingRouteKeys.includes(key) || closingRouteKeys.includes(key)\n : false\n )\n );\n }\n\n if (!routes.length) {\n throw new Error(\n 'There should always be at least one route in the navigation state.'\n );\n }\n\n const descriptors = routes.reduce<StackDescriptorMap>((acc, route) => {\n acc[route.key] =\n props.descriptors[route.key] || state.descriptors[route.key];\n\n return acc;\n }, {});\n\n return {\n routes,\n previousRoutes: props.state.routes,\n previousDescriptors: props.descriptors,\n openingRouteKeys,\n closingRouteKeys,\n replacingRouteKeys,\n descriptors,\n };\n }\n\n state: State = {\n routes: [],\n previousRoutes: [],\n previousDescriptors: {},\n openingRouteKeys: [],\n closingRouteKeys: [],\n replacingRouteKeys: [],\n descriptors: {},\n };\n\n private getPreviousRoute = ({ route }: { route: Route<string> }) => {\n const { closingRouteKeys, replacingRouteKeys } = this.state;\n const routes = this.state.routes.filter(\n (r) =>\n r.key === route.key ||\n (!closingRouteKeys.includes(r.key) &&\n !replacingRouteKeys.includes(r.key))\n );\n\n const index = routes.findIndex((r) => r.key === route.key);\n\n return routes[index - 1];\n };\n\n private renderScene = ({ route }: { route: Route<string> }) => {\n const descriptor =\n this.state.descriptors[route.key] || this.props.descriptors[route.key];\n\n if (!descriptor) {\n return null;\n }\n\n return descriptor.render();\n };\n\n private renderHeader = (props: HeaderContainerProps) => {\n return <HeaderContainer {...props} />;\n };\n\n private handleOpenRoute = ({ route }: { route: Route<string> }) => {\n const { state, navigation } = this.props;\n const { closingRouteKeys, replacingRouteKeys } = this.state;\n\n if (\n closingRouteKeys.some((key) => key === route.key) &&\n replacingRouteKeys.every((key) => key !== route.key) &&\n state.routeNames.includes(route.name) &&\n !state.routes.some((r) => r.key === route.key)\n ) {\n // If route isn't present in current state, but was closing, assume that a close animation was cancelled\n // So we need to add this route back to the state\n navigation.navigate(route);\n } else {\n this.setState((state) => ({\n routes: state.replacingRouteKeys.length\n ? state.routes.filter(\n (r) => !state.replacingRouteKeys.includes(r.key)\n )\n : state.routes,\n openingRouteKeys: state.openingRouteKeys.filter(\n (key) => key !== route.key\n ),\n closingRouteKeys: state.closingRouteKeys.filter(\n (key) => key !== route.key\n ),\n replacingRouteKeys: [],\n }));\n }\n };\n\n private handleCloseRoute = ({ route }: { route: Route<string> }) => {\n const { state, navigation } = this.props;\n\n if (state.routes.some((r) => r.key === route.key)) {\n // If a route exists in state, trigger a pop\n // This will happen in when the route was closed from the card component\n // e.g. When the close animation triggered from a gesture ends\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key,\n });\n } else {\n // We need to clean up any state tracking the route and pop it immediately\n this.setState((state) => ({\n routes: state.routes.filter((r) => r.key !== route.key),\n openingRouteKeys: state.openingRouteKeys.filter(\n (key) => key !== route.key\n ),\n closingRouteKeys: state.closingRouteKeys.filter(\n (key) => key !== route.key\n ),\n }));\n }\n };\n\n private handleTransitionStart = (\n { route }: { route: Route<string> },\n closing: boolean\n ) =>\n this.props.navigation.emit({\n type: 'transitionStart',\n data: { closing },\n target: route.key,\n });\n\n private handleTransitionEnd = (\n { route }: { route: Route<string> },\n closing: boolean\n ) =>\n this.props.navigation.emit({\n type: 'transitionEnd',\n data: { closing },\n target: route.key,\n });\n\n private handleGestureStart = ({ route }: { route: Route<string> }) => {\n this.props.navigation.emit({\n type: 'gestureStart',\n target: route.key,\n });\n };\n\n private handleGestureEnd = ({ route }: { route: Route<string> }) => {\n this.props.navigation.emit({\n type: 'gestureEnd',\n target: route.key,\n });\n };\n\n private handleGestureCancel = ({ route }: { route: Route<string> }) => {\n this.props.navigation.emit({\n type: 'gestureCancel',\n target: route.key,\n });\n };\n\n render() {\n const {\n state,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n descriptors: _,\n ...rest\n } = this.props;\n\n const { routes, descriptors, openingRouteKeys, closingRouteKeys } =\n this.state;\n\n return (\n <GestureHandlerWrapper style={styles.container}>\n <SafeAreaProviderCompat>\n <SafeAreaInsetsContext.Consumer>\n {(insets) => (\n <ModalPresentationContext.Consumer>\n {(isParentModal) => (\n <HeaderShownContext.Consumer>\n {(isParentHeaderShown) => (\n <CardStack\n insets={insets as EdgeInsets}\n isParentHeaderShown={isParentHeaderShown}\n isParentModal={isParentModal}\n getPreviousRoute={this.getPreviousRoute}\n routes={routes}\n openingRouteKeys={openingRouteKeys}\n closingRouteKeys={closingRouteKeys}\n onOpenRoute={this.handleOpenRoute}\n onCloseRoute={this.handleCloseRoute}\n onTransitionStart={this.handleTransitionStart}\n onTransitionEnd={this.handleTransitionEnd}\n renderHeader={this.renderHeader}\n renderScene={this.renderScene}\n state={state}\n descriptors={descriptors}\n onGestureStart={this.handleGestureStart}\n onGestureEnd={this.handleGestureEnd}\n onGestureCancel={this.handleGestureCancel}\n {...rest}\n />\n )}\n </HeaderShownContext.Consumer>\n )}\n </ModalPresentationContext.Consumer>\n )}\n </SafeAreaInsetsContext.Consumer>\n </SafeAreaProviderCompat>\n </GestureHandlerWrapper>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
1
+ {"version":3,"sources":["StackView.tsx"],"names":["HeaderShownContext","SafeAreaProviderCompat","StackActions","React","StyleSheet","View","SafeAreaInsetsContext","ModalPresentationContext","GestureHandlerRootView","HeaderContainer","CardStack","GestureHandlerWrapper","isArrayEqual","a","b","length","every","it","index","StackView","Component","routes","previousRoutes","previousDescriptors","openingRouteKeys","closingRouteKeys","replacingRouteKeys","descriptors","route","state","filter","r","key","includes","findIndex","descriptor","props","render","navigation","some","routeNames","name","navigate","setState","dispatch","pop","source","target","closing","emit","type","data","getDerivedStateFromProps","map","reduce","acc","slice","previousFocusedRoute","nextFocusedRoute","isAnimationEnabled","options","animationEnabled","getAnimationTypeForReplace","animationTypeForReplace","splice","Error","_","rest","styles","container","insets","isParentModal","isParentHeaderShown","getPreviousRoute","handleOpenRoute","handleCloseRoute","handleTransitionStart","handleTransitionEnd","renderHeader","renderScene","handleGestureStart","handleGestureEnd","handleGestureCancel","create","flex"],"mappings":";;;;AAAA,SACEA,kBADF,EAEEC,sBAFF,QAGO,4BAHP;AAIA,SAGEC,YAHF,QAKO,0BALP;AAMA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AACA,SAEEC,qBAFF,QAGO,gCAHP;AAUA,OAAOC,wBAAP,MAAqC,sCAArC;AACA,SAASC,sBAAT,QAAuC,mBAAvC;AACA,OAAOC,eAAP,MAEO,2BAFP;AAGA,OAAOC,SAAP,MAAsB,aAAtB;AA0BA,MAAMC,qBAAqB,GAAGH,sBAAH,aAAGA,sBAAH,cAAGA,sBAAH,GAA6BH,IAAxD;AAEA;AACA;AACA;AACA;;AACA,MAAMO,YAAY,GAAG,CAACC,CAAD,EAAWC,CAAX,KACnBD,CAAC,CAACE,MAAF,KAAaD,CAAC,CAACC,MAAf,IAAyBF,CAAC,CAACG,KAAF,CAAQ,CAACC,EAAD,EAAKC,KAAL,KAAeD,EAAE,KAAKH,CAAC,CAACI,KAAD,CAA/B,CAD3B;;AAGA,eAAe,MAAMC,SAAN,SAAwBhB,KAAK,CAACiB,SAA9B,CAAsD;AAAA;AAAA;;AAAA,mCAyNpD;AACbC,MAAAA,MAAM,EAAE,EADK;AAEbC,MAAAA,cAAc,EAAE,EAFH;AAGbC,MAAAA,mBAAmB,EAAE,EAHR;AAIbC,MAAAA,gBAAgB,EAAE,EAJL;AAKbC,MAAAA,gBAAgB,EAAE,EALL;AAMbC,MAAAA,kBAAkB,EAAE,EANP;AAObC,MAAAA,WAAW,EAAE;AAPA,KAzNoD;;AAAA,8CAmOxC,QAAyC;AAAA,UAAxC;AAAEC,QAAAA;AAAF,OAAwC;AAClE,YAAM;AAAEH,QAAAA,gBAAF;AAAoBC,QAAAA;AAApB,UAA2C,KAAKG,KAAtD;AACA,YAAMR,MAAM,GAAG,KA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CAA0B,QAA1B,QACIC,aAAD,iBACC,oBAAC,kBAAD,CAAoB,QAApB,QACIC,mBAAD,iBACC,oBAAC,SAAD;AACE,MAAA,MAAM,EAAEF,MADV;AAEE,MAAA,mBAAmB,EAAEE,mBAFvB;AAGE,MAAA,aAAa,EAAED,aAHjB;AAIE,MAAA,gBAAgB,EAAE,KAAKE,gBAJzB;AAKE,MAAA,MAAM,EAAEpD,MALV;AAME,MAAA,gBAAgB,EAAEG,gBANpB;AAOE,MAAA,gBAAgB,EAAEC,gBAPpB;AAQE,MAAA,WAAW,EAAE,KAAKiD,eARpB;AASE,MAAA,YAAY,EAAE,KAAKC,gBATrB;AAUE,MAAA,iBAAiB,EAAE,KAAKC,qBAV1B;AAWE,MAAA,eAAe,EAAE,KAAKC,mBAXxB;AAYE,MAAA,YAAY,EAAE,KAAKC,YAZrB;AAaE,MAAA,WAAW,EAAE,KAAKC,WAbpB;AAcE,MAAA,KAAK,EAAElD,KAdT;AAeE,MAAA,WAAW,EAAEF,WAff;AAgBE,MAAA,cAAc,EAAE,KAAKqD,kBAhBvB;AAiBE,MAAA,YAAY,EAAE,KAAKC,gBAjBrB;AAkBE,MAAA,eAAe,EAAE,KAAKC;AAlBxB,OAmBMf,IAnBN,EAFJ,CAFJ,CAFJ,CADF,CADF,CADF;AAuCD;;AApZkE;AAuZrE,MAAMC,MAAM,GAAGhE,UAAU,CAAC+E,MAAX,CAAkB;AAC/Bd,EAAAA,SAAS,EAAE;AACTe,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport {\n EdgeInsets,\n SafeAreaInsetsContext,\n} from 'react-native-safe-area-context';\n\nimport type {\n StackDescriptorMap,\n StackNavigationConfig,\n StackNavigationHelpers,\n} from '../../types';\nimport ModalPresentationContext from '../../utils/ModalPresentationContext';\nimport { GestureHandlerRootView } from '../GestureHandler';\nimport HeaderContainer, {\n Props as HeaderContainerProps,\n} from '../Header/HeaderContainer';\nimport CardStack from './CardStack';\n\ntype Props = StackNavigationConfig & {\n state: StackNavigationState<ParamListBase>;\n navigation: StackNavigationHelpers;\n descriptors: StackDescriptorMap;\n};\n\ntype State = {\n // Local copy of the routes which are actually rendered\n routes: Route<string>[];\n // Previous routes, to compare whether routes have changed or not\n previousRoutes: Route<string>[];\n // Previous descriptors, to compare whether descriptors have changed or not\n previousDescriptors: StackDescriptorMap;\n // List of routes being opened, we need to animate pushing of these new routes\n openingRouteKeys: string[];\n // List of routes being closed, we need to animate popping of these routes\n closingRouteKeys: string[];\n // List of routes being replaced, we need to keep a copy until the new route animates in\n replacingRouteKeys: string[];\n // Since the local routes can vary from the routes from props, we need to keep the descriptors for old routes\n // Otherwise we won't be able to access the options for routes that were removed\n descriptors: StackDescriptorMap;\n};\n\nconst GestureHandlerWrapper = GestureHandlerRootView ?? View;\n\n/**\n * Compare two arrays with primitive values as the content.\n * We need to make sure that both values and order match.\n */\nconst isArrayEqual = (a: any[], b: any[]) =>\n a.length === b.length && a.every((it, index) => it === b[index]);\n\nexport default class StackView extends React.Component<Props, State> {\n static getDerivedStateFromProps(\n props: Readonly<Props>,\n state: Readonly<State>\n ) {\n // If there was no change in routes, we don't need to compute anything\n if (\n (props.state.routes === state.previousRoutes ||\n isArrayEqual(\n props.state.routes.map((r) => r.key),\n state.previousRoutes.map((r) => r.key)\n )) &&\n state.routes.length\n ) {\n let routes = state.routes;\n let previousRoutes = state.previousRoutes;\n let descriptors = props.descriptors;\n let previousDescriptors = state.previousDescriptors;\n\n if (props.descriptors !== state.previousDescriptors) {\n descriptors = state.routes.reduce<StackDescriptorMap>((acc, route) => {\n acc[route.key] =\n props.descriptors[route.key] || state.descriptors[route.key];\n\n return acc;\n }, {});\n\n previousDescriptors = props.descriptors;\n }\n\n if (props.state.routes !== state.previousRoutes) {\n // if any route objects have changed, we should update them\n const map = props.state.routes.reduce<Record<string, Route<string>>>(\n (acc, route) => {\n acc[route.key] = route;\n return acc;\n },\n {}\n );\n\n routes = state.routes.map((route) => map[route.key] || route);\n previousRoutes = props.state.routes;\n }\n\n return {\n routes,\n previousRoutes,\n descriptors,\n previousDescriptors,\n };\n }\n\n // Here we determine which routes were added or removed to animate them\n // We keep a copy of the route being removed in local state to be able to animate it\n\n let routes =\n props.state.index < props.state.routes.length - 1\n ? // Remove any extra routes from the state\n // The last visible route should be the focused route, i.e. at current index\n props.state.routes.slice(0, props.state.index + 1)\n : props.state.routes;\n\n // Now we need to determine which routes were added and removed\n let {\n openingRouteKeys,\n closingRouteKeys,\n replacingRouteKeys,\n previousRoutes,\n } = state;\n\n const previousFocusedRoute = previousRoutes[previousRoutes.length - 1] as\n | Route<string>\n | undefined;\n const nextFocusedRoute = routes[routes.length - 1];\n\n const isAnimationEnabled = (key: string) => {\n const descriptor = props.descriptors[key] || state.descriptors[key];\n\n return descriptor ? descriptor.options.animationEnabled !== false : true;\n };\n\n const getAnimationTypeForReplace = (key: string) => {\n const descriptor = props.descriptors[key] || state.descriptors[key];\n\n return descriptor.options.animationTypeForReplace ?? 'push';\n };\n\n if (\n previousFocusedRoute &&\n previousFocusedRoute.key !== nextFocusedRoute.key\n ) {\n // We only need to animate routes if the focused route changed\n // Animating previous routes won't be visible coz the focused route is on top of everything\n\n if (!previousRoutes.some((r) => r.key === nextFocusedRoute.key)) {\n // A new route has come to the focus, we treat this as a push\n // A replace can also trigger this, the animation should look like push\n\n if (\n isAnimationEnabled(nextFocusedRoute.key) &&\n !openingRouteKeys.includes(nextFocusedRoute.key)\n ) {\n // In this case, we need to animate pushing the focused route\n // We don't care about animating any other added routes because they won't be visible\n openingRouteKeys = [...openingRouteKeys, nextFocusedRoute.key];\n\n closingRouteKeys = closingRouteKeys.filter(\n (key) => key !== nextFocusedRoute.key\n );\n replacingRouteKeys = replacingRouteKeys.filter(\n (key) => key !== nextFocusedRoute.key\n );\n\n if (!routes.some((r) => r.key === previousFocusedRoute.key)) {\n // The previous focused route isn't present in state, we treat this as a replace\n\n openingRouteKeys = openingRouteKeys.filter(\n (key) => key !== previousFocusedRoute.key\n );\n\n if (getAnimationTypeForReplace(nextFocusedRoute.key) === 'pop') {\n closingRouteKeys = [\n ...closingRouteKeys,\n previousFocusedRoute.key,\n ];\n\n // By default, new routes have a push animation, so we add it to `openingRouteKeys` before\n // But since user configured it to animate the old screen like a pop, we need to add this without animation\n // So remove it from `openingRouteKeys` which will remove the animation\n openingRouteKeys = openingRouteKeys.filter(\n (key) => key !== nextFocusedRoute.key\n );\n\n // Keep the route being removed at the end to animate it out\n routes = [...routes, previousFocusedRoute];\n } else {\n replacingRouteKeys = [\n ...replacingRouteKeys,\n previousFocusedRoute.key,\n ];\n\n closingRouteKeys = closingRouteKeys.filter(\n (key) => key !== previousFocusedRoute.key\n );\n\n // Keep the old route in the state because it's visible under the new route, and removing it will feel abrupt\n // We need to insert it just before the focused one (the route being pushed)\n // After the push animation is completed, routes being replaced will be removed completely\n routes = routes.slice();\n routes.splice(routes.length - 1, 0, previousFocusedRoute);\n }\n }\n }\n } else if (!routes.some((r) => r.key === previousFocusedRoute.key)) {\n // The previously focused route was removed, we treat this as a pop\n\n if (\n isAnimationEnabled(previousFocusedRoute.key) &&\n !closingRouteKeys.includes(previousFocusedRoute.key)\n ) {\n closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];\n\n // Sometimes a route can be closed before the opening animation finishes\n // So we also need to remove it from the opening list\n openingRouteKeys = openingRouteKeys.filter(\n (key) => key !== previousFocusedRoute.key\n );\n replacingRouteKeys = replacingRouteKeys.filter(\n (key) => key !== previousFocusedRoute.key\n );\n\n // Keep a copy of route being removed in the state to be able to animate it\n routes = [...routes, previousFocusedRoute];\n }\n } else {\n // Looks like some routes were re-arranged and no focused routes were added/removed\n // i.e. the currently focused route already existed and the previously focused route still exists\n // We don't know how to animate this\n }\n } else if (replacingRouteKeys.length || closingRouteKeys.length) {\n // Keep the routes we are closing or replacing if animation is enabled for them\n routes = routes.slice();\n routes.splice(\n routes.length - 1,\n 0,\n ...state.routes.filter(({ key }) =>\n isAnimationEnabled(key)\n ? replacingRouteKeys.includes(key) || closingRouteKeys.includes(key)\n : false\n )\n );\n }\n\n if (!routes.length) {\n throw new Error(\n 'There should always be at least one route in the navigation state.'\n );\n }\n\n const descriptors = routes.reduce<StackDescriptorMap>((acc, route) => {\n acc[route.key] =\n props.descriptors[route.key] || state.descriptors[route.key];\n\n return acc;\n }, {});\n\n return {\n routes,\n previousRoutes: props.state.routes,\n previousDescriptors: props.descriptors,\n openingRouteKeys,\n closingRouteKeys,\n replacingRouteKeys,\n descriptors,\n };\n }\n\n state: State = {\n routes: [],\n previousRoutes: [],\n previousDescriptors: {},\n openingRouteKeys: [],\n closingRouteKeys: [],\n replacingRouteKeys: [],\n descriptors: {},\n };\n\n private getPreviousRoute = ({ route }: { route: Route<string> }) => {\n const { closingRouteKeys, replacingRouteKeys } = this.state;\n const routes = this.state.routes.filter(\n (r) =>\n r.key === route.key ||\n (!closingRouteKeys.includes(r.key) &&\n !replacingRouteKeys.includes(r.key))\n );\n\n const index = routes.findIndex((r) => r.key === route.key);\n\n return routes[index - 1];\n };\n\n private renderScene = ({ route }: { route: Route<string> }) => {\n const descriptor =\n this.state.descriptors[route.key] || this.props.descriptors[route.key];\n\n if (!descriptor) {\n return null;\n }\n\n return descriptor.render();\n };\n\n private renderHeader = (props: HeaderContainerProps) => {\n return <HeaderContainer {...props} />;\n };\n\n private handleOpenRoute = ({ route }: { route: Route<string> }) => {\n const { state, navigation } = this.props;\n const { closingRouteKeys, replacingRouteKeys } = this.state;\n\n if (\n closingRouteKeys.some((key) => key === route.key) &&\n replacingRouteKeys.every((key) => key !== route.key) &&\n state.routeNames.includes(route.name) &&\n !state.routes.some((r) => r.key === route.key)\n ) {\n // If route isn't present in current state, but was closing, assume that a close animation was cancelled\n // So we need to add this route back to the state\n navigation.navigate(route);\n } else {\n this.setState((state) => ({\n routes: state.replacingRouteKeys.length\n ? state.routes.filter(\n (r) => !state.replacingRouteKeys.includes(r.key)\n )\n : state.routes,\n openingRouteKeys: state.openingRouteKeys.filter(\n (key) => key !== route.key\n ),\n closingRouteKeys: state.closingRouteKeys.filter(\n (key) => key !== route.key\n ),\n replacingRouteKeys: [],\n }));\n }\n };\n\n private handleCloseRoute = ({ route }: { route: Route<string> }) => {\n const { state, navigation } = this.props;\n\n if (state.routes.some((r) => r.key === route.key)) {\n // If a route exists in state, trigger a pop\n // This will happen in when the route was closed from the card component\n // e.g. When the close animation triggered from a gesture ends\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key,\n });\n } else {\n // We need to clean up any state tracking the route and pop it immediately\n this.setState((state) => ({\n routes: state.routes.filter((r) => r.key !== route.key),\n openingRouteKeys: state.openingRouteKeys.filter(\n (key) => key !== route.key\n ),\n closingRouteKeys: state.closingRouteKeys.filter(\n (key) => key !== route.key\n ),\n }));\n }\n };\n\n private handleTransitionStart = (\n { route }: { route: Route<string> },\n closing: boolean\n ) =>\n this.props.navigation.emit({\n type: 'transitionStart',\n data: { closing },\n target: route.key,\n });\n\n private handleTransitionEnd = (\n { route }: { route: Route<string> },\n closing: boolean\n ) =>\n this.props.navigation.emit({\n type: 'transitionEnd',\n data: { closing },\n target: route.key,\n });\n\n private handleGestureStart = ({ route }: { route: Route<string> }) => {\n this.props.navigation.emit({\n type: 'gestureStart',\n target: route.key,\n });\n };\n\n private handleGestureEnd = ({ route }: { route: Route<string> }) => {\n this.props.navigation.emit({\n type: 'gestureEnd',\n target: route.key,\n });\n };\n\n private handleGestureCancel = ({ route }: { route: Route<string> }) => {\n this.props.navigation.emit({\n type: 'gestureCancel',\n target: route.key,\n });\n };\n\n render() {\n const {\n state,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n descriptors: _,\n ...rest\n } = this.props;\n\n const { routes, descriptors, openingRouteKeys, closingRouteKeys } =\n this.state;\n\n return (\n <GestureHandlerWrapper style={styles.container}>\n <SafeAreaProviderCompat>\n <SafeAreaInsetsContext.Consumer>\n {(insets) => (\n <ModalPresentationContext.Consumer>\n {(isParentModal) => (\n <HeaderShownContext.Consumer>\n {(isParentHeaderShown) => (\n <CardStack\n insets={insets as EdgeInsets}\n isParentHeaderShown={isParentHeaderShown}\n isParentModal={isParentModal}\n getPreviousRoute={this.getPreviousRoute}\n routes={routes}\n openingRouteKeys={openingRouteKeys}\n closingRouteKeys={closingRouteKeys}\n onOpenRoute={this.handleOpenRoute}\n onCloseRoute={this.handleCloseRoute}\n onTransitionStart={this.handleTransitionStart}\n onTransitionEnd={this.handleTransitionEnd}\n renderHeader={this.renderHeader}\n renderScene={this.renderScene}\n state={state}\n descriptors={descriptors}\n onGestureStart={this.handleGestureStart}\n onGestureEnd={this.handleGestureEnd}\n onGestureCancel={this.handleGestureCancel}\n {...rest}\n />\n )}\n </HeaderShownContext.Consumer>\n )}\n </ModalPresentationContext.Consumer>\n )}\n </SafeAreaInsetsContext.Consumer>\n </SafeAreaProviderCompat>\n </GestureHandlerWrapper>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
@@ -25,4 +25,4 @@ export { default as useGestureHandlerRef } from './utils/useGestureHandlerRef';
25
25
  /**
26
26
  * Types
27
27
  */
28
- export type { StackCardInterpolatedStyle, StackCardInterpolationProps, StackCardStyleInterpolator, StackHeaderInterpolatedStyle, StackHeaderInterpolationProps, StackHeaderProps, StackHeaderStyleInterpolator, StackNavigationOptions, StackNavigationProp, StackScreenProps, TransitionPreset, } from './types';
28
+ export type { StackCardInterpolatedStyle, StackCardInterpolationProps, StackCardStyleInterpolator, StackHeaderInterpolatedStyle, StackHeaderInterpolationProps, StackHeaderProps, StackHeaderStyleInterpolator, StackNavigationEventMap, StackNavigationOptions, StackNavigationProp, StackScreenProps, TransitionPreset, } from './types';
@@ -1,4 +1,4 @@
1
- import type { HeaderBackButton, HeaderBackButtonProps, HeaderOptions, HeaderTitleProps } from '@react-navigation/elements';
1
+ import type { HeaderBackButton, HeaderBackButtonProps, HeaderButtonProps, HeaderOptions, HeaderTitleProps } from '@react-navigation/elements';
2
2
  import type { Descriptor, NavigationHelpers, NavigationProp, ParamListBase, Route, RouteProp, StackActionHelpers, StackNavigationState } from '@react-navigation/native';
3
3
  import type * as React from 'react';
4
4
  import type { Animated, StyleProp, TextStyle, ViewStyle } from 'react-native';
@@ -89,7 +89,7 @@ export declare type SceneProgress = {
89
89
  };
90
90
  export declare type StackHeaderMode = 'float' | 'screen';
91
91
  export declare type StackPresentationMode = 'card' | 'modal';
92
- export declare type StackHeaderOptions = Omit<HeaderOptions, 'headerLeft' | 'headerTitle'> & {
92
+ export declare type StackHeaderOptions = Omit<HeaderOptions, 'headerLeft' | 'headerTitle' | 'headerRight'> & {
93
93
  /**
94
94
  * String or a function that returns a React Element to be used by the header.
95
95
  * Defaults to screen `title` or route name.
@@ -102,6 +102,10 @@ export declare type StackHeaderOptions = Omit<HeaderOptions, 'headerLeft' | 'hea
102
102
  * Function which returns a React Element to display on the left side of the header.
103
103
  */
104
104
  headerLeft?: (props: HeaderBackButtonProps) => React.ReactNode;
105
+ /**
106
+ * Function which returns a React Element to display on the right side of the header.
107
+ */
108
+ headerRight?: (props: HeaderButtonProps) => React.ReactNode;
105
109
  /**
106
110
  * Whether back button title font should scale to respect Text Size accessibility settings. Defaults to `false`.
107
111
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/stack",
3
3
  "description": "Stack navigator component for iOS and Android with animated transitions and gestures",
4
- "version": "6.0.11",
4
+ "version": "6.1.0",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -40,23 +40,23 @@
40
40
  "clean": "del lib"
41
41
  },
42
42
  "dependencies": {
43
- "@react-navigation/elements": "^1.2.1",
43
+ "@react-navigation/elements": "^1.3.0",
44
44
  "color": "^3.1.3",
45
45
  "warn-once": "^0.1.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@react-navigation/native": "^6.0.6",
48
+ "@react-navigation/native": "^6.0.7",
49
49
  "@testing-library/react-native": "^7.2.0",
50
50
  "@types/color": "^3.0.1",
51
51
  "@types/react": "^17.0.9",
52
52
  "@types/react-native": "~0.64.9",
53
53
  "del-cli": "^3.0.1",
54
- "react": "~16.13.1",
55
- "react-native": "~0.63.4",
54
+ "react": "17.0.1",
55
+ "react-native": "~0.64.3",
56
56
  "react-native-builder-bob": "^0.18.1",
57
- "react-native-gesture-handler": "~1.10.2",
58
- "react-native-safe-area-context": "~3.2.0",
59
- "react-native-screens": "~3.8.0",
57
+ "react-native-gesture-handler": "~2.1.0",
58
+ "react-native-safe-area-context": "3.3.2",
59
+ "react-native-screens": "~3.10.1",
60
60
  "typescript": "^4.3.2"
61
61
  },
62
62
  "peerDependencies": {
@@ -81,5 +81,5 @@
81
81
  ]
82
82
  ]
83
83
  },
84
- "gitHead": "e77a5ab9d342a03cd8e20b54938700dfd4e23f42"
84
+ "gitHead": "4c5805867ce946d99ba17f71b4d6086bb8751262"
85
85
  }
package/src/index.tsx CHANGED
@@ -43,6 +43,7 @@ export type {
43
43
  StackHeaderInterpolationProps,
44
44
  StackHeaderProps,
45
45
  StackHeaderStyleInterpolator,
46
+ StackNavigationEventMap,
46
47
  StackNavigationOptions,
47
48
  StackNavigationProp,
48
49
  StackScreenProps,
package/src/types.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import type {
2
2
  HeaderBackButton,
3
3
  HeaderBackButtonProps,
4
+ HeaderButtonProps,
4
5
  HeaderOptions,
5
6
  HeaderTitleProps,
6
7
  } from '@react-navigation/elements';
@@ -122,7 +123,7 @@ export type StackPresentationMode = 'card' | 'modal';
122
123
 
123
124
  export type StackHeaderOptions = Omit<
124
125
  HeaderOptions,
125
- 'headerLeft' | 'headerTitle'
126
+ 'headerLeft' | 'headerTitle' | 'headerRight'
126
127
  > & {
127
128
  /**
128
129
  * String or a function that returns a React Element to be used by the header.
@@ -136,6 +137,10 @@ export type StackHeaderOptions = Omit<
136
137
  * Function which returns a React Element to display on the left side of the header.
137
138
  */
138
139
  headerLeft?: (props: HeaderBackButtonProps) => React.ReactNode;
140
+ /**
141
+ * Function which returns a React Element to display on the right side of the header.
142
+ */
143
+ headerRight?: (props: HeaderButtonProps) => React.ReactNode;
139
144
  /**
140
145
  * Whether back button title font should scale to respect Text Size accessibility settings. Defaults to `false`.
141
146
  */
@@ -33,11 +33,13 @@ type Props = Omit<StackHeaderOptions, 'headerStatusBarHeight'> & {
33
33
  };
34
34
 
35
35
  export default function HeaderSegment(props: Props) {
36
- const [leftLabelLayout, setLeftLabelLayout] =
37
- React.useState<Layout | undefined>(undefined);
36
+ const [leftLabelLayout, setLeftLabelLayout] = React.useState<
37
+ Layout | undefined
38
+ >(undefined);
38
39
 
39
- const [titleLayout, setTitleLayout] =
40
- React.useState<Layout | undefined>(undefined);
40
+ const [titleLayout, setTitleLayout] = React.useState<Layout | undefined>(
41
+ undefined
42
+ );
41
43
 
42
44
  const handleTitleLayout = (e: LayoutChangeEvent) => {
43
45
  const { height, width } = e.nativeEvent.layout;
@@ -103,6 +105,7 @@ export default function HeaderSegment(props: Props) {
103
105
  headerLeft: left = onGoBack
104
106
  ? (props: HeaderBackButtonProps) => <HeaderBackButton {...props} />
105
107
  : undefined,
108
+ headerRight: right,
106
109
  headerBackImage,
107
110
  headerBackTitle,
108
111
  headerBackTitleVisible = Platform.OS === 'ios',
@@ -166,6 +169,14 @@ export default function HeaderSegment(props: Props) {
166
169
  })
167
170
  : undefined;
168
171
 
172
+ const headerRight: StackHeaderOptions['headerRight'] = right
173
+ ? (props) =>
174
+ right({
175
+ ...props,
176
+ canGoBack: Boolean(onGoBack),
177
+ })
178
+ : undefined;
179
+
169
180
  const headerTitle: StackHeaderOptions['headerTitle'] =
170
181
  typeof title !== 'function'
171
182
  ? (props) => <HeaderTitle {...props} onLayout={handleTitleLayout} />
@@ -178,6 +189,7 @@ export default function HeaderSegment(props: Props) {
178
189
  headerTitle={headerTitle}
179
190
  headerLeft={headerLeft}
180
191
  headerLeftLabelVisible={headerBackTitleVisible}
192
+ headerRight={headerRight}
181
193
  headerTitleContainerStyle={[titleStyle, headerTitleContainerStyle]}
182
194
  headerLeftContainerStyle={[leftButtonStyle, headerLeftContainerStyle]}
183
195
  headerRightContainerStyle={[rightButtonStyle, headerRightContainerStyle]}
@@ -272,7 +272,7 @@ export default class Card extends React.Component<Props> {
272
272
  } = this.props;
273
273
 
274
274
  switch (nativeEvent.state) {
275
- case GestureState.BEGAN:
275
+ case GestureState.ACTIVE:
276
276
  this.isSwiping.setValue(TRUE);
277
277
  this.handleStartInteraction();
278
278
  onGestureBegin?.();
@@ -165,8 +165,9 @@ function CardContainer({
165
165
 
166
166
  const { colors } = useTheme();
167
167
 
168
- const [pointerEvents, setPointerEvents] =
169
- React.useState<'box-none' | 'none'>('box-none');
168
+ const [pointerEvents, setPointerEvents] = React.useState<'box-none' | 'none'>(
169
+ 'box-none'
170
+ );
170
171
 
171
172
  React.useEffect(() => {
172
173
  const listener = scene.progress.next?.addListener?.(
@@ -530,7 +530,12 @@ export default class CardStack extends React.Component<Props, State> {
530
530
  if (detachPreviousScreen === false) {
531
531
  activeScreensLimit++;
532
532
  } else {
533
- break;
533
+ // Check at least last 2 screens before stopping
534
+ // This will make sure that screen isn't detached when another screen is animating on top of the transparent one
535
+ // For example, (Opaque -> Transparent -> Opaque)
536
+ if (i <= scenes.length - 2) {
537
+ break;
538
+ }
534
539
  }
535
540
  }
536
541