@react-navigation/stack 7.0.0-alpha.0 → 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 +4 -5
- 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 +16 -17
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/navigators/createStackNavigator.js +35 -28
- package/lib/commonjs/navigators/createStackNavigator.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/CardAnimationContext.js +4 -5
- package/lib/commonjs/utils/CardAnimationContext.js.map +1 -1
- package/lib/commonjs/utils/GestureHandlerRefContext.js +4 -5
- package/lib/commonjs/utils/GestureHandlerRefContext.js.map +1 -1
- package/lib/commonjs/utils/ModalPresentationContext.js +4 -6
- package/lib/commonjs/utils/ModalPresentationContext.js.map +1 -1
- package/lib/commonjs/utils/conditional.js +1 -1
- package/lib/commonjs/utils/conditional.js.map +1 -1
- package/lib/commonjs/utils/debounce.js +1 -1
- package/lib/commonjs/utils/debounce.js.map +1 -1
- package/lib/commonjs/utils/findLastIndex.js +2 -2
- package/lib/commonjs/utils/findLastIndex.js.map +1 -1
- package/lib/commonjs/utils/getDistanceForDirection.js +4 -5
- package/lib/commonjs/utils/getDistanceForDirection.js.map +1 -1
- package/lib/commonjs/utils/getInvertedMultiplier.js +4 -5
- package/lib/commonjs/utils/getInvertedMultiplier.js.map +1 -1
- package/lib/commonjs/utils/memoize.js +1 -1
- package/lib/commonjs/utils/memoize.js.map +1 -1
- package/lib/commonjs/utils/useCardAnimation.js +5 -6
- package/lib/commonjs/utils/useCardAnimation.js.map +1 -1
- package/lib/commonjs/utils/useGestureHandlerRef.js +5 -6
- package/lib/commonjs/utils/useGestureHandlerRef.js.map +1 -1
- package/lib/commonjs/utils/useKeyboardManager.js +7 -7
- 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 +4 -5
- package/lib/commonjs/views/GestureHandlerNative.js.map +1 -1
- package/lib/commonjs/views/Header/Header.js +11 -12
- package/lib/commonjs/views/Header/Header.js.map +1 -1
- package/lib/commonjs/views/Header/HeaderContainer.js +15 -13
- package/lib/commonjs/views/Header/HeaderContainer.js.map +1 -1
- package/lib/commonjs/views/Header/HeaderSegment.js +14 -7
- 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 +236 -234
- package/lib/commonjs/views/Stack/Card.js.map +1 -1
- package/lib/commonjs/views/Stack/CardContainer.js +33 -30
- package/lib/commonjs/views/Stack/CardContainer.js.map +1 -1
- package/lib/commonjs/views/Stack/CardSheet.js +25 -5
- package/lib/commonjs/views/Stack/CardSheet.js.map +1 -1
- package/lib/commonjs/views/Stack/CardStack.js +131 -136
- package/lib/commonjs/views/Stack/CardStack.js.map +1 -1
- package/lib/commonjs/views/Stack/StackView.js +153 -164
- package/lib/commonjs/views/Stack/StackView.js.map +1 -1
- package/lib/module/TransitionConfigs/CardStyleInterpolators.js +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 +7 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createStackNavigator.js +32 -23
- package/lib/module/navigators/createStackNavigator.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/CardAnimationContext.js +1 -1
- package/lib/module/utils/CardAnimationContext.js.map +1 -1
- package/lib/module/utils/GestureHandlerRefContext.js +1 -1
- package/lib/module/utils/GestureHandlerRefContext.js.map +1 -1
- package/lib/module/utils/ModalPresentationContext.js +1 -2
- package/lib/module/utils/ModalPresentationContext.js.map +1 -1
- package/lib/module/utils/conditional.js +1 -1
- package/lib/module/utils/conditional.js.map +1 -1
- package/lib/module/utils/debounce.js +1 -1
- package/lib/module/utils/debounce.js.map +1 -1
- package/lib/module/utils/findLastIndex.js +2 -2
- package/lib/module/utils/findLastIndex.js.map +1 -1
- package/lib/module/utils/getDistanceForDirection.js +3 -3
- 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 +1 -1
- package/lib/module/utils/memoize.js.map +1 -1
- package/lib/module/utils/useCardAnimation.js +2 -2
- package/lib/module/utils/useCardAnimation.js.map +1 -1
- package/lib/module/utils/useGestureHandlerRef.js +3 -3
- package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
- package/lib/module/utils/useKeyboardManager.js +5 -5
- 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 +1 -1
- package/lib/module/views/GestureHandlerNative.js.map +1 -1
- package/lib/module/views/Header/Header.js +5 -4
- package/lib/module/views/Header/Header.js.map +1 -1
- package/lib/module/views/Header/HeaderContainer.js +13 -10
- package/lib/module/views/Header/HeaderContainer.js.map +1 -1
- package/lib/module/views/Header/HeaderSegment.js +11 -3
- 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 +231 -228
- package/lib/module/views/Stack/Card.js.map +1 -1
- package/lib/module/views/Stack/CardContainer.js +28 -23
- package/lib/module/views/Stack/CardContainer.js.map +1 -1
- package/lib/module/views/Stack/CardSheet.js +22 -1
- package/lib/module/views/Stack/CardSheet.js.map +1 -1
- package/lib/module/views/Stack/CardStack.js +124 -128
- package/lib/module/views/Stack/CardStack.js.map +1 -1
- package/lib/module/views/Stack/StackView.js +149 -159
- 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/index.d.ts +7 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createStackNavigator.d.ts +6 -6
- 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/CardAnimationContext.d.ts +1 -2
- package/lib/typescript/src/utils/CardAnimationContext.d.ts.map +1 -1
- package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts +1 -2
- package/lib/typescript/src/utils/GestureHandlerRefContext.d.ts.map +1 -1
- package/lib/typescript/src/utils/ModalPresentationContext.d.ts +1 -2
- package/lib/typescript/src/utils/ModalPresentationContext.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/debounce.d.ts +1 -1
- package/lib/typescript/src/utils/debounce.d.ts.map +1 -1
- package/lib/typescript/src/utils/findLastIndex.d.ts +1 -1
- package/lib/typescript/src/utils/findLastIndex.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/utils/memoize.d.ts +1 -1
- package/lib/typescript/src/utils/memoize.d.ts.map +1 -1
- package/lib/typescript/src/utils/useCardAnimation.d.ts +1 -1
- package/lib/typescript/src/utils/useCardAnimation.d.ts.map +1 -1
- package/lib/typescript/src/utils/useGestureHandlerRef.d.ts +1 -1
- package/lib/typescript/src/utils/useGestureHandlerRef.d.ts.map +1 -1
- package/lib/typescript/src/utils/useKeyboardManager.d.ts +1 -1
- package/lib/typescript/src/utils/useKeyboardManager.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 +1 -2
- 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 +7 -6
- package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardContainer.d.ts +5 -8
- package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardSheet.d.ts +2 -3
- package/lib/typescript/src/views/Stack/CardSheet.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/CardStack.d.ts +5 -6
- package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
- package/lib/typescript/src/views/Stack/StackView.d.ts +10 -81
- package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
- package/package.json +20 -21
- package/src/TransitionConfigs/CardStyleInterpolators.tsx +6 -6
- package/src/TransitionConfigs/HeaderStyleInterpolators.tsx +32 -22
- package/src/TransitionConfigs/TransitionPresets.tsx +4 -4
- package/src/index.tsx +7 -7
- package/src/navigators/createStackNavigator.tsx +20 -9
- package/src/types.tsx +50 -10
- package/src/utils/CardAnimationContext.tsx +3 -3
- package/src/utils/GestureHandlerRefContext.tsx +1 -1
- package/src/utils/ModalPresentationContext.tsx +1 -3
- package/src/utils/conditional.tsx +1 -1
- package/src/utils/debounce.tsx +1 -1
- package/src/utils/findLastIndex.tsx +2 -5
- package/src/utils/getDistanceForDirection.tsx +5 -4
- package/src/utils/getInvertedMultiplier.tsx +5 -6
- package/src/utils/memoize.tsx +1 -1
- package/src/utils/useCardAnimation.tsx +2 -2
- package/src/utils/useGestureHandlerRef.tsx +3 -3
- package/src/utils/useKeyboardManager.tsx +2 -2
- package/src/views/GestureHandlerNative.tsx +2 -2
- package/src/views/Header/Header.tsx +7 -6
- package/src/views/Header/HeaderContainer.tsx +19 -8
- package/src/views/Header/HeaderSegment.tsx +14 -6
- package/src/views/Screens.tsx +2 -1
- package/src/views/Stack/Card.tsx +80 -61
- package/src/views/Stack/CardContainer.tsx +23 -14
- package/src/views/Stack/CardSheet.tsx +58 -35
- package/src/views/Stack/CardStack.tsx +220 -190
- package/src/views/Stack/StackView.tsx +29 -31
- 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 -50
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
array
|
|
3
|
-
callback: (value: T) => boolean
|
|
4
|
-
) {
|
|
5
|
-
for (var i = array.length - 1; i >= 0; i--) {
|
|
1
|
+
export function findLastIndex<T>(array: T[], callback: (value: T) => boolean) {
|
|
2
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
6
3
|
if (callback(array[i])) {
|
|
7
4
|
return i;
|
|
8
5
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { GestureDirection, Layout } from '../types';
|
|
2
|
-
import getInvertedMultiplier from './getInvertedMultiplier';
|
|
2
|
+
import { getInvertedMultiplier } from './getInvertedMultiplier';
|
|
3
3
|
|
|
4
|
-
export
|
|
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
|
-
export
|
|
6
|
-
gestureDirection: GestureDirection
|
|
3
|
+
export function getInvertedMultiplier(
|
|
4
|
+
gestureDirection: GestureDirection,
|
|
5
|
+
isRTL: boolean
|
|
7
6
|
): 1 | -1 {
|
|
8
7
|
switch (gestureDirection) {
|
|
9
8
|
case 'vertical':
|
|
@@ -11,8 +10,8 @@ export default 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
|
}
|
package/src/utils/memoize.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import CardAnimationContext from './CardAnimationContext';
|
|
3
|
+
import { CardAnimationContext } from './CardAnimationContext';
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export function useCardAnimation() {
|
|
6
6
|
const animation = React.useContext(CardAnimationContext);
|
|
7
7
|
|
|
8
8
|
if (animation === undefined) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { GestureHandlerRefContext } from './GestureHandlerRefContext';
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
const ref = React.useContext(
|
|
5
|
+
export function useGestureHandlerRef() {
|
|
6
|
+
const ref = React.useContext(GestureHandlerRefContext);
|
|
7
7
|
|
|
8
8
|
if (ref === undefined) {
|
|
9
9
|
throw new Error(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { HostComponent, Keyboard, TextInput } from 'react-native';
|
|
2
|
+
import { type HostComponent, Keyboard, TextInput } from 'react-native';
|
|
3
3
|
|
|
4
4
|
type InputRef = React.ElementRef<HostComponent<unknown>> | undefined;
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export function useKeyboardManager(isEnabled: () => boolean) {
|
|
7
7
|
// Numeric id of the previously focused text input
|
|
8
8
|
// When a gesture didn't change the tab, we can restore the focused input with this
|
|
9
9
|
const previouslyFocusedTextInputRef = React.useRef<InputRef>(undefined);
|
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
import GestureHandlerRefContext from '../utils/GestureHandlerRefContext';
|
|
7
|
+
import { GestureHandlerRefContext } from '../utils/GestureHandlerRefContext';
|
|
8
8
|
|
|
9
9
|
export function PanGestureHandler(props: PanGestureHandlerProperties) {
|
|
10
10
|
const gestureRef = React.useRef<PanGestureHandlerNative>(null);
|
|
@@ -4,11 +4,11 @@ import * as React from 'react';
|
|
|
4
4
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
5
5
|
|
|
6
6
|
import type { StackHeaderProps } from '../../types';
|
|
7
|
-
import debounce from '../../utils/debounce';
|
|
8
|
-
import ModalPresentationContext from '../../utils/ModalPresentationContext';
|
|
9
|
-
import HeaderSegment from './HeaderSegment';
|
|
7
|
+
import { debounce } from '../../utils/debounce';
|
|
8
|
+
import { ModalPresentationContext } from '../../utils/ModalPresentationContext';
|
|
9
|
+
import { HeaderSegment } from './HeaderSegment';
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export const Header = React.memo(function Header({
|
|
12
12
|
back,
|
|
13
13
|
layout,
|
|
14
14
|
progress,
|
|
@@ -49,8 +49,8 @@ export default 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 default 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,
|
|
@@ -21,7 +28,7 @@ import type {
|
|
|
21
28
|
StackHeaderProps,
|
|
22
29
|
StackNavigationProp,
|
|
23
30
|
} from '../../types';
|
|
24
|
-
import Header from './Header';
|
|
31
|
+
import { Header } from './Header';
|
|
25
32
|
|
|
26
33
|
export type Props = {
|
|
27
34
|
mode: StackHeaderMode;
|
|
@@ -36,7 +43,7 @@ export type Props = {
|
|
|
36
43
|
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
37
44
|
};
|
|
38
45
|
|
|
39
|
-
export
|
|
46
|
+
export function HeaderContainer({
|
|
40
47
|
mode,
|
|
41
48
|
scenes,
|
|
42
49
|
layout,
|
|
@@ -47,6 +54,7 @@ export default 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 default 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 default 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 {
|
|
@@ -20,7 +21,7 @@ import type {
|
|
|
20
21
|
StackHeaderOptions,
|
|
21
22
|
StackHeaderStyleInterpolator,
|
|
22
23
|
} from '../../types';
|
|
23
|
-
import memoize from '../../utils/memoize';
|
|
24
|
+
import { memoize } from '../../utils/memoize';
|
|
24
25
|
|
|
25
26
|
type Props = Omit<StackHeaderOptions, 'headerStatusBarHeight'> & {
|
|
26
27
|
headerStatusBarHeight: number;
|
|
@@ -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
|
-
export
|
|
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 default 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 default 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,
|
|
@@ -20,17 +20,16 @@ import type {
|
|
|
20
20
|
StackCardStyleInterpolator,
|
|
21
21
|
TransitionSpec,
|
|
22
22
|
} from '../../types';
|
|
23
|
-
import CardAnimationContext from '../../utils/CardAnimationContext';
|
|
24
|
-
import getDistanceForDirection from '../../utils/getDistanceForDirection';
|
|
25
|
-
import getInvertedMultiplier from '../../utils/getInvertedMultiplier';
|
|
26
|
-
import memoize from '../../utils/memoize';
|
|
23
|
+
import { CardAnimationContext } from '../../utils/CardAnimationContext';
|
|
24
|
+
import { getDistanceForDirection } from '../../utils/getDistanceForDirection';
|
|
25
|
+
import { getInvertedMultiplier } from '../../utils/getInvertedMultiplier';
|
|
26
|
+
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>;
|
|
@@ -89,7 +89,7 @@ const hasOpacityStyle = (style: any) => {
|
|
|
89
89
|
return false;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
export
|
|
92
|
+
export class Card extends React.Component<Props> {
|
|
93
93
|
static defaultProps = {
|
|
94
94
|
shadowEnabled: false,
|
|
95
95
|
gestureEnabled: true,
|
|
@@ -105,12 +105,16 @@ export default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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 default 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,
|