@amazon-devices/react-navigation__stack 8.0.9000000000 → 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 (81) hide show
  1. package/SystemModules/amzn__react-navigation__stack-8.private.modules.txt +39 -34
  2. package/kepler-compatibility.json +4 -2
  3. package/lib/module/index.js +0 -34
  4. package/lib/typescript/src/index.d.ts +1 -1
  5. package/lib/typescript/src/index.d.ts.map +1 -1
  6. package/oss-attribution/attribution.txt +76 -0
  7. package/oss-attribution/licenseInfos.json +27 -0
  8. package/package.json +1 -1
  9. package/src/index.tsx +0 -55
  10. package/SystemBundles/98ca5eeb45684e3e5615c766e1d3a956fee53d14cd6c2318098c23c210bd76d7.bundle +0 -13464
  11. package/SystemBundles/98ca5eeb45684e3e5615c766e1d3a956fee53d14cd6c2318098c23c210bd76d7.map +0 -4638
  12. package/lib/module/TransitionConfigs/CardStyleInterpolators.js +0 -394
  13. package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +0 -262
  14. package/lib/module/TransitionConfigs/TransitionPresets.js +0 -156
  15. package/lib/module/TransitionConfigs/TransitionSpecs.js +0 -124
  16. package/lib/module/navigators/createStackNavigator.js +0 -71
  17. package/lib/module/types.js +0 -4
  18. package/lib/module/utils/CardAnimationContext.js +0 -5
  19. package/lib/module/utils/GestureHandlerRefContext.js +0 -5
  20. package/lib/module/utils/ModalPresentationContext.js +0 -5
  21. package/lib/module/utils/conditional.js +0 -28
  22. package/lib/module/utils/findLastIndex.js +0 -11
  23. package/lib/module/utils/gestureActivationCriteria.js +0 -60
  24. package/lib/module/utils/getDistanceForDirection.js +0 -15
  25. package/lib/module/utils/getInvertedMultiplier.js +0 -15
  26. package/lib/module/utils/getModalRoutesKeys.js +0 -12
  27. package/lib/module/utils/getShadowStyle.js +0 -24
  28. package/lib/module/utils/throttle.js +0 -14
  29. package/lib/module/utils/useCardAnimation.js +0 -12
  30. package/lib/module/utils/useGestureHandlerRef.js +0 -12
  31. package/lib/module/utils/useKeyboardManager.js +0 -90
  32. package/lib/module/views/GestureHandler.android.js +0 -4
  33. package/lib/module/views/GestureHandler.ios.js +0 -4
  34. package/lib/module/views/GestureHandler.js +0 -21
  35. package/lib/module/views/GestureHandler.kepler.js +0 -4
  36. package/lib/module/views/GestureHandlerNative.js +0 -18
  37. package/lib/module/views/Header/Header.js +0 -56
  38. package/lib/module/views/Header/HeaderContainer.js +0 -128
  39. package/lib/module/views/Header/HeaderSegment.js +0 -142
  40. package/lib/module/views/Screens.js +0 -42
  41. package/lib/module/views/Stack/Card.js +0 -433
  42. package/lib/module/views/Stack/CardA11yWrapper.js +0 -43
  43. package/lib/module/views/Stack/CardContainer.js +0 -276
  44. package/lib/module/views/Stack/CardContent.js +0 -74
  45. package/lib/module/views/Stack/CardStack.js +0 -493
  46. package/lib/module/views/Stack/StackView.js +0 -339
  47. package/src/TransitionConfigs/CardStyleInterpolators.tsx +0 -460
  48. package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +0 -286
  49. package/src/TransitionConfigs/TransitionPresets.tsx +0 -182
  50. package/src/TransitionConfigs/TransitionSpecs.tsx +0 -124
  51. package/src/navigators/createStackNavigator.tsx +0 -120
  52. package/src/types.tsx +0 -639
  53. package/src/utils/CardAnimationContext.tsx +0 -7
  54. package/src/utils/GestureHandlerRefContext.tsx +0 -5
  55. package/src/utils/ModalPresentationContext.tsx +0 -3
  56. package/src/utils/conditional.tsx +0 -33
  57. package/src/utils/findLastIndex.tsx +0 -9
  58. package/src/utils/gestureActivationCriteria.tsx +0 -70
  59. package/src/utils/getDistanceForDirection.tsx +0 -19
  60. package/src/utils/getInvertedMultiplier.tsx +0 -17
  61. package/src/utils/getModalRoutesKeys.ts +0 -21
  62. package/src/utils/getShadowStyle.tsx +0 -37
  63. package/src/utils/throttle.tsx +0 -16
  64. package/src/utils/useCardAnimation.tsx +0 -15
  65. package/src/utils/useGestureHandlerRef.tsx +0 -15
  66. package/src/utils/useKeyboardManager.tsx +0 -103
  67. package/src/views/GestureHandler.android.tsx +0 -1
  68. package/src/views/GestureHandler.ios.tsx +0 -1
  69. package/src/views/GestureHandler.kepler.tsx +0 -1
  70. package/src/views/GestureHandler.tsx +0 -23
  71. package/src/views/GestureHandlerNative.tsx +0 -23
  72. package/src/views/Header/Header.tsx +0 -73
  73. package/src/views/Header/HeaderContainer.tsx +0 -191
  74. package/src/views/Header/HeaderSegment.tsx +0 -203
  75. package/src/views/Screens.tsx +0 -45
  76. package/src/views/Stack/Card.tsx +0 -646
  77. package/src/views/Stack/CardA11yWrapper.tsx +0 -67
  78. package/src/views/Stack/CardContainer.tsx +0 -339
  79. package/src/views/Stack/CardContent.tsx +0 -92
  80. package/src/views/Stack/CardStack.tsx +0 -844
  81. package/src/views/Stack/StackView.tsx +0 -485
@@ -1,493 +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
- let activeScreensLimit = 1;
204
- for (let i = props.routes.length - 1; i >= 0; i--) {
205
- const {
206
- options
207
- } = scenes[i].descriptor;
208
- const {
209
- // By default, we don't want to detach the previous screen of the active one for modals
210
- detachPreviousScreen = options.presentation === 'transparentModal' ? false : getIsModalPresentation(options.cardStyleInterpolator) ? i !== findLastIndex(scenes, scene => {
211
- const {
212
- cardStyleInterpolator
213
- } = scene.descriptor.options;
214
- return cardStyleInterpolator === forModalPresentationIOS || cardStyleInterpolator?.name === 'forModalPresentationIOS';
215
- }) : true
216
- } = options;
217
- if (detachPreviousScreen === false) {
218
- activeScreensLimit++;
219
- } else {
220
- // Check at least last 2 screens before stopping
221
- // This will make sure that screen isn't detached when another screen is animating on top of the transparent one
222
- // e.g. opaque -> transparent -> opaque
223
- if (i <= props.routes.length - 2) {
224
- break;
225
- }
226
- }
227
- }
228
- activeStates = props.routes.map((_, index, self) => {
229
- // The activity state represents state of the screen:
230
- // 0 - inactive, the screen is detached
231
- // 1 - transitioning or below the top screen, the screen is mounted but interaction is disabled
232
- // 2 - on top of the stack, the screen is mounted and interaction is enabled
233
- let activityState;
234
- const lastActiveState = state.activeStates[index];
235
- const activeAfterTransition = index >= self.length - activeScreensLimit;
236
- if (lastActiveState === STATE_INACTIVE && !activeAfterTransition) {
237
- // screen was inactive before and it will still be inactive after the transition
238
- activityState = STATE_INACTIVE;
239
- } else {
240
- const sceneForActivity = scenes[self.length - 1];
241
- const outputValue = index === self.length - 1 ? STATE_ON_TOP // the screen is on top after the transition
242
- : activeAfterTransition ? STATE_TRANSITIONING_OR_BELOW_TOP // the screen should stay active after the transition, it is not on top but is in activeLimit
243
- : STATE_INACTIVE; // the screen should be active only during the transition, it is at the edge of activeLimit
244
-
245
- activityState = sceneForActivity ? sceneForActivity.progress.current.interpolate({
246
- inputRange: [0, 1 - EPSILON, 1],
247
- outputRange: [1, 1, outputValue],
248
- extrapolate: 'clamp'
249
- }) : STATE_TRANSITIONING_OR_BELOW_TOP;
250
- }
251
- return activityState;
252
- });
253
- }
254
- return {
255
- routes: props.routes,
256
- scenes,
257
- gestures,
258
- descriptors: props.descriptors,
259
- activeStates,
260
- headerHeights: getHeaderHeights(scenes, props.insets, props.isParentHeaderShown, props.isParentModal, state.layout, state.headerHeights)
261
- };
262
- }
263
- constructor(props) {
264
- super(props);
265
- this.state = {
266
- routes: [],
267
- scenes: [],
268
- gestures: {},
269
- layout: SafeAreaProviderCompat.initialMetrics.frame,
270
- descriptors: this.props.descriptors,
271
- activeStates: [],
272
- // Used when card's header is null and mode is float to make transition
273
- // between screens with headers and those without headers smooth.
274
- // This is not a great heuristic here. We don't know synchronously
275
- // on mount what the header height is so we have just used the most
276
- // common cases here.
277
- headerHeights: {}
278
- };
279
- }
280
- handleLayout = e => {
281
- const {
282
- height,
283
- width
284
- } = e.nativeEvent.layout;
285
- const layout = {
286
- width,
287
- height
288
- };
289
- this.setState((state, props) => {
290
- if (height === state.layout.height && width === state.layout.width) {
291
- return null;
292
- }
293
- return {
294
- layout,
295
- headerHeights: getHeaderHeights(state.scenes, props.insets, props.isParentHeaderShown, props.isParentModal, layout, state.headerHeights)
296
- };
297
- });
298
- };
299
- handleHeaderLayout = ({
300
- route,
301
- height
302
- }) => {
303
- this.setState(({
304
- headerHeights
305
- }) => {
306
- const previousHeight = headerHeights[route.key];
307
- if (previousHeight === height) {
308
- return null;
309
- }
310
- return {
311
- headerHeights: {
312
- ...headerHeights,
313
- [route.key]: height
314
- }
315
- };
316
- });
317
- };
318
- getFocusedRoute = () => {
319
- const {
320
- state
321
- } = this.props;
322
- return state.routes[state.index];
323
- };
324
- getPreviousScene = ({
325
- route
326
- }) => {
327
- const {
328
- getPreviousRoute
329
- } = this.props;
330
- const {
331
- scenes
332
- } = this.state;
333
- const previousRoute = getPreviousRoute({
334
- route
335
- });
336
- if (previousRoute) {
337
- const previousScene = scenes.find(scene => scene.descriptor.route.key === previousRoute.key);
338
- return previousScene;
339
- }
340
- return undefined;
341
- };
342
- render() {
343
- const {
344
- insets,
345
- state,
346
- routes,
347
- openingRouteKeys,
348
- closingRouteKeys,
349
- onOpenRoute,
350
- onCloseRoute,
351
- renderHeader,
352
- isParentHeaderShown,
353
- isParentModal,
354
- onTransitionStart,
355
- onTransitionEnd,
356
- onGestureStart,
357
- onGestureEnd,
358
- onGestureCancel,
359
- detachInactiveScreens = Platform.OS === 'web' || Platform.OS === 'android' || Platform.OS === 'ios' ||
360
- // @ts-ignore - accept kepler as a platform
361
- Platform.OS === 'kepler'
362
- } = this.props;
363
- const {
364
- scenes,
365
- layout,
366
- gestures,
367
- activeStates,
368
- headerHeights
369
- } = this.state;
370
- const focusedRoute = state.routes[state.index];
371
- const focusedHeaderHeight = headerHeights[focusedRoute.key];
372
- const isFloatHeaderAbsolute = this.state.scenes.slice(-2).some(scene => {
373
- const options = scene.descriptor.options ?? {};
374
- const {
375
- headerMode,
376
- headerTransparent,
377
- headerShown = true
378
- } = options;
379
- if (headerTransparent || headerShown === false || headerMode === 'screen') {
380
- return true;
381
- }
382
- return false;
383
- });
384
- return /*#__PURE__*/_jsxs(View, {
385
- style: styles.container,
386
- children: [renderHeader({
387
- mode: 'float',
388
- layout,
389
- scenes,
390
- getPreviousScene: this.getPreviousScene,
391
- getFocusedRoute: this.getFocusedRoute,
392
- onContentHeightChange: this.handleHeaderLayout,
393
- style: [styles.floating, isFloatHeaderAbsolute && [
394
- // Without this, the header buttons won't be touchable on Android when headerTransparent: true
395
- {
396
- height: focusedHeaderHeight
397
- }, styles.absolute]]
398
- }), /*#__PURE__*/_jsx(MaybeScreenContainer, {
399
- enabled: detachInactiveScreens,
400
- style: styles.container,
401
- onLayout: this.handleLayout,
402
- children: [...routes, ...state.preloadedRoutes].map((route, index) => {
403
- const focused = focusedRoute.key === route.key;
404
- const gesture = gestures[route.key];
405
- const scene = scenes[index];
406
- // It is possible that for a short period the route appears in both arrays.
407
- // Particularly, if the screen is removed with `retain`, then it needs a moment to execute the animation.
408
- // However, due to the router action, it immediately populates the `preloadedRoutes` array.
409
- // Practically, the logic below takes care that it is rendered only once.
410
- const isPreloaded = state.preloadedRoutes.includes(route) && !routes.includes(route);
411
- if (state.preloadedRoutes.includes(route) && routes.includes(route) && index >= routes.length) {
412
- return null;
413
- }
414
- const {
415
- headerShown = true,
416
- headerTransparent,
417
- freezeOnBlur,
418
- autoHideHomeIndicator
419
- } = scene.descriptor.options;
420
- const safeAreaInsetTop = insets.top;
421
- const safeAreaInsetRight = insets.right;
422
- const safeAreaInsetBottom = insets.bottom;
423
- const safeAreaInsetLeft = insets.left;
424
- const headerHeight = headerShown !== false ? headerHeights[route.key] : 0;
425
-
426
- // Start from current card and count backwards the number of cards with same interpolation
427
- const interpolationIndex = getInterpolationIndex(scenes, index);
428
- const isModal = getIsModal(scene, interpolationIndex, isParentModal);
429
- const isNextScreenTransparent = scenes[index + 1]?.descriptor.options.presentation === 'transparentModal';
430
- const detachCurrentScreen = scenes[index + 1]?.descriptor.options.detachPreviousScreen !== false;
431
- const activityState = isPreloaded ? STATE_INACTIVE : activeStates[index];
432
- return /*#__PURE__*/_jsx(MaybeScreen, {
433
- style: [StyleSheet.absoluteFill],
434
- enabled: detachInactiveScreens,
435
- active: activityState,
436
- freezeOnBlur: freezeOnBlur,
437
- shouldFreeze: activityState === STATE_INACTIVE && !isPreloaded,
438
- homeIndicatorHidden: autoHideHomeIndicator,
439
- pointerEvents: "box-none",
440
- children: /*#__PURE__*/_jsx(CardContainer, {
441
- index: index,
442
- interpolationIndex: interpolationIndex,
443
- modal: isModal,
444
- active: index === routes.length - 1,
445
- focused: focused,
446
- opening: openingRouteKeys.includes(route.key),
447
- closing: closingRouteKeys.includes(route.key),
448
- layout: layout,
449
- gesture: gesture,
450
- scene: scene,
451
- safeAreaInsetTop: safeAreaInsetTop,
452
- safeAreaInsetRight: safeAreaInsetRight,
453
- safeAreaInsetBottom: safeAreaInsetBottom,
454
- safeAreaInsetLeft: safeAreaInsetLeft,
455
- onGestureStart: onGestureStart,
456
- onGestureCancel: onGestureCancel,
457
- onGestureEnd: onGestureEnd,
458
- headerHeight: headerHeight,
459
- isParentHeaderShown: isParentHeaderShown,
460
- onHeaderHeightChange: this.handleHeaderLayout,
461
- getPreviousScene: this.getPreviousScene,
462
- getFocusedRoute: this.getFocusedRoute,
463
- hasAbsoluteFloatHeader: isFloatHeaderAbsolute && !headerTransparent,
464
- renderHeader: renderHeader,
465
- onOpenRoute: onOpenRoute,
466
- onCloseRoute: onCloseRoute,
467
- onTransitionStart: onTransitionStart,
468
- onTransitionEnd: onTransitionEnd,
469
- isNextScreenTransparent: isNextScreenTransparent,
470
- detachCurrentScreen: detachCurrentScreen,
471
- preloaded: isPreloaded
472
- })
473
- }, route.key);
474
- })
475
- })]
476
- });
477
- }
478
- }
479
- const styles = StyleSheet.create({
480
- container: {
481
- flex: 1
482
- },
483
- absolute: {
484
- position: 'absolute',
485
- top: 0,
486
- start: 0,
487
- end: 0
488
- },
489
- floating: {
490
- zIndex: 1
491
- }
492
- });
493
- //# sourceMappingURL=CardStack.js.map