@react-navigation/stack 7.0.5 → 7.0.7
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/commonjs/views/Stack/Card.js +9 -0
- package/lib/commonjs/views/Stack/Card.js.map +1 -1
- package/lib/commonjs/views/Stack/CardContainer.js +2 -0
- package/lib/commonjs/views/Stack/CardContainer.js.map +1 -1
- package/lib/commonjs/views/Stack/CardStack.js +4 -1
- package/lib/commonjs/views/Stack/CardStack.js.map +1 -1
- package/lib/commonjs/views/Stack/StackView.js +19 -21
- package/lib/commonjs/views/Stack/StackView.js.map +1 -1
- package/lib/module/views/Stack/Card.js +9 -0
- package/lib/module/views/Stack/Card.js.map +1 -1
- package/lib/module/views/Stack/CardContainer.js +2 -0
- package/lib/module/views/Stack/CardContainer.js.map +1 -1
- package/lib/module/views/Stack/CardStack.js +6 -3
- package/lib/module/views/Stack/CardStack.js.map +1 -1
- package/lib/module/views/Stack/StackView.js +19 -21
- package/lib/module/views/Stack/StackView.js.map +1 -1
- package/lib/typescript/commonjs/src/views/Stack/Card.d.ts +1 -0
- package/lib/typescript/commonjs/src/views/Stack/Card.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/Stack/CardContainer.d.ts +2 -1
- package/lib/typescript/commonjs/src/views/Stack/CardContainer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/views/Stack/StackView.d.ts.map +1 -1
- package/lib/typescript/commonjs/tsconfig.build.tsbuildinfo +1 -1
- package/lib/typescript/module/src/views/Stack/Card.d.ts +1 -0
- package/lib/typescript/module/src/views/Stack/Card.d.ts.map +1 -1
- package/lib/typescript/module/src/views/Stack/CardContainer.d.ts +2 -1
- package/lib/typescript/module/src/views/Stack/CardContainer.d.ts.map +1 -1
- package/lib/typescript/module/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/module/src/views/Stack/StackView.d.ts.map +1 -1
- package/lib/typescript/module/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +12 -12
- package/src/views/Stack/Card.tsx +11 -1
- package/src/views/Stack/CardContainer.tsx +3 -0
- package/src/views/Stack/CardStack.tsx +5 -3
- package/src/views/Stack/StackView.tsx +29 -28
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": "7.0.
|
|
4
|
+
"version": "7.0.7",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native-component",
|
|
7
7
|
"react-component",
|
|
@@ -51,26 +51,26 @@
|
|
|
51
51
|
"clean": "del lib"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@react-navigation/elements": "^2.1.
|
|
54
|
+
"@react-navigation/elements": "^2.1.1",
|
|
55
55
|
"color": "^4.2.3"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@jest/globals": "^29.7.0",
|
|
59
|
-
"@react-navigation/native": "^7.0.
|
|
60
|
-
"@testing-library/react-native": "^12.
|
|
59
|
+
"@react-navigation/native": "^7.0.4",
|
|
60
|
+
"@testing-library/react-native": "^12.8.1",
|
|
61
61
|
"@types/color": "^3.0.6",
|
|
62
|
-
"@types/react": "~18.
|
|
62
|
+
"@types/react": "~18.3.12",
|
|
63
63
|
"del-cli": "^5.1.0",
|
|
64
|
-
"react": "18.
|
|
65
|
-
"react-native": "0.
|
|
64
|
+
"react": "18.3.1",
|
|
65
|
+
"react-native": "0.76.2",
|
|
66
66
|
"react-native-builder-bob": "^0.29.0",
|
|
67
|
-
"react-native-gesture-handler": "~2.
|
|
68
|
-
"react-native-safe-area-context": "4.
|
|
69
|
-
"react-native-screens": "
|
|
67
|
+
"react-native-gesture-handler": "~2.20.2",
|
|
68
|
+
"react-native-safe-area-context": "4.12.0",
|
|
69
|
+
"react-native-screens": "^4.3.0",
|
|
70
70
|
"typescript": "^5.5.2"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@react-navigation/native": "^7.0.
|
|
73
|
+
"@react-navigation/native": "^7.0.4",
|
|
74
74
|
"react": ">= 18.2.0",
|
|
75
75
|
"react-native": "*",
|
|
76
76
|
"react-native-gesture-handler": ">= 2.0.0",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
]
|
|
103
103
|
]
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "046ed593f82d1e5ecfe411c6db6bf25c5e04ff7b"
|
|
106
106
|
}
|
package/src/views/Stack/Card.tsx
CHANGED
|
@@ -34,6 +34,7 @@ import { CardSheet, type CardSheetRef } from './CardSheet';
|
|
|
34
34
|
|
|
35
35
|
type Props = ViewProps & {
|
|
36
36
|
interpolationIndex: number;
|
|
37
|
+
opening: boolean;
|
|
37
38
|
closing: boolean;
|
|
38
39
|
next?: Animated.AnimatedInterpolation<number>;
|
|
39
40
|
current: Animated.AnimatedInterpolation<number>;
|
|
@@ -115,7 +116,8 @@ export class Card extends React.Component<Props> {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
componentDidUpdate(prevProps: Props) {
|
|
118
|
-
const { direction, layout, gestureDirection, closing } =
|
|
119
|
+
const { gesture, direction, layout, gestureDirection, opening, closing } =
|
|
120
|
+
this.props;
|
|
119
121
|
const { width, height } = layout;
|
|
120
122
|
|
|
121
123
|
if (width !== prevProps.layout.width) {
|
|
@@ -143,6 +145,14 @@ export class Card extends React.Component<Props> {
|
|
|
143
145
|
// When route was closed due to a gesture, the animation would've happened already
|
|
144
146
|
// It's still important to trigger the animation so that `onClose` is called
|
|
145
147
|
// If `onClose` is not called, cleanup step won't be performed for gestures
|
|
148
|
+
this.animate({ closing });
|
|
149
|
+
} else if (opening && !prevProps.opening) {
|
|
150
|
+
// This can happen when screen somewhere below in the stack comes into focus via rearranging
|
|
151
|
+
// Also reset the animated value to make sure that the animation starts from the beginning
|
|
152
|
+
gesture.setValue(
|
|
153
|
+
getDistanceForDirection(layout, gestureDirection, direction === 'rtl')
|
|
154
|
+
);
|
|
155
|
+
|
|
146
156
|
this.animate({ closing });
|
|
147
157
|
}
|
|
148
158
|
}
|
|
@@ -24,6 +24,7 @@ type Props = {
|
|
|
24
24
|
index: number;
|
|
25
25
|
active: boolean;
|
|
26
26
|
focused: boolean;
|
|
27
|
+
opening: boolean;
|
|
27
28
|
closing: boolean;
|
|
28
29
|
modal: boolean;
|
|
29
30
|
layout: Layout;
|
|
@@ -64,6 +65,7 @@ function CardContainerInner({
|
|
|
64
65
|
interpolationIndex,
|
|
65
66
|
index,
|
|
66
67
|
active,
|
|
68
|
+
opening,
|
|
67
69
|
closing,
|
|
68
70
|
gesture,
|
|
69
71
|
focused,
|
|
@@ -240,6 +242,7 @@ function CardContainerInner({
|
|
|
240
242
|
gesture={gesture}
|
|
241
243
|
current={scene.progress.current}
|
|
242
244
|
next={scene.progress.next}
|
|
245
|
+
opening={opening}
|
|
243
246
|
closing={closing}
|
|
244
247
|
onOpen={handleOpen}
|
|
245
248
|
onClose={handleClose}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Background,
|
|
3
2
|
getDefaultHeaderHeight,
|
|
4
3
|
SafeAreaProviderCompat,
|
|
5
4
|
} from '@react-navigation/elements';
|
|
@@ -15,6 +14,7 @@ import {
|
|
|
15
14
|
type LayoutChangeEvent,
|
|
16
15
|
Platform,
|
|
17
16
|
StyleSheet,
|
|
17
|
+
View,
|
|
18
18
|
} from 'react-native';
|
|
19
19
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
20
20
|
|
|
@@ -569,6 +569,7 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
569
569
|
insets,
|
|
570
570
|
state,
|
|
571
571
|
routes,
|
|
572
|
+
openingRouteKeys,
|
|
572
573
|
closingRouteKeys,
|
|
573
574
|
onOpenRoute,
|
|
574
575
|
onCloseRoute,
|
|
@@ -660,7 +661,7 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
660
661
|
);
|
|
661
662
|
|
|
662
663
|
return (
|
|
663
|
-
<
|
|
664
|
+
<View style={styles.container}>
|
|
664
665
|
{isFloatHeaderAbsolute ? null : floatingHeader}
|
|
665
666
|
<MaybeScreenContainer
|
|
666
667
|
enabled={detachInactiveScreens}
|
|
@@ -762,6 +763,7 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
762
763
|
modal={isModal}
|
|
763
764
|
active={index === routes.length - 1}
|
|
764
765
|
focused={focused}
|
|
766
|
+
opening={openingRouteKeys.includes(route.key)}
|
|
765
767
|
closing={closingRouteKeys.includes(route.key)}
|
|
766
768
|
layout={layout}
|
|
767
769
|
gesture={gesture}
|
|
@@ -795,7 +797,7 @@ export class CardStack extends React.Component<Props, State> {
|
|
|
795
797
|
})}
|
|
796
798
|
</MaybeScreenContainer>
|
|
797
799
|
{isFloatHeaderAbsolute ? floatingHeader : null}
|
|
798
|
-
</
|
|
800
|
+
</View>
|
|
799
801
|
);
|
|
800
802
|
}
|
|
801
803
|
}
|
|
@@ -158,9 +158,35 @@ export class StackView extends React.Component<Props, State> {
|
|
|
158
158
|
// We only need to animate routes if the focused route changed
|
|
159
159
|
// Animating previous routes won't be visible coz the focused route is on top of everything
|
|
160
160
|
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
if (
|
|
162
|
+
previousRoutes.some((r) => r.key === nextFocusedRoute.key) &&
|
|
163
|
+
!routes.some((r) => r.key === previousFocusedRoute.key)
|
|
164
|
+
) {
|
|
165
|
+
// The previously focused route was removed, and the new focused route was already present
|
|
166
|
+
// We treat this as a pop
|
|
167
|
+
|
|
168
|
+
if (
|
|
169
|
+
isAnimationEnabled(previousFocusedRoute.key) &&
|
|
170
|
+
!closingRouteKeys.includes(previousFocusedRoute.key)
|
|
171
|
+
) {
|
|
172
|
+
closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];
|
|
173
|
+
|
|
174
|
+
// Sometimes a route can be closed before the opening animation finishes
|
|
175
|
+
// So we also need to remove it from the opening list
|
|
176
|
+
openingRouteKeys = openingRouteKeys.filter(
|
|
177
|
+
(key) => key !== previousFocusedRoute.key
|
|
178
|
+
);
|
|
179
|
+
replacingRouteKeys = replacingRouteKeys.filter(
|
|
180
|
+
(key) => key !== previousFocusedRoute.key
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
// Keep a copy of route being removed in the state to be able to animate it
|
|
184
|
+
routes = [...routes, previousFocusedRoute];
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
// A route has come to the focus, we treat this as a push
|
|
188
|
+
// A replace or rearranging can also trigger this
|
|
189
|
+
// The animation should look like push
|
|
164
190
|
|
|
165
191
|
if (
|
|
166
192
|
isAnimationEnabled(nextFocusedRoute.key) &&
|
|
@@ -217,31 +243,6 @@ export class StackView extends React.Component<Props, State> {
|
|
|
217
243
|
}
|
|
218
244
|
}
|
|
219
245
|
}
|
|
220
|
-
} else if (!routes.some((r) => r.key === previousFocusedRoute.key)) {
|
|
221
|
-
// The previously focused route was removed, we treat this as a pop
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
isAnimationEnabled(previousFocusedRoute.key) &&
|
|
225
|
-
!closingRouteKeys.includes(previousFocusedRoute.key)
|
|
226
|
-
) {
|
|
227
|
-
closingRouteKeys = [...closingRouteKeys, previousFocusedRoute.key];
|
|
228
|
-
|
|
229
|
-
// Sometimes a route can be closed before the opening animation finishes
|
|
230
|
-
// So we also need to remove it from the opening list
|
|
231
|
-
openingRouteKeys = openingRouteKeys.filter(
|
|
232
|
-
(key) => key !== previousFocusedRoute.key
|
|
233
|
-
);
|
|
234
|
-
replacingRouteKeys = replacingRouteKeys.filter(
|
|
235
|
-
(key) => key !== previousFocusedRoute.key
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
// Keep a copy of route being removed in the state to be able to animate it
|
|
239
|
-
routes = [...routes, previousFocusedRoute];
|
|
240
|
-
}
|
|
241
|
-
} else {
|
|
242
|
-
// Looks like some routes were re-arranged and no focused routes were added/removed
|
|
243
|
-
// i.e. the currently focused route already existed and the previously focused route still exists
|
|
244
|
-
// We don't know how to animate this
|
|
245
246
|
}
|
|
246
247
|
} else if (replacingRouteKeys.length || closingRouteKeys.length) {
|
|
247
248
|
// Keep the routes we are closing or replacing if animation is enabled for them
|