@react-navigation/stack 7.0.0-alpha.1 → 7.0.0-alpha.10
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/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
- package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js +19 -12
- package/lib/commonjs/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
- package/lib/commonjs/TransitionConfigs/TransitionPresets.js +11 -21
- package/lib/commonjs/TransitionConfigs/TransitionPresets.js.map +1 -1
- package/lib/commonjs/TransitionConfigs/TransitionSpecs.js +7 -14
- package/lib/commonjs/TransitionConfigs/TransitionSpecs.js.map +1 -1
- package/lib/commonjs/index.js +2 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/navigators/createStackNavigator.js +32 -24
- package/lib/commonjs/navigators/createStackNavigator.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/CardAnimationContext.js +3 -4
- package/lib/commonjs/utils/CardAnimationContext.js.map +1 -1
- package/lib/commonjs/utils/GestureHandlerRefContext.js +3 -4
- package/lib/commonjs/utils/GestureHandlerRefContext.js.map +1 -1
- package/lib/commonjs/utils/ModalPresentationContext.js +3 -4
- package/lib/commonjs/utils/ModalPresentationContext.js.map +1 -1
- package/lib/commonjs/utils/conditional.js.map +1 -1
- package/lib/commonjs/utils/debounce.js.map +1 -1
- package/lib/commonjs/utils/findLastIndex.js +1 -1
- package/lib/commonjs/utils/findLastIndex.js.map +1 -1
- package/lib/commonjs/utils/getDistanceForDirection.js +2 -2
- package/lib/commonjs/utils/getDistanceForDirection.js.map +1 -1
- package/lib/commonjs/utils/getInvertedMultiplier.js +3 -4
- package/lib/commonjs/utils/getInvertedMultiplier.js.map +1 -1
- package/lib/commonjs/utils/memoize.js.map +1 -1
- package/lib/commonjs/utils/useCardAnimation.js +2 -2
- package/lib/commonjs/utils/useCardAnimation.js.map +1 -1
- package/lib/commonjs/utils/useGestureHandlerRef.js +2 -2
- package/lib/commonjs/utils/useGestureHandlerRef.js.map +1 -1
- package/lib/commonjs/utils/useKeyboardManager.js +6 -6
- package/lib/commonjs/utils/useKeyboardManager.js.map +1 -1
- package/lib/commonjs/views/GestureHandler.android.js.map +1 -1
- package/lib/commonjs/views/GestureHandler.ios.js.map +1 -1
- package/lib/commonjs/views/GestureHandler.js +5 -8
- package/lib/commonjs/views/GestureHandler.js.map +1 -1
- package/lib/commonjs/views/GestureHandlerNative.js +2 -2
- package/lib/commonjs/views/GestureHandlerNative.js.map +1 -1
- package/lib/commonjs/views/Header/Header.js +4 -4
- package/lib/commonjs/views/Header/Header.js.map +1 -1
- package/lib/commonjs/views/Header/HeaderContainer.js +12 -9
- package/lib/commonjs/views/Header/HeaderContainer.js.map +1 -1
- package/lib/commonjs/views/Header/HeaderSegment.js +11 -3
- package/lib/commonjs/views/Header/HeaderSegment.js.map +1 -1
- package/lib/commonjs/views/Screens.js +2 -2
- package/lib/commonjs/views/Screens.js.map +1 -1
- package/lib/commonjs/views/Stack/Card.js +48 -41
- package/lib/commonjs/views/Stack/Card.js.map +1 -1
- package/lib/commonjs/views/Stack/CardContainer.js +25 -21
- package/lib/commonjs/views/Stack/CardContainer.js.map +1 -1
- package/lib/commonjs/views/Stack/CardSheet.js +24 -4
- package/lib/commonjs/views/Stack/CardSheet.js.map +1 -1
- package/lib/commonjs/views/Stack/CardStack.js +58 -60
- package/lib/commonjs/views/Stack/CardStack.js.map +1 -1
- package/lib/commonjs/views/Stack/StackView.js +26 -30
- package/lib/commonjs/views/Stack/StackView.js.map +1 -1
- package/lib/module/TransitionConfigs/CardStyleInterpolators.js.map +1 -1
- package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js +20 -13
- package/lib/module/TransitionConfigs/HeaderStyleInterpolators.js.map +1 -1
- package/lib/module/TransitionConfigs/TransitionPresets.js +1 -1
- package/lib/module/TransitionConfigs/TransitionPresets.js.map +1 -1
- package/lib/module/TransitionConfigs/TransitionSpecs.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createStackNavigator.js +30 -21
- package/lib/module/navigators/createStackNavigator.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/CardAnimationContext.js.map +1 -1
- package/lib/module/utils/GestureHandlerRefContext.js.map +1 -1
- package/lib/module/utils/ModalPresentationContext.js.map +1 -1
- package/lib/module/utils/conditional.js.map +1 -1
- package/lib/module/utils/debounce.js.map +1 -1
- package/lib/module/utils/findLastIndex.js +1 -1
- package/lib/module/utils/findLastIndex.js.map +1 -1
- package/lib/module/utils/getDistanceForDirection.js +2 -2
- package/lib/module/utils/getDistanceForDirection.js.map +1 -1
- package/lib/module/utils/getInvertedMultiplier.js +3 -4
- package/lib/module/utils/getInvertedMultiplier.js.map +1 -1
- package/lib/module/utils/memoize.js.map +1 -1
- package/lib/module/utils/useCardAnimation.js.map +1 -1
- package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
- package/lib/module/utils/useKeyboardManager.js +4 -4
- package/lib/module/utils/useKeyboardManager.js.map +1 -1
- package/lib/module/views/GestureHandler.android.js.map +1 -1
- package/lib/module/views/GestureHandler.ios.js.map +1 -1
- package/lib/module/views/GestureHandler.js.map +1 -1
- package/lib/module/views/GestureHandlerNative.js.map +1 -1
- package/lib/module/views/Header/Header.js +1 -0
- package/lib/module/views/Header/Header.js.map +1 -1
- package/lib/module/views/Header/HeaderContainer.js +11 -8
- package/lib/module/views/Header/HeaderContainer.js.map +1 -1
- package/lib/module/views/Header/HeaderSegment.js +9 -1
- package/lib/module/views/Header/HeaderSegment.js.map +1 -1
- package/lib/module/views/Screens.js.map +1 -1
- package/lib/module/views/Stack/Card.js +45 -37
- package/lib/module/views/Stack/Card.js.map +1 -1
- package/lib/module/views/Stack/CardContainer.js +23 -18
- package/lib/module/views/Stack/CardContainer.js.map +1 -1
- package/lib/module/views/Stack/CardSheet.js +21 -0
- package/lib/module/views/Stack/CardSheet.js.map +1 -1
- package/lib/module/views/Stack/CardStack.js +53 -54
- package/lib/module/views/Stack/CardStack.js.map +1 -1
- package/lib/module/views/Stack/StackView.js +24 -28
- package/lib/module/views/Stack/StackView.js.map +1 -1
- package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts +3 -3
- package/lib/typescript/src/TransitionConfigs/HeaderStyleInterpolators.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createStackNavigator.d.ts +4 -4
- package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +47 -9
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/getDistanceForDirection.d.ts +1 -1
- package/lib/typescript/src/utils/getDistanceForDirection.d.ts.map +1 -1
- package/lib/typescript/src/utils/getInvertedMultiplier.d.ts +1 -1
- package/lib/typescript/src/utils/getInvertedMultiplier.d.ts.map +1 -1
- package/lib/typescript/src/views/GestureHandlerNative.d.ts +3 -3
- package/lib/typescript/src/views/GestureHandlerNative.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderContainer.d.ts +4 -4
- package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts +3 -2
- package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
- package/lib/typescript/src/views/Screens.d.ts +4 -3
- package/lib/typescript/src/views/Screens.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/Card.d.ts +6 -5
- package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardContainer.d.ts +3 -6
- package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardSheet.d.ts +1 -1
- package/lib/typescript/src/views/Stack/CardSheet.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardStack.d.ts +4 -5
- package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/StackView.d.ts +9 -80
- package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
- package/package.json +20 -21
- package/src/TransitionConfigs/CardStyleInterpolators.tsx +5 -5
- package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +32 -22
- package/src/TransitionConfigs/TransitionPresets.tsx +4 -4
- package/src/navigators/createStackNavigator.tsx +18 -7
- package/src/types.tsx +50 -10
- package/src/utils/findLastIndex.tsx +1 -1
- package/src/utils/getDistanceForDirection.tsx +3 -2
- package/src/utils/getInvertedMultiplier.tsx +4 -5
- package/src/utils/useKeyboardManager.tsx +1 -1
- package/src/views/GestureHandlerNative.tsx +1 -1
- package/src/views/Header/Header.tsx +3 -2
- package/src/views/Header/HeaderContainer.tsx +17 -6
- package/src/views/Header/HeaderSegment.tsx +12 -4
- package/src/views/Screens.tsx +2 -1
- package/src/views/Stack/Card.tsx +75 -56
- package/src/views/Stack/CardContainer.tsx +18 -9
- package/src/views/Stack/CardSheet.tsx +25 -1
- package/src/views/Stack/CardStack.tsx +216 -186
- package/src/views/Stack/StackView.tsx +24 -27
- package/lib/commonjs/views/ModalStatusBarManager.js +0 -44
- package/lib/commonjs/views/ModalStatusBarManager.js.map +0 -1
- package/lib/module/views/ModalStatusBarManager.js +0 -36
- package/lib/module/views/ModalStatusBarManager.js.map +0 -1
- package/lib/typescript/src/views/ModalStatusBarManager.d.ts +0 -12
- package/lib/typescript/src/views/ModalStatusBarManager.d.ts.map +0 -1
- package/src/views/ModalStatusBarManager.tsx +0 -45
package/src/types.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
HeaderBackButton,
|
|
3
3
|
HeaderBackButtonProps,
|
|
4
|
-
HeaderButtonProps,
|
|
5
4
|
HeaderOptions,
|
|
6
5
|
HeaderTitleProps,
|
|
7
6
|
} from '@react-navigation/elements';
|
|
8
7
|
import type {
|
|
9
8
|
Descriptor,
|
|
9
|
+
LocaleDirection,
|
|
10
10
|
NavigationHelpers,
|
|
11
11
|
NavigationProp,
|
|
12
12
|
ParamListBase,
|
|
@@ -50,7 +50,7 @@ export type StackNavigationHelpers = NavigationHelpers<
|
|
|
50
50
|
export type StackNavigationProp<
|
|
51
51
|
ParamList extends ParamListBase,
|
|
52
52
|
RouteName extends keyof ParamList = keyof ParamList,
|
|
53
|
-
NavigatorID extends string | undefined = undefined
|
|
53
|
+
NavigatorID extends string | undefined = undefined,
|
|
54
54
|
> = NavigationProp<
|
|
55
55
|
ParamList,
|
|
56
56
|
RouteName,
|
|
@@ -64,7 +64,7 @@ export type StackNavigationProp<
|
|
|
64
64
|
export type StackScreenProps<
|
|
65
65
|
ParamList extends ParamListBase,
|
|
66
66
|
RouteName extends keyof ParamList = keyof ParamList,
|
|
67
|
-
NavigatorID extends string | undefined = undefined
|
|
67
|
+
NavigatorID extends string | undefined = undefined,
|
|
68
68
|
> = {
|
|
69
69
|
navigation: StackNavigationProp<ParamList, RouteName, NavigatorID>;
|
|
70
70
|
route: RouteProp<ParamList, RouteName>;
|
|
@@ -139,11 +139,11 @@ export type StackHeaderOptions = Omit<
|
|
|
139
139
|
/**
|
|
140
140
|
* Function which returns a React Element to display on the left side of the header.
|
|
141
141
|
*/
|
|
142
|
-
headerLeft?: (props:
|
|
142
|
+
headerLeft?: (props: StackHeaderLeftProps) => React.ReactNode;
|
|
143
143
|
/**
|
|
144
144
|
* Function which returns a React Element to display on the right side of the header.
|
|
145
145
|
*/
|
|
146
|
-
headerRight?: (props:
|
|
146
|
+
headerRight?: (props: StackHeaderRightProps) => React.ReactNode;
|
|
147
147
|
/**
|
|
148
148
|
* Whether back button title font should scale to respect Text Size accessibility settings. Defaults to `false`.
|
|
149
149
|
*/
|
|
@@ -196,7 +196,11 @@ export type StackHeaderProps = {
|
|
|
196
196
|
/**
|
|
197
197
|
* Title of the previous screen.
|
|
198
198
|
*/
|
|
199
|
-
title: string;
|
|
199
|
+
title: string | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* The `href` to use for the anchor tag on web
|
|
202
|
+
*/
|
|
203
|
+
href: string | undefined;
|
|
200
204
|
};
|
|
201
205
|
/**
|
|
202
206
|
* Animated nodes representing the progress of the animation.
|
|
@@ -220,6 +224,32 @@ export type StackHeaderProps = {
|
|
|
220
224
|
styleInterpolator: StackHeaderStyleInterpolator;
|
|
221
225
|
};
|
|
222
226
|
|
|
227
|
+
export type StackHeaderRightProps = {
|
|
228
|
+
/**
|
|
229
|
+
* Tint color for the header button.
|
|
230
|
+
*/
|
|
231
|
+
tintColor?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Color for material ripple (Android >= 5.0 only).
|
|
234
|
+
*/
|
|
235
|
+
pressColor?: string;
|
|
236
|
+
/**
|
|
237
|
+
* Opacity when the button is pressed, used when ripple is not supported.
|
|
238
|
+
*/
|
|
239
|
+
pressOpacity?: number;
|
|
240
|
+
/**
|
|
241
|
+
* Whether it's possible to navigate back in stack.
|
|
242
|
+
*/
|
|
243
|
+
canGoBack?: boolean;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export type StackHeaderLeftProps = HeaderBackButtonProps & {
|
|
247
|
+
/**
|
|
248
|
+
* Whether it's possible to navigate back in stack.
|
|
249
|
+
*/
|
|
250
|
+
canGoBack?: boolean;
|
|
251
|
+
};
|
|
252
|
+
|
|
223
253
|
export type StackDescriptor = Descriptor<
|
|
224
254
|
StackNavigationOptions,
|
|
225
255
|
StackNavigationProp<ParamListBase>,
|
|
@@ -341,6 +371,12 @@ export type StackNavigationOptions = StackHeaderOptions &
|
|
|
341
371
|
* Only supported on iOS and Android.
|
|
342
372
|
*/
|
|
343
373
|
freezeOnBlur?: boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Whether the home indicator should prefer to stay hidden on this screen. Defaults to `false`.
|
|
376
|
+
*
|
|
377
|
+
* @platform ios
|
|
378
|
+
*/
|
|
379
|
+
autoHideHomeIndicator?: boolean;
|
|
344
380
|
};
|
|
345
381
|
|
|
346
382
|
export type StackNavigationConfig = {
|
|
@@ -429,19 +465,19 @@ export type StackCardInterpolatedStyle = {
|
|
|
429
465
|
/**
|
|
430
466
|
* Interpolated style for the container view wrapping the card.
|
|
431
467
|
*/
|
|
432
|
-
containerStyle?:
|
|
468
|
+
containerStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
433
469
|
/**
|
|
434
470
|
* Interpolated style for the view representing the card.
|
|
435
471
|
*/
|
|
436
|
-
cardStyle?:
|
|
472
|
+
cardStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
437
473
|
/**
|
|
438
474
|
* Interpolated style for the view representing the semi-transparent overlay below the card.
|
|
439
475
|
*/
|
|
440
|
-
overlayStyle?:
|
|
476
|
+
overlayStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
441
477
|
/**
|
|
442
478
|
* Interpolated style representing the card shadow.
|
|
443
479
|
*/
|
|
444
|
-
shadowStyle?:
|
|
480
|
+
shadowStyle?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
445
481
|
};
|
|
446
482
|
|
|
447
483
|
export type StackCardStyleInterpolator = (
|
|
@@ -468,6 +504,10 @@ export type StackHeaderInterpolationProps = {
|
|
|
468
504
|
*/
|
|
469
505
|
progress: Animated.AnimatedInterpolation<number>;
|
|
470
506
|
};
|
|
507
|
+
/**
|
|
508
|
+
* Writing direction of the layout.
|
|
509
|
+
*/
|
|
510
|
+
direction: LocaleDirection;
|
|
471
511
|
/**
|
|
472
512
|
* Layout measurements for various items we use for animation.
|
|
473
513
|
*/
|
|
@@ -3,9 +3,10 @@ import { getInvertedMultiplier } from './getInvertedMultiplier';
|
|
|
3
3
|
|
|
4
4
|
export function getDistanceForDirection(
|
|
5
5
|
layout: Layout,
|
|
6
|
-
gestureDirection: GestureDirection
|
|
6
|
+
gestureDirection: GestureDirection,
|
|
7
|
+
isRTL: boolean
|
|
7
8
|
): number {
|
|
8
|
-
const multiplier = getInvertedMultiplier(gestureDirection);
|
|
9
|
+
const multiplier = getInvertedMultiplier(gestureDirection, isRTL);
|
|
9
10
|
|
|
10
11
|
switch (gestureDirection) {
|
|
11
12
|
case 'vertical':
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { I18nManager } from 'react-native';
|
|
2
|
-
|
|
3
1
|
import type { GestureDirection } from '../types';
|
|
4
2
|
|
|
5
3
|
export function getInvertedMultiplier(
|
|
6
|
-
gestureDirection: GestureDirection
|
|
4
|
+
gestureDirection: GestureDirection,
|
|
5
|
+
isRTL: boolean
|
|
7
6
|
): 1 | -1 {
|
|
8
7
|
switch (gestureDirection) {
|
|
9
8
|
case 'vertical':
|
|
@@ -11,8 +10,8 @@ export function getInvertedMultiplier(
|
|
|
11
10
|
case 'vertical-inverted':
|
|
12
11
|
return -1;
|
|
13
12
|
case 'horizontal':
|
|
14
|
-
return
|
|
13
|
+
return isRTL ? -1 : 1;
|
|
15
14
|
case 'horizontal-inverted':
|
|
16
|
-
return
|
|
15
|
+
return isRTL ? 1 : -1;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
PanGestureHandler as PanGestureHandlerNative,
|
|
4
|
-
PanGestureHandlerProperties,
|
|
4
|
+
type PanGestureHandlerProperties,
|
|
5
5
|
} from 'react-native-gesture-handler';
|
|
6
6
|
|
|
7
7
|
import { GestureHandlerRefContext } from '../utils/GestureHandlerRefContext';
|
|
@@ -49,8 +49,8 @@ export const Header = React.memo(function Header({
|
|
|
49
49
|
options.headerStatusBarHeight !== undefined
|
|
50
50
|
? options.headerStatusBarHeight
|
|
51
51
|
: isModal || isParentHeaderShown
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
? 0
|
|
53
|
+
: insets.top;
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
56
|
<HeaderSegment
|
|
@@ -66,6 +66,7 @@ export const Header = React.memo(function Header({
|
|
|
66
66
|
}
|
|
67
67
|
headerStatusBarHeight={statusBarHeight}
|
|
68
68
|
onGoBack={back ? goBack : undefined}
|
|
69
|
+
backHref={back ? back.href : undefined}
|
|
69
70
|
styleInterpolator={styleInterpolator}
|
|
70
71
|
/>
|
|
71
72
|
);
|
|
@@ -2,11 +2,18 @@ import { getHeaderTitle, HeaderBackContext } from '@react-navigation/elements';
|
|
|
2
2
|
import {
|
|
3
3
|
NavigationContext,
|
|
4
4
|
NavigationRouteContext,
|
|
5
|
-
ParamListBase,
|
|
6
|
-
Route,
|
|
5
|
+
type ParamListBase,
|
|
6
|
+
type Route,
|
|
7
|
+
useLinkBuilder,
|
|
7
8
|
} from '@react-navigation/native';
|
|
8
9
|
import * as React from 'react';
|
|
9
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Animated,
|
|
12
|
+
type StyleProp,
|
|
13
|
+
StyleSheet,
|
|
14
|
+
View,
|
|
15
|
+
type ViewStyle,
|
|
16
|
+
} from 'react-native';
|
|
10
17
|
|
|
11
18
|
import {
|
|
12
19
|
forNoAnimation,
|
|
@@ -47,6 +54,7 @@ export function HeaderContainer({
|
|
|
47
54
|
}: Props) {
|
|
48
55
|
const focusedRoute = getFocusedRoute();
|
|
49
56
|
const parentHeaderBack = React.useContext(HeaderBackContext);
|
|
57
|
+
const { buildHref } = useLinkBuilder();
|
|
50
58
|
|
|
51
59
|
return (
|
|
52
60
|
<Animated.View pointerEvents="box-none" style={style}>
|
|
@@ -78,7 +86,10 @@ export function HeaderContainer({
|
|
|
78
86
|
const { options, route } = previousScene.descriptor;
|
|
79
87
|
|
|
80
88
|
headerBack = previousScene
|
|
81
|
-
? {
|
|
89
|
+
? {
|
|
90
|
+
title: getHeaderTitle(options, route.name),
|
|
91
|
+
href: buildHref(route.name, route.params),
|
|
92
|
+
}
|
|
82
93
|
: parentHeaderBack;
|
|
83
94
|
}
|
|
84
95
|
|
|
@@ -128,8 +139,8 @@ export function HeaderContainer({
|
|
|
128
139
|
nextHeaderlessGestureDirection === 'vertical-inverted'
|
|
129
140
|
? forSlideUp
|
|
130
141
|
: nextHeaderlessGestureDirection === 'horizontal-inverted'
|
|
131
|
-
|
|
132
|
-
|
|
142
|
+
? forSlideRight
|
|
143
|
+
: forSlideLeft
|
|
133
144
|
: headerStyleInterpolator
|
|
134
145
|
: forNoAnimation,
|
|
135
146
|
};
|
|
@@ -2,16 +2,17 @@ import {
|
|
|
2
2
|
getDefaultHeaderHeight,
|
|
3
3
|
Header,
|
|
4
4
|
HeaderBackButton,
|
|
5
|
-
HeaderBackButtonProps,
|
|
5
|
+
type HeaderBackButtonProps,
|
|
6
6
|
HeaderTitle,
|
|
7
7
|
} from '@react-navigation/elements';
|
|
8
|
+
import { useLocale } from '@react-navigation/native';
|
|
8
9
|
import * as React from 'react';
|
|
9
10
|
import {
|
|
10
11
|
Animated,
|
|
11
|
-
LayoutChangeEvent,
|
|
12
|
+
type LayoutChangeEvent,
|
|
12
13
|
Platform,
|
|
13
14
|
StyleSheet,
|
|
14
|
-
ViewStyle,
|
|
15
|
+
type ViewStyle,
|
|
15
16
|
} from 'react-native';
|
|
16
17
|
|
|
17
18
|
import type {
|
|
@@ -28,11 +29,14 @@ type Props = Omit<StackHeaderOptions, 'headerStatusBarHeight'> & {
|
|
|
28
29
|
title: string;
|
|
29
30
|
modal: boolean;
|
|
30
31
|
onGoBack?: () => void;
|
|
32
|
+
backHref?: string;
|
|
31
33
|
progress: SceneProgress;
|
|
32
34
|
styleInterpolator: StackHeaderStyleInterpolator;
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
export function HeaderSegment(props: Props) {
|
|
38
|
+
const { direction } = useLocale();
|
|
39
|
+
|
|
36
40
|
const [leftLabelLayout, setLeftLabelLayout] = React.useState<
|
|
37
41
|
Layout | undefined
|
|
38
42
|
>(undefined);
|
|
@@ -84,6 +88,7 @@ export function HeaderSegment(props: Props) {
|
|
|
84
88
|
styleInterpolator({
|
|
85
89
|
current: { progress: current },
|
|
86
90
|
next: next && { progress: next },
|
|
91
|
+
direction,
|
|
87
92
|
layouts: {
|
|
88
93
|
header: {
|
|
89
94
|
height: headerHeight,
|
|
@@ -101,9 +106,12 @@ export function HeaderSegment(props: Props) {
|
|
|
101
106
|
layout,
|
|
102
107
|
modal,
|
|
103
108
|
onGoBack,
|
|
109
|
+
backHref,
|
|
104
110
|
headerTitle: title,
|
|
105
111
|
headerLeft: left = onGoBack
|
|
106
|
-
? (props: HeaderBackButtonProps) =>
|
|
112
|
+
? (props: HeaderBackButtonProps) => (
|
|
113
|
+
<HeaderBackButton {...props} href={backHref} />
|
|
114
|
+
)
|
|
107
115
|
: undefined,
|
|
108
116
|
headerRight: right,
|
|
109
117
|
headerBackImage,
|
package/src/views/Screens.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Animated, View, ViewProps } from 'react-native';
|
|
2
|
+
import { Animated, View, type ViewProps } from 'react-native';
|
|
3
3
|
|
|
4
4
|
let Screens: typeof import('react-native-screens') | undefined;
|
|
5
5
|
|
|
@@ -32,6 +32,7 @@ export const MaybeScreen = ({
|
|
|
32
32
|
active: 0 | 1 | Animated.AnimatedInterpolation<0 | 1>;
|
|
33
33
|
children: React.ReactNode;
|
|
34
34
|
freezeOnBlur?: boolean;
|
|
35
|
+
homeIndicatorHidden?: boolean;
|
|
35
36
|
}) => {
|
|
36
37
|
if (Screens != null) {
|
|
37
38
|
return (
|
package/src/views/Stack/Card.tsx
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import type { LocaleDirection } from '@react-navigation/native';
|
|
1
2
|
import Color from 'color';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import {
|
|
4
5
|
Animated,
|
|
5
6
|
InteractionManager,
|
|
6
7
|
Platform,
|
|
7
|
-
StyleProp,
|
|
8
|
+
type StyleProp,
|
|
8
9
|
StyleSheet,
|
|
9
10
|
View,
|
|
10
|
-
ViewProps,
|
|
11
|
-
ViewStyle,
|
|
11
|
+
type ViewProps,
|
|
12
|
+
type ViewStyle,
|
|
12
13
|
} from 'react-native';
|
|
13
14
|
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
14
15
|
|
|
15
|
-
import { forModalPresentationIOS } from '../../TransitionConfigs/CardStyleInterpolators';
|
|
16
16
|
import type {
|
|
17
17
|
GestureDirection,
|
|
18
18
|
Layout,
|
|
@@ -27,10 +27,9 @@ import { memoize } from '../../utils/memoize';
|
|
|
27
27
|
import {
|
|
28
28
|
GestureState,
|
|
29
29
|
PanGestureHandler,
|
|
30
|
-
PanGestureHandlerGestureEvent,
|
|
30
|
+
type PanGestureHandlerGestureEvent,
|
|
31
31
|
} from '../GestureHandler';
|
|
32
|
-
import {
|
|
33
|
-
import { CardSheet, CardSheetRef } from './CardSheet';
|
|
32
|
+
import { CardSheet, type CardSheetRef } from './CardSheet';
|
|
34
33
|
|
|
35
34
|
type Props = ViewProps & {
|
|
36
35
|
interpolationIndex: number;
|
|
@@ -40,7 +39,7 @@ type Props = ViewProps & {
|
|
|
40
39
|
gesture: Animated.Value;
|
|
41
40
|
layout: Layout;
|
|
42
41
|
insets: EdgeInsets;
|
|
43
|
-
|
|
42
|
+
direction: LocaleDirection;
|
|
44
43
|
pageOverflowEnabled: boolean;
|
|
45
44
|
gestureDirection: GestureDirection;
|
|
46
45
|
onOpen: () => void;
|
|
@@ -62,6 +61,7 @@ type Props = ViewProps & {
|
|
|
62
61
|
open: TransitionSpec;
|
|
63
62
|
close: TransitionSpec;
|
|
64
63
|
};
|
|
64
|
+
preloaded: boolean;
|
|
65
65
|
styleInterpolator: StackCardStyleInterpolator;
|
|
66
66
|
containerStyle?: StyleProp<ViewStyle>;
|
|
67
67
|
contentStyle?: StyleProp<ViewStyle>;
|
|
@@ -105,12 +105,16 @@ export class Card extends React.Component<Props> {
|
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
componentDidMount() {
|
|
108
|
-
|
|
108
|
+
if (!this.props.preloaded) {
|
|
109
|
+
this.animate({
|
|
110
|
+
closing: this.props.closing,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
109
113
|
this.isCurrentlyMounted = true;
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
componentDidUpdate(prevProps: Props) {
|
|
113
|
-
const { layout, gestureDirection, closing } = this.props;
|
|
117
|
+
const { direction, layout, gestureDirection, closing } = this.props;
|
|
114
118
|
const { width, height } = layout;
|
|
115
119
|
|
|
116
120
|
if (width !== prevProps.layout.width) {
|
|
@@ -122,7 +126,9 @@ export class Card extends React.Component<Props> {
|
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
if (gestureDirection !== prevProps.gestureDirection) {
|
|
125
|
-
this.inverted.setValue(
|
|
129
|
+
this.inverted.setValue(
|
|
130
|
+
getInvertedMultiplier(gestureDirection, direction === 'rtl')
|
|
131
|
+
);
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
const toValue = this.getAnimateToValue(this.props);
|
|
@@ -132,7 +138,7 @@ export class Card extends React.Component<Props> {
|
|
|
132
138
|
this.lastToValue !== toValue
|
|
133
139
|
) {
|
|
134
140
|
// We need to trigger the animation when route was closed
|
|
135
|
-
//
|
|
141
|
+
// The route might have been closed by a `POP` action or by a gesture
|
|
136
142
|
// When route was closed due to a gesture, the animation would've happened already
|
|
137
143
|
// It's still important to trigger the animation so that `onClose` is called
|
|
138
144
|
// If `onClose` is not called, cleanup step won't be performed for gestures
|
|
@@ -141,7 +147,7 @@ export class Card extends React.Component<Props> {
|
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
componentWillUnmount() {
|
|
144
|
-
this.props.gesture
|
|
150
|
+
this.props.gesture?.stopAnimation();
|
|
145
151
|
this.isCurrentlyMounted = false;
|
|
146
152
|
this.handleEndInteraction();
|
|
147
153
|
}
|
|
@@ -151,7 +157,10 @@ export class Card extends React.Component<Props> {
|
|
|
151
157
|
private isClosing = new Animated.Value(FALSE);
|
|
152
158
|
|
|
153
159
|
private inverted = new Animated.Value(
|
|
154
|
-
getInvertedMultiplier(
|
|
160
|
+
getInvertedMultiplier(
|
|
161
|
+
this.props.gestureDirection,
|
|
162
|
+
this.props.direction === 'rtl'
|
|
163
|
+
)
|
|
155
164
|
);
|
|
156
165
|
|
|
157
166
|
private layout = {
|
|
@@ -174,7 +183,7 @@ export class Card extends React.Component<Props> {
|
|
|
174
183
|
closing: boolean;
|
|
175
184
|
velocity?: number;
|
|
176
185
|
}) => {
|
|
177
|
-
const {
|
|
186
|
+
const { transitionSpec, onOpen, onClose, onTransition, gesture } =
|
|
178
187
|
this.props;
|
|
179
188
|
|
|
180
189
|
const toValue = this.getAnimateToValue({
|
|
@@ -227,16 +236,24 @@ export class Card extends React.Component<Props> {
|
|
|
227
236
|
closing,
|
|
228
237
|
layout,
|
|
229
238
|
gestureDirection,
|
|
239
|
+
direction,
|
|
240
|
+
preloaded,
|
|
230
241
|
}: {
|
|
231
242
|
closing?: boolean;
|
|
232
243
|
layout: Layout;
|
|
233
244
|
gestureDirection: GestureDirection;
|
|
245
|
+
direction: LocaleDirection;
|
|
246
|
+
preloaded: boolean;
|
|
234
247
|
}) => {
|
|
235
|
-
if (!closing) {
|
|
248
|
+
if (!closing && !preloaded) {
|
|
236
249
|
return 0;
|
|
237
250
|
}
|
|
238
251
|
|
|
239
|
-
return getDistanceForDirection(
|
|
252
|
+
return getDistanceForDirection(
|
|
253
|
+
layout,
|
|
254
|
+
gestureDirection,
|
|
255
|
+
direction === 'rtl'
|
|
256
|
+
);
|
|
240
257
|
};
|
|
241
258
|
|
|
242
259
|
private setPointerEventsEnabled = (enabled: boolean) => {
|
|
@@ -262,6 +279,7 @@ export class Card extends React.Component<Props> {
|
|
|
262
279
|
nativeEvent,
|
|
263
280
|
}: PanGestureHandlerGestureEvent) => {
|
|
264
281
|
const {
|
|
282
|
+
direction,
|
|
265
283
|
layout,
|
|
266
284
|
onClose,
|
|
267
285
|
onGestureBegin,
|
|
@@ -277,7 +295,8 @@ export class Card extends React.Component<Props> {
|
|
|
277
295
|
this.handleStartInteraction();
|
|
278
296
|
onGestureBegin?.();
|
|
279
297
|
break;
|
|
280
|
-
case GestureState.CANCELLED:
|
|
298
|
+
case GestureState.CANCELLED:
|
|
299
|
+
case GestureState.FAILED: {
|
|
281
300
|
this.isSwiping.setValue(FALSE);
|
|
282
301
|
this.handleEndInteraction();
|
|
283
302
|
|
|
@@ -287,7 +306,10 @@ export class Card extends React.Component<Props> {
|
|
|
287
306
|
? nativeEvent.velocityY
|
|
288
307
|
: nativeEvent.velocityX;
|
|
289
308
|
|
|
290
|
-
this.animate({
|
|
309
|
+
this.animate({
|
|
310
|
+
closing: this.props.closing,
|
|
311
|
+
velocity,
|
|
312
|
+
});
|
|
291
313
|
|
|
292
314
|
onGestureCanceled?.();
|
|
293
315
|
break;
|
|
@@ -314,7 +336,7 @@ export class Card extends React.Component<Props> {
|
|
|
314
336
|
|
|
315
337
|
const closing =
|
|
316
338
|
(translation + velocity * gestureVelocityImpact) *
|
|
317
|
-
getInvertedMultiplier(gestureDirection) >
|
|
339
|
+
getInvertedMultiplier(gestureDirection, direction === 'rtl') >
|
|
318
340
|
distance / 2
|
|
319
341
|
? velocity !== 0 || translation !== 0
|
|
320
342
|
: this.props.closing;
|
|
@@ -378,16 +400,17 @@ export class Card extends React.Component<Props> {
|
|
|
378
400
|
);
|
|
379
401
|
|
|
380
402
|
private gestureActivationCriteria() {
|
|
381
|
-
const { layout, gestureDirection, gestureResponseDistance } =
|
|
403
|
+
const { direction, layout, gestureDirection, gestureResponseDistance } =
|
|
404
|
+
this.props;
|
|
382
405
|
const enableTrackpadTwoFingerGesture = true;
|
|
383
406
|
|
|
384
407
|
const distance =
|
|
385
408
|
gestureResponseDistance !== undefined
|
|
386
409
|
? gestureResponseDistance
|
|
387
410
|
: gestureDirection === 'vertical' ||
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
411
|
+
gestureDirection === 'vertical-inverted'
|
|
412
|
+
? GESTURE_RESPONSE_DISTANCE_VERTICAL
|
|
413
|
+
: GESTURE_RESPONSE_DISTANCE_HORIZONTAL;
|
|
391
414
|
|
|
392
415
|
if (gestureDirection === 'vertical') {
|
|
393
416
|
return {
|
|
@@ -405,7 +428,10 @@ export class Card extends React.Component<Props> {
|
|
|
405
428
|
};
|
|
406
429
|
} else {
|
|
407
430
|
const hitSlop = -layout.width + distance;
|
|
408
|
-
const invertedMultiplier = getInvertedMultiplier(
|
|
431
|
+
const invertedMultiplier = getInvertedMultiplier(
|
|
432
|
+
gestureDirection,
|
|
433
|
+
direction === 'rtl'
|
|
434
|
+
);
|
|
409
435
|
|
|
410
436
|
if (invertedMultiplier === 1) {
|
|
411
437
|
return {
|
|
@@ -442,10 +468,22 @@ export class Card extends React.Component<Props> {
|
|
|
442
468
|
gestureEnabled,
|
|
443
469
|
gestureDirection,
|
|
444
470
|
pageOverflowEnabled,
|
|
445
|
-
headerDarkContent,
|
|
446
471
|
children,
|
|
447
472
|
containerStyle: customContainerStyle,
|
|
448
473
|
contentStyle,
|
|
474
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
475
|
+
closing,
|
|
476
|
+
direction,
|
|
477
|
+
gestureResponseDistance,
|
|
478
|
+
gestureVelocityImpact,
|
|
479
|
+
onClose,
|
|
480
|
+
onGestureBegin,
|
|
481
|
+
onGestureCanceled,
|
|
482
|
+
onGestureEnd,
|
|
483
|
+
onOpen,
|
|
484
|
+
onTransition,
|
|
485
|
+
transitionSpec,
|
|
486
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
449
487
|
...rest
|
|
450
488
|
} = this.props;
|
|
451
489
|
|
|
@@ -491,21 +529,6 @@ export class Card extends React.Component<Props> {
|
|
|
491
529
|
|
|
492
530
|
return (
|
|
493
531
|
<CardAnimationContext.Provider value={interpolationProps}>
|
|
494
|
-
{
|
|
495
|
-
// StatusBar messes with translucent status bar on Android
|
|
496
|
-
// So we should only enable it on iOS
|
|
497
|
-
Platform.OS === 'ios' &&
|
|
498
|
-
overlayEnabled &&
|
|
499
|
-
next &&
|
|
500
|
-
getIsModalPresentation(styleInterpolator) ? (
|
|
501
|
-
<ModalStatusBarManager
|
|
502
|
-
dark={headerDarkContent}
|
|
503
|
-
layout={layout}
|
|
504
|
-
insets={insets}
|
|
505
|
-
style={cardStyle}
|
|
506
|
-
/>
|
|
507
|
-
) : null
|
|
508
|
-
}
|
|
509
532
|
<Animated.View
|
|
510
533
|
style={{
|
|
511
534
|
// This is a dummy style that doesn't actually change anything visually.
|
|
@@ -517,7 +540,13 @@ export class Card extends React.Component<Props> {
|
|
|
517
540
|
// Make sure that this view isn't removed. If this view is removed, our style with animated value won't apply
|
|
518
541
|
collapsable={false}
|
|
519
542
|
/>
|
|
520
|
-
<View
|
|
543
|
+
<View
|
|
544
|
+
pointerEvents="box-none"
|
|
545
|
+
// Make sure this view is not removed on the new architecture, as it causes focus loss during navigation on Android.
|
|
546
|
+
// This can happen when the view flattening results in different trees - due to `overflow` style changing in a parent.
|
|
547
|
+
collapsable={false}
|
|
548
|
+
{...rest}
|
|
549
|
+
>
|
|
521
550
|
{overlayEnabled ? (
|
|
522
551
|
<View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
|
|
523
552
|
{overlay({ style: overlayStyle })}
|
|
@@ -544,10 +573,10 @@ export class Card extends React.Component<Props> {
|
|
|
544
573
|
gestureDirection === 'horizontal'
|
|
545
574
|
? [styles.shadowHorizontal, styles.shadowLeft]
|
|
546
575
|
: gestureDirection === 'horizontal-inverted'
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
576
|
+
? [styles.shadowHorizontal, styles.shadowRight]
|
|
577
|
+
: gestureDirection === 'vertical'
|
|
578
|
+
? [styles.shadowVertical, styles.shadowTop]
|
|
579
|
+
: [styles.shadowVertical, styles.shadowBottom],
|
|
551
580
|
{ backgroundColor },
|
|
552
581
|
shadowStyle,
|
|
553
582
|
]}
|
|
@@ -571,16 +600,6 @@ export class Card extends React.Component<Props> {
|
|
|
571
600
|
}
|
|
572
601
|
}
|
|
573
602
|
|
|
574
|
-
export const getIsModalPresentation = (
|
|
575
|
-
cardStyleInterpolator: StackCardStyleInterpolator
|
|
576
|
-
) => {
|
|
577
|
-
return (
|
|
578
|
-
cardStyleInterpolator === forModalPresentationIOS ||
|
|
579
|
-
// Handle custom modal presentation interpolators as well
|
|
580
|
-
cardStyleInterpolator.name === 'forModalPresentationIOS'
|
|
581
|
-
);
|
|
582
|
-
};
|
|
583
|
-
|
|
584
603
|
const styles = StyleSheet.create({
|
|
585
604
|
container: {
|
|
586
605
|
flex: 1,
|