@amazon-devices/react-navigation__stack 8.0.9000000001 → 8.0.9000000002

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 (76) hide show
  1. package/kepler-compatibility.json +2 -1
  2. package/lib/module/index.js +0 -34
  3. package/lib/module/views/Stack/CardStack.js.map +1 -1
  4. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
  5. package/package.json +1 -1
  6. package/src/index.tsx +0 -56
  7. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +0 -394
  8. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +0 -262
  9. package/lib/module/TransitionConfigs/TransitionPresets.js +0 -156
  10. package/lib/module/TransitionConfigs/TransitionSpecs.js +0 -124
  11. package/lib/module/navigators/createStackNavigator.js +0 -71
  12. package/lib/module/types.js +0 -4
  13. package/lib/module/utils/CardAnimationContext.js +0 -5
  14. package/lib/module/utils/GestureHandlerRefContext.js +0 -5
  15. package/lib/module/utils/ModalPresentationContext.js +0 -5
  16. package/lib/module/utils/conditional.js +0 -28
  17. package/lib/module/utils/findLastIndex.js +0 -11
  18. package/lib/module/utils/gestureActivationCriteria.js +0 -60
  19. package/lib/module/utils/getDistanceForDirection.js +0 -15
  20. package/lib/module/utils/getInvertedMultiplier.js +0 -15
  21. package/lib/module/utils/getModalRoutesKeys.js +0 -12
  22. package/lib/module/utils/getShadowStyle.js +0 -24
  23. package/lib/module/utils/throttle.js +0 -14
  24. package/lib/module/utils/useCardAnimation.js +0 -12
  25. package/lib/module/utils/useGestureHandlerRef.js +0 -12
  26. package/lib/module/utils/useKeyboardManager.js +0 -90
  27. package/lib/module/views/GestureHandler.android.js +0 -4
  28. package/lib/module/views/GestureHandler.ios.js +0 -4
  29. package/lib/module/views/GestureHandler.js +0 -21
  30. package/lib/module/views/GestureHandler.kepler.js +0 -4
  31. package/lib/module/views/GestureHandlerNative.js +0 -18
  32. package/lib/module/views/Header/Header.js +0 -56
  33. package/lib/module/views/Header/HeaderContainer.js +0 -128
  34. package/lib/module/views/Header/HeaderSegment.js +0 -142
  35. package/lib/module/views/Screens.js +0 -42
  36. package/lib/module/views/Stack/Card.js +0 -433
  37. package/lib/module/views/Stack/CardA11yWrapper.js +0 -43
  38. package/lib/module/views/Stack/CardContainer.js +0 -276
  39. package/lib/module/views/Stack/CardContent.js +0 -74
  40. package/lib/module/views/Stack/CardStack.js +0 -498
  41. package/lib/module/views/Stack/StackView.js +0 -339
  42. package/src/TransitionConfigs/CardStyleInterpolators.tsx +0 -460
  43. package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +0 -286
  44. package/src/TransitionConfigs/TransitionPresets.tsx +0 -182
  45. package/src/TransitionConfigs/TransitionSpecs.tsx +0 -124
  46. package/src/navigators/createStackNavigator.tsx +0 -120
  47. package/src/types.tsx +0 -639
  48. package/src/utils/CardAnimationContext.tsx +0 -7
  49. package/src/utils/GestureHandlerRefContext.tsx +0 -5
  50. package/src/utils/ModalPresentationContext.tsx +0 -3
  51. package/src/utils/conditional.tsx +0 -33
  52. package/src/utils/findLastIndex.tsx +0 -9
  53. package/src/utils/gestureActivationCriteria.tsx +0 -70
  54. package/src/utils/getDistanceForDirection.tsx +0 -19
  55. package/src/utils/getInvertedMultiplier.tsx +0 -17
  56. package/src/utils/getModalRoutesKeys.ts +0 -21
  57. package/src/utils/getShadowStyle.tsx +0 -37
  58. package/src/utils/throttle.tsx +0 -16
  59. package/src/utils/useCardAnimation.tsx +0 -15
  60. package/src/utils/useGestureHandlerRef.tsx +0 -15
  61. package/src/utils/useKeyboardManager.tsx +0 -103
  62. package/src/views/GestureHandler.android.tsx +0 -1
  63. package/src/views/GestureHandler.ios.tsx +0 -1
  64. package/src/views/GestureHandler.kepler.tsx +0 -1
  65. package/src/views/GestureHandler.tsx +0 -23
  66. package/src/views/GestureHandlerNative.tsx +0 -23
  67. package/src/views/Header/Header.tsx +0 -73
  68. package/src/views/Header/HeaderContainer.tsx +0 -191
  69. package/src/views/Header/HeaderSegment.tsx +0 -203
  70. package/src/views/Screens.tsx +0 -45
  71. package/src/views/Stack/Card.tsx +0 -646
  72. package/src/views/Stack/CardA11yWrapper.tsx +0 -67
  73. package/src/views/Stack/CardContainer.tsx +0 -339
  74. package/src/views/Stack/CardContent.tsx +0 -92
  75. package/src/views/Stack/CardStack.tsx +0 -849
  76. package/src/views/Stack/StackView.tsx +0 -485
@@ -1,498 +0,0 @@
1
- "use strict";
2
-
3
- import { getDefaultHeaderHeight, SafeAreaProviderCompat } from '@amazon-devices/react-navigation__elements';
4
- import * as React from 'react';
5
- import { Animated, Platform, StyleSheet, View } from 'react-native';
6
- import { forModalPresentationIOS, forNoAnimation as forNoAnimationCard } from "../../TransitionConfigs/CardStyleInterpolators.js";
7
- import { BottomSheetAndroid, DefaultTransition, FadeFromBottomAndroid, FadeFromRightAndroid, ModalFadeTransition, ModalSlideFromBottomIOS, ModalTransition, RevealFromBottomAndroid, ScaleFromCenterAndroid, SlideFromLeftIOS, SlideFromRightIOS } from "../../TransitionConfigs/TransitionPresets.js";
8
- import { findLastIndex } from "../../utils/findLastIndex.js";
9
- import { getDistanceForDirection } from "../../utils/getDistanceForDirection.js";
10
- import { getModalRouteKeys } from "../../utils/getModalRoutesKeys.js";
11
- import { MaybeScreen, MaybeScreenContainer } from "../Screens.js";
12
- import { CardContainer } from "./CardContainer.js";
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const NAMED_TRANSITIONS_PRESETS = {
15
- default: DefaultTransition,
16
- fade: ModalFadeTransition,
17
- fade_from_bottom: FadeFromBottomAndroid,
18
- fade_from_right: FadeFromRightAndroid,
19
- none: DefaultTransition,
20
- reveal_from_bottom: RevealFromBottomAndroid,
21
- scale_from_center: ScaleFromCenterAndroid,
22
- slide_from_left: SlideFromLeftIOS,
23
- slide_from_right: SlideFromRightIOS,
24
- slide_from_bottom: Platform.select({
25
- ios: ModalSlideFromBottomIOS,
26
- default: BottomSheetAndroid
27
- })
28
- };
29
- const EPSILON = 1e-5;
30
- const STATE_INACTIVE = 0;
31
- const STATE_TRANSITIONING_OR_BELOW_TOP = 1;
32
- const STATE_ON_TOP = 2;
33
- const FALLBACK_DESCRIPTOR = Object.freeze({
34
- options: {}
35
- });
36
- const getInterpolationIndex = (scenes, index) => {
37
- const {
38
- cardStyleInterpolator
39
- } = scenes[index].descriptor.options;
40
-
41
- // Start from current card and count backwards the number of cards with same interpolation
42
- let interpolationIndex = 0;
43
- for (let i = index - 1; i >= 0; i--) {
44
- const cardStyleInterpolatorCurrent = scenes[i]?.descriptor.options.cardStyleInterpolator;
45
- if (cardStyleInterpolatorCurrent !== cardStyleInterpolator) {
46
- break;
47
- }
48
- interpolationIndex++;
49
- }
50
- return interpolationIndex;
51
- };
52
- const getIsModalPresentation = cardStyleInterpolator => {
53
- return cardStyleInterpolator === forModalPresentationIOS ||
54
- // Handle custom modal presentation interpolators as well
55
- cardStyleInterpolator.name === 'forModalPresentationIOS';
56
- };
57
- const getIsModal = (scene, interpolationIndex, isParentModal) => {
58
- if (isParentModal) {
59
- return true;
60
- }
61
- const {
62
- cardStyleInterpolator
63
- } = scene.descriptor.options;
64
- const isModalPresentation = getIsModalPresentation(cardStyleInterpolator);
65
- const isModal = isModalPresentation && interpolationIndex !== 0;
66
- return isModal;
67
- };
68
- const getHeaderHeights = (scenes, insets, isParentHeaderShown, isParentModal, layout, previous) => {
69
- return scenes.reduce((acc, curr, index) => {
70
- const {
71
- headerStatusBarHeight = isParentHeaderShown ? 0 : insets.top,
72
- headerStyle
73
- } = curr.descriptor.options;
74
- const style = StyleSheet.flatten(headerStyle || {});
75
- const height = 'height' in style && typeof style.height === 'number' ? style.height : previous[curr.route.key];
76
- const interpolationIndex = getInterpolationIndex(scenes, index);
77
- const isModal = getIsModal(curr, interpolationIndex, isParentModal);
78
- acc[curr.route.key] = typeof height === 'number' ? height : getDefaultHeaderHeight(layout, isModal, headerStatusBarHeight);
79
- return acc;
80
- }, {});
81
- };
82
- const getDistanceFromOptions = (layout, options, isRTL) => {
83
- if (options?.gestureDirection) {
84
- return getDistanceForDirection(layout, options.gestureDirection, isRTL);
85
- }
86
- const defaultGestureDirection = options?.presentation === 'modal' ? ModalTransition.gestureDirection : DefaultTransition.gestureDirection;
87
- const gestureDirection = options?.animation ? NAMED_TRANSITIONS_PRESETS[options?.animation]?.gestureDirection : defaultGestureDirection;
88
- return getDistanceForDirection(layout, gestureDirection, isRTL);
89
- };
90
- const getProgressFromGesture = (gesture, layout, options, isRTL) => {
91
- const distance = getDistanceFromOptions({
92
- // Make sure that we have a non-zero distance, otherwise there will be incorrect progress
93
- // This causes blank screen on web if it was previously inside container with display: none
94
- width: Math.max(1, layout.width),
95
- height: Math.max(1, layout.height)
96
- }, options, isRTL);
97
- if (distance > 0) {
98
- return gesture.interpolate({
99
- inputRange: [0, distance],
100
- outputRange: [1, 0]
101
- });
102
- }
103
- return gesture.interpolate({
104
- inputRange: [distance, 0],
105
- outputRange: [0, 1]
106
- });
107
- };
108
- function getDefaultAnimation(animation) {
109
- // Disable screen transition animation by default on web, windows and macos to match the native behavior
110
- const excludedPlatforms = Platform.OS !== 'web' && Platform.OS !== 'windows' && Platform.OS !== 'macos';
111
- return animation ?? (excludedPlatforms ? 'default' : 'none');
112
- }
113
- export function getAnimationEnabled(animation) {
114
- return getDefaultAnimation(animation) !== 'none';
115
- }
116
- export class CardStack extends React.Component {
117
- static getDerivedStateFromProps(props, state) {
118
- if (props.routes === state.routes && props.descriptors === state.descriptors) {
119
- return null;
120
- }
121
- const gestures = [...props.routes, ...props.state.preloadedRoutes].reduce((acc, curr) => {
122
- const descriptor = props.descriptors[curr.key] || props.preloadedDescriptors[curr.key];
123
- const {
124
- animation
125
- } = descriptor?.options || {};
126
- acc[curr.key] = state.gestures[curr.key] || new Animated.Value(props.openingRouteKeys.includes(curr.key) && getAnimationEnabled(animation) || props.state.preloadedRoutes.includes(curr) ? getDistanceFromOptions(state.layout, descriptor?.options, props.direction === 'rtl') : 0);
127
- return acc;
128
- }, {});
129
- const modalRouteKeys = getModalRouteKeys([...props.routes, ...props.state.preloadedRoutes], {
130
- ...props.descriptors,
131
- ...props.preloadedDescriptors
132
- });
133
- const scenes = [...props.routes, ...props.state.preloadedRoutes].map((route, index, self) => {
134
- // For preloaded screens, we don't care about the previous and the next screen
135
- const isPreloaded = props.state.preloadedRoutes.includes(route);
136
- const previousRoute = isPreloaded ? undefined : self[index - 1];
137
- const nextRoute = isPreloaded ? undefined : self[index + 1];
138
- const oldScene = state.scenes[index];
139
- const currentGesture = gestures[route.key];
140
- const previousGesture = previousRoute ? gestures[previousRoute.key] : undefined;
141
- const nextGesture = nextRoute ? gestures[nextRoute.key] : undefined;
142
- const descriptor = (isPreloaded ? props.preloadedDescriptors : props.descriptors)[route.key] || state.descriptors[route.key] || (oldScene ? oldScene.descriptor : FALLBACK_DESCRIPTOR);
143
- const nextOptions = nextRoute && (props.descriptors[nextRoute?.key] || state.descriptors[nextRoute?.key])?.options;
144
- const previousOptions = previousRoute && (props.descriptors[previousRoute?.key] || state.descriptors[previousRoute?.key])?.options;
145
-
146
- // When a screen is not the last, it should use next screen's transition config
147
- // Many transitions also animate the previous screen, so using 2 different transitions doesn't look right
148
- // For example combining a slide and a modal transition would look wrong otherwise
149
- // With this approach, combining different transition styles in the same navigator mostly looks right
150
- // This will still be broken when 2 transitions have different idle state (e.g. modal presentation),
151
- // but the majority of the transitions look alright
152
- const optionsForTransitionConfig = index !== self.length - 1 && nextOptions && nextOptions?.presentation !== 'transparentModal' ? nextOptions : descriptor.options;
153
-
154
- // Assume modal if there are already modal screens in the stack
155
- // or current screen is a modal when no presentation is specified
156
- const isModal = modalRouteKeys.includes(route.key);
157
- const animation = getDefaultAnimation(optionsForTransitionConfig.animation);
158
- const isAnimationEnabled = getAnimationEnabled(animation);
159
- const transitionPreset = animation !== 'default' ? NAMED_TRANSITIONS_PRESETS[animation] : optionsForTransitionConfig.presentation === 'transparentModal' ? ModalFadeTransition : optionsForTransitionConfig.presentation === 'modal' || isModal ? ModalTransition : DefaultTransition;
160
- const {
161
- gestureEnabled = Platform.OS === 'ios' && isAnimationEnabled,
162
- gestureDirection = transitionPreset.gestureDirection,
163
- transitionSpec = transitionPreset.transitionSpec,
164
- cardStyleInterpolator = isAnimationEnabled ? transitionPreset.cardStyleInterpolator : forNoAnimationCard,
165
- headerStyleInterpolator = transitionPreset.headerStyleInterpolator,
166
- cardOverlayEnabled = Platform.OS !== 'ios' && optionsForTransitionConfig.presentation !== 'transparentModal' || getIsModalPresentation(cardStyleInterpolator)
167
- } = optionsForTransitionConfig;
168
- const headerMode = descriptor.options.headerMode ?? (!(optionsForTransitionConfig.presentation === 'modal' || optionsForTransitionConfig.presentation === 'transparentModal' || nextOptions?.presentation === 'modal' || nextOptions?.presentation === 'transparentModal' || getIsModalPresentation(cardStyleInterpolator)) && Platform.OS === 'ios' && descriptor.options.header === undefined ? 'float' : 'screen');
169
- const isRTL = props.direction === 'rtl';
170
- const scene = {
171
- route,
172
- descriptor: {
173
- ...descriptor,
174
- options: {
175
- ...descriptor.options,
176
- animation,
177
- cardOverlayEnabled,
178
- cardStyleInterpolator,
179
- gestureDirection,
180
- gestureEnabled,
181
- headerStyleInterpolator,
182
- transitionSpec,
183
- headerMode
184
- }
185
- },
186
- progress: {
187
- current: getProgressFromGesture(currentGesture, state.layout, descriptor.options, isRTL),
188
- next: nextGesture && nextOptions?.presentation !== 'transparentModal' ? getProgressFromGesture(nextGesture, state.layout, nextOptions, isRTL) : undefined,
189
- previous: previousGesture ? getProgressFromGesture(previousGesture, state.layout, previousOptions, isRTL) : undefined
190
- },
191
- __memo: [state.layout, descriptor, nextOptions, previousOptions, currentGesture, nextGesture, previousGesture]
192
- };
193
- if (oldScene && scene.__memo.every((it, i) => {
194
- // @ts-expect-error: we haven't added __memo to the annotation to prevent usage elsewhere
195
- return oldScene.__memo[i] === it;
196
- })) {
197
- return oldScene;
198
- }
199
- return scene;
200
- });
201
- let activeStates = state.activeStates;
202
- if (props.routes.length !== state.routes.length) {
203
- // amznmod_react - change activeScreensLimit from 1 to 2
204
- // Increase activeScreensLimit to prevent detaching the screen underneath
205
- // When performing a pop animation, the screen underneath is inactive and has to by mounted
206
- // This takes a long time and results with a noticeable delay when navigating between screens
207
- // @ts-ignore - accept kepler as a platform
208
- let activeScreensLimit = Platform.OS === 'kepler' ? 2 : 1;
209
- for (let i = props.routes.length - 1; i >= 0; i--) {
210
- const {
211
- options
212
- } = scenes[i].descriptor;
213
- const {
214
- // By default, we don't want to detach the previous screen of the active one for modals
215
- detachPreviousScreen = options.presentation === 'transparentModal' ? false : getIsModalPresentation(options.cardStyleInterpolator) ? i !== findLastIndex(scenes, scene => {
216
- const {
217
- cardStyleInterpolator
218
- } = scene.descriptor.options;
219
- return cardStyleInterpolator === forModalPresentationIOS || cardStyleInterpolator?.name === 'forModalPresentationIOS';
220
- }) : true
221
- } = options;
222
- if (detachPreviousScreen === false) {
223
- activeScreensLimit++;
224
- } else {
225
- // Check at least last 2 screens before stopping
226
- // This will make sure that screen isn't detached when another screen is animating on top of the transparent one
227
- // e.g. opaque -> transparent -> opaque
228
- if (i <= props.routes.length - 2) {
229
- break;
230
- }
231
- }
232
- }
233
- activeStates = props.routes.map((_, index, self) => {
234
- // The activity state represents state of the screen:
235
- // 0 - inactive, the screen is detached
236
- // 1 - transitioning or below the top screen, the screen is mounted but interaction is disabled
237
- // 2 - on top of the stack, the screen is mounted and interaction is enabled
238
- let activityState;
239
- const lastActiveState = state.activeStates[index];
240
- const activeAfterTransition = index >= self.length - activeScreensLimit;
241
- if (lastActiveState === STATE_INACTIVE && !activeAfterTransition) {
242
- // screen was inactive before and it will still be inactive after the transition
243
- activityState = STATE_INACTIVE;
244
- } else {
245
- const sceneForActivity = scenes[self.length - 1];
246
- const outputValue = index === self.length - 1 ? STATE_ON_TOP // the screen is on top after the transition
247
- : activeAfterTransition ? STATE_TRANSITIONING_OR_BELOW_TOP // the screen should stay active after the transition, it is not on top but is in activeLimit
248
- : STATE_INACTIVE; // the screen should be active only during the transition, it is at the edge of activeLimit
249
-
250
- activityState = sceneForActivity ? sceneForActivity.progress.current.interpolate({
251
- inputRange: [0, 1 - EPSILON, 1],
252
- outputRange: [1, 1, outputValue],
253
- extrapolate: 'clamp'
254
- }) : STATE_TRANSITIONING_OR_BELOW_TOP;
255
- }
256
- return activityState;
257
- });
258
- }
259
- return {
260
- routes: props.routes,
261
- scenes,
262
- gestures,
263
- descriptors: props.descriptors,
264
- activeStates,
265
- headerHeights: getHeaderHeights(scenes, props.insets, props.isParentHeaderShown, props.isParentModal, state.layout, state.headerHeights)
266
- };
267
- }
268
- constructor(props) {
269
- super(props);
270
- this.state = {
271
- routes: [],
272
- scenes: [],
273
- gestures: {},
274
- layout: SafeAreaProviderCompat.initialMetrics.frame,
275
- descriptors: this.props.descriptors,
276
- activeStates: [],
277
- // Used when card's header is null and mode is float to make transition
278
- // between screens with headers and those without headers smooth.
279
- // This is not a great heuristic here. We don't know synchronously
280
- // on mount what the header height is so we have just used the most
281
- // common cases here.
282
- headerHeights: {}
283
- };
284
- }
285
- handleLayout = e => {
286
- const {
287
- height,
288
- width
289
- } = e.nativeEvent.layout;
290
- const layout = {
291
- width,
292
- height
293
- };
294
- this.setState((state, props) => {
295
- if (height === state.layout.height && width === state.layout.width) {
296
- return null;
297
- }
298
- return {
299
- layout,
300
- headerHeights: getHeaderHeights(state.scenes, props.insets, props.isParentHeaderShown, props.isParentModal, layout, state.headerHeights)
301
- };
302
- });
303
- };
304
- handleHeaderLayout = ({
305
- route,
306
- height
307
- }) => {
308
- this.setState(({
309
- headerHeights
310
- }) => {
311
- const previousHeight = headerHeights[route.key];
312
- if (previousHeight === height) {
313
- return null;
314
- }
315
- return {
316
- headerHeights: {
317
- ...headerHeights,
318
- [route.key]: height
319
- }
320
- };
321
- });
322
- };
323
- getFocusedRoute = () => {
324
- const {
325
- state
326
- } = this.props;
327
- return state.routes[state.index];
328
- };
329
- getPreviousScene = ({
330
- route
331
- }) => {
332
- const {
333
- getPreviousRoute
334
- } = this.props;
335
- const {
336
- scenes
337
- } = this.state;
338
- const previousRoute = getPreviousRoute({
339
- route
340
- });
341
- if (previousRoute) {
342
- const previousScene = scenes.find(scene => scene.descriptor.route.key === previousRoute.key);
343
- return previousScene;
344
- }
345
- return undefined;
346
- };
347
- render() {
348
- const {
349
- insets,
350
- state,
351
- routes,
352
- openingRouteKeys,
353
- closingRouteKeys,
354
- onOpenRoute,
355
- onCloseRoute,
356
- renderHeader,
357
- isParentHeaderShown,
358
- isParentModal,
359
- onTransitionStart,
360
- onTransitionEnd,
361
- onGestureStart,
362
- onGestureEnd,
363
- onGestureCancel,
364
- detachInactiveScreens = Platform.OS === 'web' || Platform.OS === 'android' || Platform.OS === 'ios' ||
365
- // @ts-ignore - accept kepler as a platform
366
- Platform.OS === 'kepler'
367
- } = this.props;
368
- const {
369
- scenes,
370
- layout,
371
- gestures,
372
- activeStates,
373
- headerHeights
374
- } = this.state;
375
- const focusedRoute = state.routes[state.index];
376
- const focusedHeaderHeight = headerHeights[focusedRoute.key];
377
- const isFloatHeaderAbsolute = this.state.scenes.slice(-2).some(scene => {
378
- const options = scene.descriptor.options ?? {};
379
- const {
380
- headerMode,
381
- headerTransparent,
382
- headerShown = true
383
- } = options;
384
- if (headerTransparent || headerShown === false || headerMode === 'screen') {
385
- return true;
386
- }
387
- return false;
388
- });
389
- return /*#__PURE__*/_jsxs(View, {
390
- style: styles.container,
391
- children: [renderHeader({
392
- mode: 'float',
393
- layout,
394
- scenes,
395
- getPreviousScene: this.getPreviousScene,
396
- getFocusedRoute: this.getFocusedRoute,
397
- onContentHeightChange: this.handleHeaderLayout,
398
- style: [styles.floating, isFloatHeaderAbsolute && [
399
- // Without this, the header buttons won't be touchable on Android when headerTransparent: true
400
- {
401
- height: focusedHeaderHeight
402
- }, styles.absolute]]
403
- }), /*#__PURE__*/_jsx(MaybeScreenContainer, {
404
- enabled: detachInactiveScreens,
405
- style: styles.container,
406
- onLayout: this.handleLayout,
407
- children: [...routes, ...state.preloadedRoutes].map((route, index) => {
408
- const focused = focusedRoute.key === route.key;
409
- const gesture = gestures[route.key];
410
- const scene = scenes[index];
411
- // It is possible that for a short period the route appears in both arrays.
412
- // Particularly, if the screen is removed with `retain`, then it needs a moment to execute the animation.
413
- // However, due to the router action, it immediately populates the `preloadedRoutes` array.
414
- // Practically, the logic below takes care that it is rendered only once.
415
- const isPreloaded = state.preloadedRoutes.includes(route) && !routes.includes(route);
416
- if (state.preloadedRoutes.includes(route) && routes.includes(route) && index >= routes.length) {
417
- return null;
418
- }
419
- const {
420
- headerShown = true,
421
- headerTransparent,
422
- freezeOnBlur,
423
- autoHideHomeIndicator
424
- } = scene.descriptor.options;
425
- const safeAreaInsetTop = insets.top;
426
- const safeAreaInsetRight = insets.right;
427
- const safeAreaInsetBottom = insets.bottom;
428
- const safeAreaInsetLeft = insets.left;
429
- const headerHeight = headerShown !== false ? headerHeights[route.key] : 0;
430
-
431
- // Start from current card and count backwards the number of cards with same interpolation
432
- const interpolationIndex = getInterpolationIndex(scenes, index);
433
- const isModal = getIsModal(scene, interpolationIndex, isParentModal);
434
- const isNextScreenTransparent = scenes[index + 1]?.descriptor.options.presentation === 'transparentModal';
435
- const detachCurrentScreen = scenes[index + 1]?.descriptor.options.detachPreviousScreen !== false;
436
- const activityState = isPreloaded ? STATE_INACTIVE : activeStates[index];
437
- return /*#__PURE__*/_jsx(MaybeScreen, {
438
- style: [StyleSheet.absoluteFill],
439
- enabled: detachInactiveScreens,
440
- active: activityState,
441
- freezeOnBlur: freezeOnBlur,
442
- shouldFreeze: activityState === STATE_INACTIVE && !isPreloaded,
443
- homeIndicatorHidden: autoHideHomeIndicator,
444
- pointerEvents: "box-none",
445
- children: /*#__PURE__*/_jsx(CardContainer, {
446
- index: index,
447
- interpolationIndex: interpolationIndex,
448
- modal: isModal,
449
- active: index === routes.length - 1,
450
- focused: focused,
451
- opening: openingRouteKeys.includes(route.key),
452
- closing: closingRouteKeys.includes(route.key),
453
- layout: layout,
454
- gesture: gesture,
455
- scene: scene,
456
- safeAreaInsetTop: safeAreaInsetTop,
457
- safeAreaInsetRight: safeAreaInsetRight,
458
- safeAreaInsetBottom: safeAreaInsetBottom,
459
- safeAreaInsetLeft: safeAreaInsetLeft,
460
- onGestureStart: onGestureStart,
461
- onGestureCancel: onGestureCancel,
462
- onGestureEnd: onGestureEnd,
463
- headerHeight: headerHeight,
464
- isParentHeaderShown: isParentHeaderShown,
465
- onHeaderHeightChange: this.handleHeaderLayout,
466
- getPreviousScene: this.getPreviousScene,
467
- getFocusedRoute: this.getFocusedRoute,
468
- hasAbsoluteFloatHeader: isFloatHeaderAbsolute && !headerTransparent,
469
- renderHeader: renderHeader,
470
- onOpenRoute: onOpenRoute,
471
- onCloseRoute: onCloseRoute,
472
- onTransitionStart: onTransitionStart,
473
- onTransitionEnd: onTransitionEnd,
474
- isNextScreenTransparent: isNextScreenTransparent,
475
- detachCurrentScreen: detachCurrentScreen,
476
- preloaded: isPreloaded
477
- })
478
- }, route.key);
479
- })
480
- })]
481
- });
482
- }
483
- }
484
- const styles = StyleSheet.create({
485
- container: {
486
- flex: 1
487
- },
488
- absolute: {
489
- position: 'absolute',
490
- top: 0,
491
- start: 0,
492
- end: 0
493
- },
494
- floating: {
495
- zIndex: 1
496
- }
497
- });
498
- //# sourceMappingURL=CardStack.js.map