@react-navigation/native-stack 8.0.0-alpha.5 → 8.0.0-alpha.51
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/index.js.map +1 -1
- package/lib/module/navigators/createNativeStackNavigator.js +16 -13
- package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/utils/useAnimatedHeaderHeight.js +1 -1
- package/lib/module/utils/useAnimatedHeaderHeight.js.map +1 -1
- package/lib/module/utils/useInvalidPreventRemoveError.js +1 -1
- package/lib/module/utils/useInvalidPreventRemoveError.js.map +1 -1
- package/lib/module/views/FooterComponent.js +1 -1
- package/lib/module/views/FooterComponent.js.map +1 -1
- package/lib/module/views/NativeStackView.js +42 -25
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +124 -76
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/module/views/useHeaderConfigProps.js +76 -23
- package/lib/module/views/useHeaderConfigProps.js.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts +10 -15
- package/lib/typescript/src/navigators/createNativeStackNavigator.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +164 -156
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/getModalRoutesKeys.d.ts +1 -1
- package/lib/typescript/src/utils/getModalRoutesKeys.d.ts.map +1 -1
- package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts +1 -1
- package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts.map +1 -1
- package/lib/typescript/src/views/FooterComponent.d.ts +2 -2
- package/lib/typescript/src/views/FooterComponent.d.ts.map +1 -1
- package/lib/typescript/src/views/NativeStackView.d.ts +3 -2
- package/lib/typescript/src/views/NativeStackView.d.ts.map +1 -1
- package/lib/typescript/src/views/NativeStackView.native.d.ts +3 -2
- package/lib/typescript/src/views/NativeStackView.native.d.ts.map +1 -1
- package/lib/typescript/src/views/useHeaderConfigProps.d.ts +2 -3
- package/lib/typescript/src/views/useHeaderConfigProps.d.ts.map +1 -1
- package/package.json +22 -19
- package/src/index.tsx +1 -2
- package/src/navigators/createNativeStackNavigator.tsx +27 -52
- package/src/types.tsx +225 -196
- package/src/utils/useAnimatedHeaderHeight.tsx +1 -1
- package/src/utils/useInvalidPreventRemoveError.tsx +2 -1
- package/src/views/FooterComponent.tsx +1 -1
- package/src/views/NativeStackView.native.tsx +184 -97
- package/src/views/NativeStackView.tsx +70 -41
- package/src/views/useHeaderConfigProps.tsx +109 -39
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createNativeStackNavigator","createNativeStackScreen","NativeStackView","useAnimatedHeaderHeight"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA,SACEA,0BAA0B,EAC1BC,uBAAuB,
|
|
1
|
+
{"version":3,"names":["createNativeStackNavigator","createNativeStackScreen","NativeStackView","useAnimatedHeaderHeight"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA,SACEA,0BAA0B,EAC1BC,uBAAuB,QAElB,4CAAyC;;AAEhD;AACA;AACA;AACA,SAASC,eAAe,QAAQ,yBAAyB;;AAEzD;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,oCAAiC;;AAEzE;AACA;AACA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { createNavigatorFactory, NavigationMetaContext, StackActions, StackRouter, useNavigationBuilder } from '@react-navigation/native';
|
|
3
|
+
import { createNavigatorFactory, createScreenFactory, NavigationMetaContext, StackActions, StackRouter, useNavigationBuilder } from '@react-navigation/native';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { NativeStackView } from '../views/NativeStackView';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -30,32 +30,39 @@ function NativeStackNavigator({
|
|
|
30
30
|
screenLayout,
|
|
31
31
|
router
|
|
32
32
|
});
|
|
33
|
-
const meta = React.
|
|
33
|
+
const meta = React.use(NavigationMetaContext);
|
|
34
34
|
React.useEffect(() => {
|
|
35
35
|
if (meta && 'type' in meta && meta.type === 'native-tabs') {
|
|
36
36
|
// If we're inside native tabs, we don't need to handle popToTop
|
|
37
37
|
// It's handled natively by native tabs
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
+
let handle;
|
|
40
41
|
|
|
41
42
|
// @ts-expect-error: there may not be a tab navigator in parent
|
|
42
|
-
|
|
43
|
+
const unsubscribe = navigation.addListener?.('tabPress', e => {
|
|
43
44
|
const isFocused = navigation.isFocused();
|
|
45
|
+
cancelAnimationFrame(handle);
|
|
44
46
|
|
|
45
47
|
// Run the operation in the next frame so we're sure all listeners have been run
|
|
46
48
|
// This is necessary to know if preventDefault() has been called
|
|
47
|
-
requestAnimationFrame(() => {
|
|
48
|
-
|
|
49
|
+
handle = requestAnimationFrame(() => {
|
|
50
|
+
const currentState = navigation.getState();
|
|
51
|
+
if (isFocused && (currentState.index > 0 || currentState.routes[0]?.history?.length) && !e.defaultPrevented) {
|
|
49
52
|
// When user taps on already focused tab and we're inside the tab,
|
|
50
53
|
// reset the stack to replicate native behaviour
|
|
51
54
|
navigation.dispatch({
|
|
52
55
|
...StackActions.popToTop(),
|
|
53
|
-
target:
|
|
56
|
+
target: currentState.key
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
60
|
});
|
|
58
|
-
|
|
61
|
+
return () => {
|
|
62
|
+
cancelAnimationFrame(handle);
|
|
63
|
+
unsubscribe?.();
|
|
64
|
+
};
|
|
65
|
+
}, [meta, navigation]);
|
|
59
66
|
return /*#__PURE__*/_jsx(NavigationContent, {
|
|
60
67
|
children: /*#__PURE__*/_jsx(NativeStackView, {
|
|
61
68
|
...rest,
|
|
@@ -65,10 +72,6 @@ function NativeStackNavigator({
|
|
|
65
72
|
})
|
|
66
73
|
});
|
|
67
74
|
}
|
|
68
|
-
export
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
export function createNativeStackScreen(config) {
|
|
72
|
-
return config;
|
|
73
|
-
}
|
|
75
|
+
export const createNativeStackNavigator = createNavigatorFactory(NativeStackNavigator);
|
|
76
|
+
export const createNativeStackScreen = createScreenFactory();
|
|
74
77
|
//# sourceMappingURL=createNativeStackNavigator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createNavigatorFactory","NavigationMetaContext","StackActions","StackRouter","useNavigationBuilder","React","NativeStackView","jsx","_jsx","NativeStackNavigator","initialRouteName","routeNamesChangeBehavior","children","layout","screenListeners","screenOptions","screenLayout","router","rest","state","descriptors","navigation","NavigationContent","meta","
|
|
1
|
+
{"version":3,"names":["createNavigatorFactory","createScreenFactory","NavigationMetaContext","StackActions","StackRouter","useNavigationBuilder","React","NativeStackView","jsx","_jsx","NativeStackNavigator","initialRouteName","routeNamesChangeBehavior","children","layout","screenListeners","screenOptions","screenLayout","router","rest","state","descriptors","navigation","NavigationContent","meta","use","useEffect","type","handle","unsubscribe","addListener","e","isFocused","cancelAnimationFrame","requestAnimationFrame","currentState","getState","index","routes","history","length","defaultPrevented","dispatch","popToTop","target","key","createNativeStackNavigator","createNativeStackScreen"],"sourceRoot":"../../../src","sources":["navigators/createNativeStackNavigator.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EACtBC,mBAAmB,EAEnBC,qBAAqB,EAIrBC,YAAY,EAEZC,WAAW,EAEXC,oBAAoB,QACf,0BAA0B;AACjC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAO9B,SAASC,eAAe,QAAQ,0BAA0B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3D,SAASC,oBAAoBA,CAAC;EAC5BC,gBAAgB;EAChBC,wBAAwB;EACxBC,QAAQ;EACRC,MAAM;EACNC,eAAe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,WAAW,GAAG,CAAC;IACjB,CAAC;EACH,CAAC,EAAE,CAACL,IAAI,EAAEF,UAAU,CAAC,CAAC;EAEtB,oBACEb,IAAA,CAACc,iBAAiB;IAAAV,QAAA,eAChBJ,IAAA,CAACF,eAAe;MAAA,GACVY,IAAI;MACRC,KAAK,EAAEA,KAAM;MACbE,UAAU,EAAEA,UAAW;MACvBD,WAAW,EAAEA;IAAY,CAC1B;EAAC,CACe,CAAC;AAExB;AAUA,OAAO,MAAMyB,0BAA0B,GACrC9C,sBAAsB,CAAqBU,oBAAoB,CAAC;AAElE,OAAO,MAAMqC,uBAAuB,GAClC9C,mBAAmB,CAAqB,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
export const AnimatedHeaderHeightContext = /*#__PURE__*/React.createContext(undefined);
|
|
5
5
|
export function useAnimatedHeaderHeight() {
|
|
6
|
-
const animatedValue = React.
|
|
6
|
+
const animatedValue = React.use(AnimatedHeaderHeightContext);
|
|
7
7
|
if (animatedValue === undefined) {
|
|
8
8
|
throw new Error("Couldn't find the header height. Are you inside a screen in a native stack navigator?");
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","AnimatedHeaderHeightContext","createContext","undefined","useAnimatedHeaderHeight","animatedValue","
|
|
1
|
+
{"version":3,"names":["React","AnimatedHeaderHeightContext","createContext","undefined","useAnimatedHeaderHeight","animatedValue","use","Error"],"sourceRoot":"../../../src","sources":["utils/useAnimatedHeaderHeight.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAO,MAAMC,2BAA2B,gBAAGD,KAAK,CAACE,aAAa,CAE5DC,SAAS,CAAC;AAEZ,OAAO,SAASC,uBAAuBA,CAAA,EAAG;EACxC,MAAMC,aAAa,GAAGL,KAAK,CAACM,GAAG,CAACL,2BAA2B,CAAC;EAE5D,IAAII,aAAa,KAAKF,SAAS,EAAE;IAC/B,MAAM,IAAII,KAAK,CACb,uFACF,CAAC;EACH;EAEA,OAAOF,aAAa;AACtB","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ export function useInvalidPreventRemoveError(descriptors) {
|
|
|
7
7
|
preventedRoutes
|
|
8
8
|
} = usePreventRemoveContext();
|
|
9
9
|
const preventedRouteKey = Object.keys(preventedRoutes)[0];
|
|
10
|
-
const preventedDescriptor = descriptors[preventedRouteKey];
|
|
10
|
+
const preventedDescriptor = preventedRouteKey == null ? undefined : descriptors[preventedRouteKey];
|
|
11
11
|
const isHeaderBackButtonMenuEnabledOnPreventedScreen = preventedDescriptor?.options?.headerBackButtonMenuEnabled;
|
|
12
12
|
const preventedRouteName = preventedDescriptor?.route?.name;
|
|
13
13
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["usePreventRemoveContext","React","useInvalidPreventRemoveError","descriptors","preventedRoutes","preventedRouteKey","Object","keys","preventedDescriptor","isHeaderBackButtonMenuEnabledOnPreventedScreen","options","headerBackButtonMenuEnabled","preventedRouteName","route","name","useEffect","message","console","error"],"sourceRoot":"../../../src","sources":["utils/useInvalidPreventRemoveError.tsx"],"mappings":";;AAAA,SAASA,uBAAuB,QAAQ,0BAA0B;AAClE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAI9B,OAAO,SAASC,4BAA4BA,CAC1CC,WAAqC,EACrC;EACA,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,uBAAuB,CAAC,CAAC;EACrD,MAAMK,iBAAiB,GAAGC,MAAM,CAACC,IAAI,CAACH,eAAe,CAAC,CAAC,CAAC,CAAC;EACzD,MAAMI,mBAAmB,
|
|
1
|
+
{"version":3,"names":["usePreventRemoveContext","React","useInvalidPreventRemoveError","descriptors","preventedRoutes","preventedRouteKey","Object","keys","preventedDescriptor","undefined","isHeaderBackButtonMenuEnabledOnPreventedScreen","options","headerBackButtonMenuEnabled","preventedRouteName","route","name","useEffect","message","console","error"],"sourceRoot":"../../../src","sources":["utils/useInvalidPreventRemoveError.tsx"],"mappings":";;AAAA,SAASA,uBAAuB,QAAQ,0BAA0B;AAClE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAI9B,OAAO,SAASC,4BAA4BA,CAC1CC,WAAqC,EACrC;EACA,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,uBAAuB,CAAC,CAAC;EACrD,MAAMK,iBAAiB,GAAGC,MAAM,CAACC,IAAI,CAACH,eAAe,CAAC,CAAC,CAAC,CAAC;EACzD,MAAMI,mBAAmB,GACvBH,iBAAiB,IAAI,IAAI,GAAGI,SAAS,GAAGN,WAAW,CAACE,iBAAiB,CAAC;EACxE,MAAMK,8CAA8C,GAClDF,mBAAmB,EAAEG,OAAO,EAAEC,2BAA2B;EAC3D,MAAMC,kBAAkB,GAAGL,mBAAmB,EAAEM,KAAK,EAAEC,IAAI;EAE3Dd,KAAK,CAACe,SAAS,CAAC,MAAM;IACpB,IACEX,iBAAiB,IAAI,IAAI,IACzBK,8CAA8C,EAC9C;MACA,MAAMO,OAAO,GACX,cAAcJ,kBAAkB,2GAA2G,GAC3I,8DAA8DA,kBAAkB,mCAAmC;MACrHK,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC;IACxB;EACF,CAAC,EAAE,CACDZ,iBAAiB,EACjBK,8CAA8C,EAC9CG,kBAAkB,CACnB,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","ScreenFooter","jsx","_jsx","FooterComponent","children","collapsable"],"sourceRoot":"../../../src","sources":["views/FooterComponent.tsx"],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"names":["React","ScreenFooter","jsx","_jsx","FooterComponent","children","collapsable"],"sourceRoot":"../../../src","sources":["views/FooterComponent.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,YAAY,QAAQ,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMpD,OAAO,SAASC,eAAeA,CAAC;EAAEC;AAAsB,CAAC,EAAE;EACzD,oBAAOF,IAAA,CAACF,YAAY;IAACK,WAAW,EAAE,KAAM;IAAAD,QAAA,EAAEA;EAAQ,CAAe,CAAC;AACpE","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { getHeaderTitle, Header, HeaderBackButton, HeaderBackContext, useHeaderHeight } from '@react-navigation/elements';
|
|
4
|
-
import { SafeAreaProviderCompat, Screen } from '@react-navigation/elements/internal';
|
|
4
|
+
import { ActivityView, SafeAreaProviderCompat, Screen } from '@react-navigation/elements/internal';
|
|
5
5
|
import { useLinkBuilder } from '@react-navigation/native';
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import { Animated,
|
|
7
|
+
import { Animated, StyleSheet, View } from 'react-native';
|
|
8
|
+
import { getModalRouteKeys } from "../utils/getModalRoutesKeys.js";
|
|
8
9
|
import { AnimatedHeaderHeightContext } from "../utils/useAnimatedHeaderHeight.js";
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
const TRANSPARENT_PRESENTATIONS = ['transparentModal', 'containedTransparentModal'];
|
|
@@ -12,28 +13,35 @@ export function NativeStackView({
|
|
|
12
13
|
state,
|
|
13
14
|
descriptors
|
|
14
15
|
}) {
|
|
15
|
-
const parentHeaderBack = React.
|
|
16
|
+
const parentHeaderBack = React.use(HeaderBackContext);
|
|
16
17
|
const {
|
|
17
18
|
buildHref
|
|
18
19
|
} = useLinkBuilder();
|
|
20
|
+
const activeRoutes = state.routes.slice(0, state.index + 1);
|
|
21
|
+
const modalRouteKeys = getModalRouteKeys(activeRoutes, descriptors);
|
|
19
22
|
return /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
|
|
20
|
-
children: state.routes.
|
|
23
|
+
children: state.routes.map((route, i) => {
|
|
21
24
|
const isFocused = state.index === i;
|
|
22
|
-
const previousKey =
|
|
23
|
-
const nextKey =
|
|
25
|
+
const previousKey = activeRoutes[i - 1]?.key;
|
|
26
|
+
const nextKey = activeRoutes[i + 1]?.key;
|
|
24
27
|
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
25
28
|
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
29
|
+
const descriptor = descriptors[route.key];
|
|
30
|
+
if (descriptor == null) {
|
|
31
|
+
throw new Error(`Couldn't find a descriptor for route '${route.key}'.`);
|
|
32
|
+
}
|
|
26
33
|
const {
|
|
27
34
|
options,
|
|
28
35
|
navigation,
|
|
29
36
|
render
|
|
30
|
-
} =
|
|
37
|
+
} = descriptor;
|
|
31
38
|
const headerBack = previousDescriptor ? {
|
|
32
39
|
title: getHeaderTitle(previousDescriptor.options, previousDescriptor.route.name),
|
|
33
40
|
href: buildHref(previousDescriptor.route.name, previousDescriptor.route.params)
|
|
34
41
|
} : parentHeaderBack;
|
|
35
42
|
const canGoBack = headerBack != null;
|
|
36
43
|
const {
|
|
44
|
+
inactiveBehavior = 'pause',
|
|
37
45
|
header,
|
|
38
46
|
headerShown,
|
|
39
47
|
headerBackIcon,
|
|
@@ -45,8 +53,20 @@ export function NativeStackView({
|
|
|
45
53
|
...rest
|
|
46
54
|
} = options;
|
|
47
55
|
const nextPresentation = nextDescriptor?.options.presentation;
|
|
48
|
-
const
|
|
49
|
-
|
|
56
|
+
const isNextScreenTransparent = nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation);
|
|
57
|
+
const isInactive = i > state.index;
|
|
58
|
+
const isBeforeLast = i === activeRoutes.length - 2;
|
|
59
|
+
const isNextScreenModal = nextKey ? modalRouteKeys.includes(nextKey) : false;
|
|
60
|
+
const activityMode =
|
|
61
|
+
// Render focused screens normally
|
|
62
|
+
isFocused ? 'normal' :
|
|
63
|
+
// Unpause preloaded and retained screens so updates are visible
|
|
64
|
+
// This lets effects on those screens run
|
|
65
|
+
inactiveBehavior === 'none' || isInactive || isNextScreenTransparent ? 'inert' : inactiveBehavior === 'unmount' && !isNextScreenModal && !isBeforeLast && !route.state ? 'unmounted' : 'paused';
|
|
66
|
+
if (activityMode === 'unmounted') {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const content = /*#__PURE__*/_jsx(Screen, {
|
|
50
70
|
focused: isFocused,
|
|
51
71
|
route: route,
|
|
52
72
|
navigation: navigation,
|
|
@@ -75,21 +95,17 @@ export function NativeStackView({
|
|
|
75
95
|
...rest,
|
|
76
96
|
label: headerBackTitle ?? label,
|
|
77
97
|
tintColor: tintColor,
|
|
78
|
-
|
|
79
|
-
source: headerBackIcon.source,
|
|
80
|
-
resizeMode: "contain",
|
|
81
|
-
tintColor: tintColor,
|
|
82
|
-
style: styles.backImage
|
|
83
|
-
}) : undefined,
|
|
98
|
+
icon: headerBackIcon,
|
|
84
99
|
onPress: navigation.goBack
|
|
85
100
|
}) : headerLeft,
|
|
86
101
|
headerTransparent: headerTransparent
|
|
87
102
|
}),
|
|
88
|
-
style:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
style: {
|
|
104
|
+
...StyleSheet.absoluteFill,
|
|
105
|
+
...(presentation != null && TRANSPARENT_PRESENTATIONS.includes(presentation) ? {
|
|
106
|
+
backgroundColor: 'transparent'
|
|
107
|
+
} : null)
|
|
108
|
+
},
|
|
93
109
|
children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
|
|
94
110
|
value: headerBack,
|
|
95
111
|
children: /*#__PURE__*/_jsx(AnimatedHeaderHeightProvider, {
|
|
@@ -100,6 +116,12 @@ export function NativeStackView({
|
|
|
100
116
|
})
|
|
101
117
|
})
|
|
102
118
|
}, route.key);
|
|
119
|
+
return /*#__PURE__*/_jsx(ActivityView, {
|
|
120
|
+
mode: activityMode,
|
|
121
|
+
visible: isFocused || isNextScreenTransparent,
|
|
122
|
+
style: StyleSheet.absoluteFill,
|
|
123
|
+
children: content
|
|
124
|
+
}, route.key);
|
|
103
125
|
})
|
|
104
126
|
});
|
|
105
127
|
}
|
|
@@ -119,11 +141,6 @@ const AnimatedHeaderHeightProvider = ({
|
|
|
119
141
|
const styles = StyleSheet.create({
|
|
120
142
|
contentContainer: {
|
|
121
143
|
flex: 1
|
|
122
|
-
},
|
|
123
|
-
backImage: {
|
|
124
|
-
height: 24,
|
|
125
|
-
width: 24,
|
|
126
|
-
margin: 3
|
|
127
144
|
}
|
|
128
145
|
});
|
|
129
146
|
//# sourceMappingURL=NativeStackView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getHeaderTitle","Header","HeaderBackButton","HeaderBackContext","useHeaderHeight","SafeAreaProviderCompat","Screen","useLinkBuilder","React","Animated","
|
|
1
|
+
{"version":3,"names":["getHeaderTitle","Header","HeaderBackButton","HeaderBackContext","useHeaderHeight","ActivityView","SafeAreaProviderCompat","Screen","useLinkBuilder","React","Animated","StyleSheet","View","getModalRouteKeys","AnimatedHeaderHeightContext","jsx","_jsx","TRANSPARENT_PRESENTATIONS","NativeStackView","state","descriptors","parentHeaderBack","use","buildHref","activeRoutes","routes","slice","index","modalRouteKeys","children","map","route","i","isFocused","previousKey","key","nextKey","previousDescriptor","undefined","nextDescriptor","descriptor","Error","options","navigation","render","headerBack","title","name","href","params","canGoBack","inactiveBehavior","header","headerShown","headerBackIcon","headerLeft","headerTransparent","headerBackTitle","presentation","contentStyle","rest","nextPresentation","isNextScreenTransparent","includes","isInactive","isBeforeLast","length","isNextScreenModal","activityMode","content","focused","back","label","tintColor","icon","onPress","goBack","style","absoluteFill","backgroundColor","Provider","value","AnimatedHeaderHeightProvider","styles","contentContainer","mode","visible","headerHeight","animatedHeaderHeight","useState","Value","useEffect","setValue","create","flex"],"sourceRoot":"../../../src","sources":["views/NativeStackView.tsx"],"mappings":";;AAAA,SACEA,cAAc,EACdC,MAAM,EACNC,gBAAgB,EAChBC,iBAAiB,EACjBC,eAAe,QACV,4BAA4B;AACnC,SACEC,YAAY,EACZC,sBAAsB,EACtBC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AAqB;IAAA3D,QAAA,EAC/DA;EAAQ,CAC2B,CAAC;AAE3C,CAAC;AAED,MAAMsD,MAAM,GAAGxE,UAAU,CAACkF,MAAM,CAAC;EAC/BT,gBAAgB,EAAE;IAChBU,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { getDefaultHeaderHeight, getHeaderTitle, HeaderBackContext, HeaderHeightContext, HeaderShownContext, useFrameSize } from '@react-navigation/elements';
|
|
4
|
-
import { SafeAreaProviderCompat } from '@react-navigation/elements/internal';
|
|
4
|
+
import { ActivityView, SafeAreaProviderCompat } from '@react-navigation/elements/internal';
|
|
5
5
|
import { NavigationProvider, StackActions, usePreventRemoveContext, useTheme } from '@react-navigation/native';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { Animated, Platform, StyleSheet, useAnimatedValue, View } from 'react-native';
|
|
@@ -15,18 +15,20 @@ import { useInvalidPreventRemoveError } from "../utils/useInvalidPreventRemoveEr
|
|
|
15
15
|
import { useHeaderConfigProps } from "./useHeaderConfigProps.js";
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
const ANDROID_DEFAULT_HEADER_HEIGHT = 56;
|
|
18
|
-
function isFabric() {
|
|
19
|
-
return 'nativeFabricUIManager' in global;
|
|
20
|
-
}
|
|
21
18
|
const useNativeDriver = Platform.OS !== 'web';
|
|
19
|
+
const TRANSPARENT_PRESENTATIONS = ['transparentModal', 'containedTransparentModal'];
|
|
20
|
+
const SHEET_PRESENTATIONS = ['formSheet', 'pageSheet'];
|
|
22
21
|
const SceneView = ({
|
|
23
22
|
index,
|
|
24
23
|
focused,
|
|
25
|
-
shouldFreeze,
|
|
26
24
|
descriptor,
|
|
27
25
|
previousDescriptor,
|
|
28
26
|
isPresentationModal,
|
|
29
|
-
|
|
27
|
+
isNextScreenTransparent,
|
|
28
|
+
isNextScreenSheet,
|
|
29
|
+
isNextScreenModal,
|
|
30
|
+
isInactive,
|
|
31
|
+
isBeforeLast,
|
|
30
32
|
onWillDisappear,
|
|
31
33
|
onWillAppear,
|
|
32
34
|
onAppear,
|
|
@@ -44,6 +46,7 @@ const SceneView = ({
|
|
|
44
46
|
render
|
|
45
47
|
} = descriptor;
|
|
46
48
|
const {
|
|
49
|
+
inactiveBehavior = 'pause',
|
|
47
50
|
animation,
|
|
48
51
|
animationDuration,
|
|
49
52
|
animationMatchesGesture,
|
|
@@ -74,9 +77,9 @@ const SceneView = ({
|
|
|
74
77
|
statusBarAnimation,
|
|
75
78
|
statusBarHidden,
|
|
76
79
|
statusBarStyle,
|
|
80
|
+
unstable_headerInsets,
|
|
77
81
|
unstable_sheetFooter,
|
|
78
82
|
scrollEdgeEffects,
|
|
79
|
-
freezeOnBlur,
|
|
80
83
|
contentStyle
|
|
81
84
|
} = options;
|
|
82
85
|
let {
|
|
@@ -97,11 +100,11 @@ const SceneView = ({
|
|
|
97
100
|
|
|
98
101
|
// Modals are fullscreen in landscape only on iPhone
|
|
99
102
|
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad || Platform.isTV);
|
|
100
|
-
const isParentHeaderShown = React.
|
|
101
|
-
const parentHeaderHeight = React.
|
|
102
|
-
const parentHeaderBack = React.
|
|
103
|
+
const isParentHeaderShown = React.use(HeaderShownContext);
|
|
104
|
+
const parentHeaderHeight = React.use(HeaderHeightContext);
|
|
105
|
+
const parentHeaderBack = React.use(HeaderBackContext);
|
|
103
106
|
const isLandscape = useFrameSize(frame => frame.width > frame.height);
|
|
104
|
-
const topInset = isParentHeaderShown || Platform.OS === 'ios' && isModal || isIPhone && isLandscape ? 0 : insets.top;
|
|
107
|
+
const topInset = isParentHeaderShown || Platform.OS === 'android' && unstable_headerInsets?.top === false || Platform.OS === 'ios' && isModal || isIPhone && isLandscape ? 0 : insets.top;
|
|
105
108
|
const defaultHeaderHeight = useFrameSize(frame => Platform.select({
|
|
106
109
|
// FIXME: Currently screens isn't using Material 3
|
|
107
110
|
// So our `getDefaultHeaderHeight` doesn't return the correct value
|
|
@@ -123,7 +126,6 @@ const SceneView = ({
|
|
|
123
126
|
// Debounce the header height updates to avoid excessive re-renders
|
|
124
127
|
debounce(setHeaderHeight, 100), []);
|
|
125
128
|
const hasCustomHeader = header != null;
|
|
126
|
-
const headerTopInsetEnabled = topInset !== 0;
|
|
127
129
|
const canGoBack = previousDescriptor != null || parentHeaderBack != null;
|
|
128
130
|
const backTitle = previousDescriptor ? getHeaderTitle(previousDescriptor.options, previousDescriptor.route.name) : parentHeaderBack?.title;
|
|
129
131
|
const headerBack = React.useMemo(() => {
|
|
@@ -145,9 +147,15 @@ const SceneView = ({
|
|
|
145
147
|
headerBackTitle: options.headerBackTitle !== undefined ? options.headerBackTitle : undefined,
|
|
146
148
|
headerHeight,
|
|
147
149
|
headerShown: header !== undefined ? false : headerShown,
|
|
148
|
-
headerTopInsetEnabled,
|
|
149
150
|
headerBack
|
|
150
151
|
});
|
|
152
|
+
const headerContainerRef = React.useRef(null);
|
|
153
|
+
React.useLayoutEffect(() => {
|
|
154
|
+
headerContainerRef.current?.measure((_x, _y, _width, height) => {
|
|
155
|
+
animatedHeaderHeight.setValue(height);
|
|
156
|
+
setHeaderHeight(height);
|
|
157
|
+
});
|
|
158
|
+
}, [animatedHeaderHeight]);
|
|
151
159
|
const onHeaderHeightChange = hasCustomHeader ?
|
|
152
160
|
// If we have a custom header, don't use native header height
|
|
153
161
|
undefined :
|
|
@@ -171,7 +179,9 @@ const SceneView = ({
|
|
|
171
179
|
if (doesHeaderAnimate) {
|
|
172
180
|
setHeaderHeightDebounced(headerHeight);
|
|
173
181
|
} else {
|
|
174
|
-
if (Platform.OS === 'android' && headerHeight !== 0 &&
|
|
182
|
+
if (Platform.OS === 'android' && headerHeight !== 0 &&
|
|
183
|
+
// On some devices, height maybe slightly off (e.g. 56.17 instead of 56)
|
|
184
|
+
Math.round(headerHeight) <= ANDROID_DEFAULT_HEADER_HEIGHT) {
|
|
175
185
|
// FIXME: On Android, events may get delivered out-of-order
|
|
176
186
|
// https://github.com/facebook/react-native/issues/54636
|
|
177
187
|
// We seem to get header height without status bar height first,
|
|
@@ -188,18 +198,77 @@ const SceneView = ({
|
|
|
188
198
|
}
|
|
189
199
|
}
|
|
190
200
|
});
|
|
201
|
+
const activityMode =
|
|
202
|
+
// Render focused screens normally
|
|
203
|
+
// Unpause preloaded and retained screens so updates are visible
|
|
204
|
+
// Unpause previous screen so update isn't delayed for swipe back
|
|
205
|
+
// This lets effects on those screens run
|
|
206
|
+
// We don't need to handle inert as it'll be handled natively
|
|
207
|
+
inactiveBehavior === 'none' || focused || isInactive || isNextScreenTransparent ||
|
|
208
|
+
// Unpause the screen behind a sheet so it stays up to date
|
|
209
|
+
// Sheets don't cover the whole screen, so the screen behind is visible
|
|
210
|
+
isNextScreenSheet ||
|
|
211
|
+
// On iPadOS, the base screen is visible while modal is in a smaller area
|
|
212
|
+
// So also keep the screens unpaused
|
|
213
|
+
isNextScreenModal && !isModal || isBeforeLast ? 'normal' : inactiveBehavior === 'unmount' && !('state' in route && route.state) ? 'unmounted' : 'paused';
|
|
214
|
+
const content = /*#__PURE__*/_jsx(AnimatedHeaderHeightContext.Provider, {
|
|
215
|
+
value: animatedHeaderHeight,
|
|
216
|
+
children: /*#__PURE__*/_jsxs(HeaderHeightContext.Provider, {
|
|
217
|
+
value: headerShown !== false ? headerHeight : parentHeaderHeight ?? 0,
|
|
218
|
+
children: [headerBackground != null ?
|
|
219
|
+
/*#__PURE__*/
|
|
220
|
+
/**
|
|
221
|
+
* To show a custom header background, we render it at the top of the screen below the header
|
|
222
|
+
* The header also needs to be positioned absolutely (with `translucent` style)
|
|
223
|
+
*/
|
|
224
|
+
_jsx(View, {
|
|
225
|
+
style: [styles.background, headerTransparent ? styles.translucent : null, {
|
|
226
|
+
height: headerHeight
|
|
227
|
+
}],
|
|
228
|
+
children: headerBackground()
|
|
229
|
+
}) : null, header != null && headerShown !== false ? /*#__PURE__*/_jsx(View, {
|
|
230
|
+
style: [styles.header, headerTransparent ? [styles.absolute,
|
|
231
|
+
// Specify an explicit min height for Android screen readers
|
|
232
|
+
{
|
|
233
|
+
minHeight: headerHeight
|
|
234
|
+
}] : null],
|
|
235
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
236
|
+
ref: headerContainerRef,
|
|
237
|
+
onLayout: e => {
|
|
238
|
+
const headerHeight = e.nativeEvent.layout.height;
|
|
239
|
+
animatedHeaderHeight.setValue(headerHeight);
|
|
240
|
+
setHeaderHeight(headerHeight);
|
|
241
|
+
},
|
|
242
|
+
style: {
|
|
243
|
+
pointerEvents: 'box-none'
|
|
244
|
+
},
|
|
245
|
+
children: header({
|
|
246
|
+
back: headerBack,
|
|
247
|
+
options,
|
|
248
|
+
route,
|
|
249
|
+
navigation
|
|
250
|
+
})
|
|
251
|
+
})
|
|
252
|
+
}) : null, /*#__PURE__*/_jsx(HeaderShownContext.Provider, {
|
|
253
|
+
value: isParentHeaderShown || headerShown !== false,
|
|
254
|
+
children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
|
|
255
|
+
value: headerBack,
|
|
256
|
+
children: render()
|
|
257
|
+
})
|
|
258
|
+
})]
|
|
259
|
+
})
|
|
260
|
+
});
|
|
191
261
|
return /*#__PURE__*/_jsx(NavigationProvider, {
|
|
192
262
|
navigation: navigation,
|
|
193
263
|
route: route,
|
|
194
264
|
children: /*#__PURE__*/_jsx(ScreenStackItem, {
|
|
195
265
|
screenId: route.key,
|
|
196
|
-
activityState:
|
|
266
|
+
activityState: isInactive ? 0 : 2,
|
|
197
267
|
style: StyleSheet.absoluteFill,
|
|
198
268
|
"aria-hidden": !focused,
|
|
199
269
|
customAnimationOnSwipe: animationMatchesGesture,
|
|
200
270
|
fullScreenSwipeEnabled: fullScreenGestureEnabled,
|
|
201
271
|
fullScreenSwipeShadowEnabled: fullScreenGestureShadowEnabled,
|
|
202
|
-
freezeOnBlur: freezeOnBlur,
|
|
203
272
|
gestureEnabled: Platform.OS === 'android' ?
|
|
204
273
|
// This prop enables handling of system back gestures on Android
|
|
205
274
|
// Since we handle them in JS side, we disable this
|
|
@@ -250,48 +319,16 @@ const SceneView = ({
|
|
|
250
319
|
backgroundColor: colors.background
|
|
251
320
|
}, contentStyle],
|
|
252
321
|
headerConfig: headerConfig,
|
|
253
|
-
unstable_sheetFooter: unstable_sheetFooter
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
children: [headerBackground != null ?
|
|
264
|
-
/*#__PURE__*/
|
|
265
|
-
/**
|
|
266
|
-
* To show a custom header background, we render it at the top of the screen below the header
|
|
267
|
-
* The header also needs to be positioned absolutely (with `translucent` style)
|
|
268
|
-
*/
|
|
269
|
-
_jsx(View, {
|
|
270
|
-
style: [styles.background, headerTransparent ? styles.translucent : null, {
|
|
271
|
-
height: headerHeight
|
|
272
|
-
}],
|
|
273
|
-
children: headerBackground()
|
|
274
|
-
}) : null, header != null && headerShown !== false ? /*#__PURE__*/_jsx(View, {
|
|
275
|
-
onLayout: e => {
|
|
276
|
-
const headerHeight = e.nativeEvent.layout.height;
|
|
277
|
-
animatedHeaderHeight.setValue(headerHeight);
|
|
278
|
-
setHeaderHeight(headerHeight);
|
|
279
|
-
},
|
|
280
|
-
style: [styles.header, headerTransparent ? styles.absolute : null],
|
|
281
|
-
children: header({
|
|
282
|
-
back: headerBack,
|
|
283
|
-
options,
|
|
284
|
-
route,
|
|
285
|
-
navigation
|
|
286
|
-
})
|
|
287
|
-
}) : null, /*#__PURE__*/_jsx(HeaderShownContext.Provider, {
|
|
288
|
-
value: isParentHeaderShown || headerShown !== false,
|
|
289
|
-
children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
|
|
290
|
-
value: headerBack,
|
|
291
|
-
children: render()
|
|
292
|
-
})
|
|
293
|
-
})]
|
|
294
|
-
})
|
|
322
|
+
unstable_sheetFooter: unstable_sheetFooter,
|
|
323
|
+
children: activityMode === 'unmounted' ? null : /*#__PURE__*/_jsx(ActivityView, {
|
|
324
|
+
mode: activityMode,
|
|
325
|
+
visible:
|
|
326
|
+
// We don't need to hide the content since it's handled natively
|
|
327
|
+
// Hiding may also cause flash due to lag after native tab switch
|
|
328
|
+
// So we leave it always visible
|
|
329
|
+
true,
|
|
330
|
+
style: styles.content,
|
|
331
|
+
children: content
|
|
295
332
|
})
|
|
296
333
|
}, route.key)
|
|
297
334
|
});
|
|
@@ -305,34 +342,38 @@ export function NativeStackView({
|
|
|
305
342
|
setNextDismissedKey
|
|
306
343
|
} = useDismissedRouteError(state);
|
|
307
344
|
useInvalidPreventRemoveError(descriptors);
|
|
308
|
-
const
|
|
345
|
+
const activeRoutes = state.routes.slice(0, state.index + 1);
|
|
346
|
+
const modalRouteKeys = getModalRouteKeys(activeRoutes, descriptors);
|
|
309
347
|
return /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
|
|
310
348
|
children: /*#__PURE__*/_jsx(ScreenStack, {
|
|
311
349
|
style: styles.container,
|
|
312
|
-
children: state.routes.
|
|
350
|
+
children: state.routes.map((route, index) => {
|
|
313
351
|
const descriptor = descriptors[route.key];
|
|
352
|
+
if (descriptor == null) {
|
|
353
|
+
throw new Error(`Couldn't find a descriptor for route '${route.key}'.`);
|
|
354
|
+
}
|
|
314
355
|
const isFocused = state.index === index;
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
const nextKey = state.routes[index + 1]?.key;
|
|
356
|
+
const previousKey = activeRoutes[index - 1]?.key;
|
|
357
|
+
const nextKey = activeRoutes[index + 1]?.key;
|
|
318
358
|
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
319
359
|
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
360
|
+
const nextPresentation = nextDescriptor?.options.presentation;
|
|
361
|
+
const isNextScreenTransparent = nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation);
|
|
362
|
+
const isNextScreenSheet = nextPresentation != null && SHEET_PRESENTATIONS.includes(nextPresentation);
|
|
363
|
+
const isNextScreenModal = nextKey ? modalRouteKeys.includes(nextKey) : false;
|
|
320
364
|
const isModal = modalRouteKeys.includes(route.key);
|
|
321
|
-
const isModalOnIos = isModal && Platform.OS === 'ios';
|
|
322
|
-
const isPreloaded = state.preloadedRoutes.some(r => r.key === route.key);
|
|
323
|
-
|
|
324
|
-
// On Fabric, when screen is frozen, animated and reanimated values are not updated
|
|
325
|
-
// due to component being unmounted. To avoid this, we don't freeze the previous screen there
|
|
326
|
-
const shouldFreeze = isFabric() ? !isPreloaded && !isFocused && !isBelowFocused && !isModalOnIos : !isPreloaded && !isFocused && !isModalOnIos;
|
|
327
365
|
return /*#__PURE__*/_jsx(SceneView, {
|
|
328
366
|
index: index,
|
|
329
367
|
focused: isFocused,
|
|
330
|
-
shouldFreeze: shouldFreeze,
|
|
331
368
|
descriptor: descriptor,
|
|
332
369
|
previousDescriptor: previousDescriptor,
|
|
333
370
|
nextDescriptor: nextDescriptor,
|
|
334
371
|
isPresentationModal: isModal,
|
|
335
|
-
|
|
372
|
+
isNextScreenTransparent: isNextScreenTransparent,
|
|
373
|
+
isNextScreenSheet: isNextScreenSheet,
|
|
374
|
+
isNextScreenModal: isNextScreenModal,
|
|
375
|
+
isInactive: index > state.index,
|
|
376
|
+
isBeforeLast: index === activeRoutes.length - 2,
|
|
336
377
|
onWillDisappear: () => {
|
|
337
378
|
navigation.emit({
|
|
338
379
|
type: 'transitionStart',
|
|
@@ -370,11 +411,15 @@ export function NativeStackView({
|
|
|
370
411
|
});
|
|
371
412
|
},
|
|
372
413
|
onDismissed: event => {
|
|
373
|
-
navigation.
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
414
|
+
const currentState = navigation.getState();
|
|
415
|
+
const currentActiveRoutes = currentState.routes.slice(0, currentState.index + 1);
|
|
416
|
+
if (currentActiveRoutes.some(r => r.key === route.key)) {
|
|
417
|
+
navigation.dispatch({
|
|
418
|
+
...StackActions.pop(event.nativeEvent.dismissCount),
|
|
419
|
+
source: route.key,
|
|
420
|
+
target: currentState.key
|
|
421
|
+
});
|
|
422
|
+
}
|
|
378
423
|
setNextDismissedKey(route.key);
|
|
379
424
|
},
|
|
380
425
|
onHeaderBackButtonClicked: () => {
|
|
@@ -416,6 +461,9 @@ const styles = StyleSheet.create({
|
|
|
416
461
|
container: {
|
|
417
462
|
flex: 1
|
|
418
463
|
},
|
|
464
|
+
content: {
|
|
465
|
+
flex: 1
|
|
466
|
+
},
|
|
419
467
|
header: {
|
|
420
468
|
zIndex: 1
|
|
421
469
|
},
|