@react-navigation/stack 7.12.1 → 7.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/utils/gestureActivationCriteria.js +10 -8
- package/lib/module/utils/gestureActivationCriteria.js.map +1 -1
- package/lib/module/utils/useKeyboardManager.js +103 -9
- package/lib/module/utils/useKeyboardManager.js.map +1 -1
- package/lib/module/utils/viewIsDescendantOf.js +23 -0
- package/lib/module/utils/viewIsDescendantOf.js.map +1 -0
- package/lib/module/views/GestureHandler.js.map +1 -1
- package/lib/module/views/Header/Header.js +1 -1
- package/lib/module/views/InteractionManager.js +1 -0
- package/lib/module/views/InteractionManager.js.map +1 -1
- package/lib/module/views/Stack/Card.js +19 -15
- package/lib/module/views/Stack/Card.js.map +1 -1
- package/lib/module/views/Stack/CardContainer.js +7 -2
- package/lib/module/views/Stack/CardContainer.js.map +1 -1
- package/lib/module/views/Stack/CardContent.js +2 -2
- package/lib/module/views/Stack/CardStack.js +23 -7
- package/lib/module/views/Stack/CardStack.js.map +1 -1
- package/lib/module/views/Stack/StackView.js +37 -28
- package/lib/module/views/Stack/StackView.js.map +1 -1
- package/lib/typescript/src/types.d.ts +2 -2
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/conditional.d.ts +1 -1
- package/lib/typescript/src/utils/conditional.d.ts.map +1 -1
- package/lib/typescript/src/utils/gestureActivationCriteria.d.ts +2 -49
- package/lib/typescript/src/utils/gestureActivationCriteria.d.ts.map +1 -1
- package/lib/typescript/src/utils/useKeyboardManager.d.ts +5 -1
- package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +1 -1
- package/lib/typescript/src/utils/viewIsDescendantOf.d.ts +3 -0
- package/lib/typescript/src/utils/viewIsDescendantOf.d.ts.map +1 -0
- package/lib/typescript/src/views/GestureHandler.d.ts.map +1 -1
- package/lib/typescript/src/views/InteractionManager.d.ts.map +1 -1
- package/lib/typescript/src/views/Screens.d.ts +1 -1
- package/lib/typescript/src/views/Screens.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardStack.d.ts +1 -1
- package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/types.tsx +16 -2
- package/src/utils/gestureActivationCriteria.tsx +13 -9
- package/src/utils/useKeyboardManager.tsx +144 -8
- package/src/utils/viewIsDescendantOf.tsx +33 -0
- package/src/views/GestureHandler.tsx +1 -1
- package/src/views/Header/Header.tsx +1 -1
- package/src/views/InteractionManager.tsx +1 -0
- package/src/views/Screens.tsx +1 -1
- package/src/views/Stack/Card.tsx +23 -12
- package/src/views/Stack/CardContainer.tsx +4 -3
- package/src/views/Stack/CardContent.tsx +2 -2
- package/src/views/Stack/CardStack.tsx +34 -11
- package/src/views/Stack/StackView.tsx +58 -39
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type RouteProp,
|
|
11
11
|
StackActions,
|
|
12
12
|
type StackNavigationState,
|
|
13
|
+
ThemeContext,
|
|
13
14
|
} from '@react-navigation/native';
|
|
14
15
|
import * as React from 'react';
|
|
15
16
|
import { StyleSheet, View } from 'react-native';
|
|
@@ -154,6 +155,15 @@ export class StackView extends React.Component<Props, State> {
|
|
|
154
155
|
|
|
155
156
|
let { openingRouteKeys, closingRouteKeys, replacingRouteKeys } = state;
|
|
156
157
|
|
|
158
|
+
// A route can be removed before its opening animation finishes
|
|
159
|
+
// e.g. when it was replaced while opening, so stop tracking it
|
|
160
|
+
// If a route being replaced is added back, it's handled like a newly focused route
|
|
161
|
+
openingRouteKeys = openingRouteKeys.filter(
|
|
162
|
+
(key) =>
|
|
163
|
+
state.routes.some((r) => r.key === key) &&
|
|
164
|
+
!(replacingRouteKeys.includes(key) && routes.some((r) => r.key === key))
|
|
165
|
+
);
|
|
166
|
+
|
|
157
167
|
// If a route that was closing or being replaced is now back in the routes,
|
|
158
168
|
// it was added back before the animation finished, so stop tracking it
|
|
159
169
|
closingRouteKeys = closingRouteKeys.filter(
|
|
@@ -239,11 +249,11 @@ export class StackView extends React.Component<Props, State> {
|
|
|
239
249
|
if (!routes.some((r) => r.key === previousFocusedRoute.key)) {
|
|
240
250
|
// The previous focused route isn't present in state, we treat this as a replace
|
|
241
251
|
|
|
242
|
-
openingRouteKeys = openingRouteKeys.filter(
|
|
243
|
-
(key) => key !== previousFocusedRoute.key
|
|
244
|
-
);
|
|
245
|
-
|
|
246
252
|
if (getAnimationTypeForReplace(nextFocusedRoute.key) === 'pop') {
|
|
253
|
+
openingRouteKeys = openingRouteKeys.filter(
|
|
254
|
+
(key) => key !== previousFocusedRoute.key
|
|
255
|
+
);
|
|
256
|
+
|
|
247
257
|
closingRouteKeys = [
|
|
248
258
|
...closingRouteKeys,
|
|
249
259
|
previousFocusedRoute.key,
|
|
@@ -493,43 +503,52 @@ export class StackView extends React.Component<Props, State> {
|
|
|
493
503
|
}, {});
|
|
494
504
|
|
|
495
505
|
return (
|
|
496
|
-
<
|
|
497
|
-
|
|
498
|
-
<
|
|
499
|
-
{
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
506
|
+
<ThemeContext.Consumer>
|
|
507
|
+
{(theme) => (
|
|
508
|
+
<GestureHandlerWrapper
|
|
509
|
+
style={[
|
|
510
|
+
styles.container,
|
|
511
|
+
{ backgroundColor: theme?.colors.background },
|
|
512
|
+
]}
|
|
513
|
+
>
|
|
514
|
+
<SafeAreaProviderCompat>
|
|
515
|
+
<SafeAreaInsetsContext.Consumer>
|
|
516
|
+
{(insets) => (
|
|
517
|
+
<ModalPresentationContext.Consumer>
|
|
518
|
+
{(isParentModal) => (
|
|
519
|
+
<HeaderShownContext.Consumer>
|
|
520
|
+
{(isParentHeaderShown) => (
|
|
521
|
+
<CardStack
|
|
522
|
+
insets={insets!}
|
|
523
|
+
isParentHeaderShown={isParentHeaderShown}
|
|
524
|
+
isParentModal={isParentModal}
|
|
525
|
+
getPreviousRoute={this.getPreviousRoute}
|
|
526
|
+
routes={routes}
|
|
527
|
+
openingRouteKeys={openingRouteKeys}
|
|
528
|
+
closingRouteKeys={closingRouteKeys}
|
|
529
|
+
onOpenRoute={this.handleOpenRoute}
|
|
530
|
+
onCloseRoute={this.handleCloseRoute}
|
|
531
|
+
onTransitionStart={this.handleTransitionStart}
|
|
532
|
+
onTransitionEnd={this.handleTransitionEnd}
|
|
533
|
+
renderHeader={this.renderHeader}
|
|
534
|
+
state={state}
|
|
535
|
+
descriptors={descriptors}
|
|
536
|
+
onGestureStart={this.handleGestureStart}
|
|
537
|
+
onGestureEnd={this.handleGestureEnd}
|
|
538
|
+
onGestureCancel={this.handleGestureCancel}
|
|
539
|
+
preloadedDescriptors={preloadedDescriptors}
|
|
540
|
+
{...rest}
|
|
541
|
+
/>
|
|
542
|
+
)}
|
|
543
|
+
</HeaderShownContext.Consumer>
|
|
525
544
|
)}
|
|
526
|
-
</
|
|
545
|
+
</ModalPresentationContext.Consumer>
|
|
527
546
|
)}
|
|
528
|
-
</
|
|
529
|
-
|
|
530
|
-
</
|
|
531
|
-
|
|
532
|
-
</
|
|
547
|
+
</SafeAreaInsetsContext.Consumer>
|
|
548
|
+
</SafeAreaProviderCompat>
|
|
549
|
+
</GestureHandlerWrapper>
|
|
550
|
+
)}
|
|
551
|
+
</ThemeContext.Consumer>
|
|
533
552
|
);
|
|
534
553
|
}
|
|
535
554
|
}
|