@react-navigation/native-stack 8.0.0-alpha.4 → 8.0.0-alpha.41
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 +4 -8
- 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 +113 -68
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/module/views/useHeaderConfigProps.js +71 -21
- 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 +145 -148
- 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 +1 -1
- package/lib/typescript/src/views/useHeaderConfigProps.d.ts.map +1 -1
- package/package.json +18 -19
- package/src/index.tsx +1 -0
- package/src/navigators/createNativeStackNavigator.tsx +11 -47
- package/src/types.tsx +206 -186
- 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 +168 -89
- package/src/views/NativeStackView.tsx +70 -41
- package/src/views/useHeaderConfigProps.tsx +100 -36
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,7 +30,7 @@ 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
|
|
@@ -65,10 +65,6 @@ function NativeStackNavigator({
|
|
|
65
65
|
})
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
export
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
export function createNativeStackScreen(config) {
|
|
72
|
-
return config;
|
|
73
|
-
}
|
|
68
|
+
export const createNativeStackNavigator = createNavigatorFactory(NativeStackNavigator);
|
|
69
|
+
export const createNativeStackScreen = createScreenFactory();
|
|
74
70
|
//# 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","addListener","e","isFocused","requestAnimationFrame","index","defaultPrevented","dispatch","popToTop","target","key","createNativeStackNavigator","createNativeStackScreen"],"sourceRoot":"../../../src","sources":["navigators/createNativeStackNavigator.tsx"],"mappings":";;AAAA,SACEA,sBAAsB,EACtBC,mBAAmB,EAEnBC,qBAAqB,EAIrBC,YAAY,EAEZ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,UAAU,EAAEF,KAAK,CAACY,KAAK,EAAEZ,KAAK,CAACiB,GAAG,CAAC,CAAC;EAE9C,oBACE5B,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,MAAMiB,0BAA0B,GACrCtC,sBAAsB,CAAqBU,oBAAoB,CAAC;AAElE,OAAO,MAAM6B,uBAAuB,GAClCtC,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,MAAM,QACD,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D,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,
|
|
@@ -76,7 +79,6 @@ const SceneView = ({
|
|
|
76
79
|
statusBarStyle,
|
|
77
80
|
unstable_sheetFooter,
|
|
78
81
|
scrollEdgeEffects,
|
|
79
|
-
freezeOnBlur,
|
|
80
82
|
contentStyle
|
|
81
83
|
} = options;
|
|
82
84
|
let {
|
|
@@ -97,9 +99,9 @@ const SceneView = ({
|
|
|
97
99
|
|
|
98
100
|
// Modals are fullscreen in landscape only on iPhone
|
|
99
101
|
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad || Platform.isTV);
|
|
100
|
-
const isParentHeaderShown = React.
|
|
101
|
-
const parentHeaderHeight = React.
|
|
102
|
-
const parentHeaderBack = React.
|
|
102
|
+
const isParentHeaderShown = React.use(HeaderShownContext);
|
|
103
|
+
const parentHeaderHeight = React.use(HeaderHeightContext);
|
|
104
|
+
const parentHeaderBack = React.use(HeaderBackContext);
|
|
103
105
|
const isLandscape = useFrameSize(frame => frame.width > frame.height);
|
|
104
106
|
const topInset = isParentHeaderShown || Platform.OS === 'ios' && isModal || isIPhone && isLandscape ? 0 : insets.top;
|
|
105
107
|
const defaultHeaderHeight = useFrameSize(frame => Platform.select({
|
|
@@ -148,6 +150,13 @@ const SceneView = ({
|
|
|
148
150
|
headerTopInsetEnabled,
|
|
149
151
|
headerBack
|
|
150
152
|
});
|
|
153
|
+
const headerContainerRef = React.useRef(null);
|
|
154
|
+
React.useLayoutEffect(() => {
|
|
155
|
+
headerContainerRef.current?.measure((_x, _y, _width, height) => {
|
|
156
|
+
animatedHeaderHeight.setValue(height);
|
|
157
|
+
setHeaderHeight(height);
|
|
158
|
+
});
|
|
159
|
+
}, [animatedHeaderHeight]);
|
|
151
160
|
const onHeaderHeightChange = hasCustomHeader ?
|
|
152
161
|
// If we have a custom header, don't use native header height
|
|
153
162
|
undefined :
|
|
@@ -171,7 +180,9 @@ const SceneView = ({
|
|
|
171
180
|
if (doesHeaderAnimate) {
|
|
172
181
|
setHeaderHeightDebounced(headerHeight);
|
|
173
182
|
} else {
|
|
174
|
-
if (Platform.OS === 'android' && headerHeight !== 0 &&
|
|
183
|
+
if (Platform.OS === 'android' && headerHeight !== 0 &&
|
|
184
|
+
// On some devices, height maybe slightly off (e.g. 56.17 instead of 56)
|
|
185
|
+
Math.round(headerHeight) <= ANDROID_DEFAULT_HEADER_HEIGHT) {
|
|
175
186
|
// FIXME: On Android, events may get delivered out-of-order
|
|
176
187
|
// https://github.com/facebook/react-native/issues/54636
|
|
177
188
|
// We seem to get header height without status bar height first,
|
|
@@ -188,18 +199,77 @@ const SceneView = ({
|
|
|
188
199
|
}
|
|
189
200
|
}
|
|
190
201
|
});
|
|
202
|
+
const activityMode =
|
|
203
|
+
// Render focused screens normally
|
|
204
|
+
// Unpause preloaded and retained screens so updates are visible
|
|
205
|
+
// Unpause previous screen so update isn't delayed for swipe back
|
|
206
|
+
// This lets effects on those screens run
|
|
207
|
+
// We don't need to handle inert as it'll be handled natively
|
|
208
|
+
inactiveBehavior === 'none' || focused || isInactive || isNextScreenTransparent ||
|
|
209
|
+
// Unpause the screen behind a sheet so it stays up to date
|
|
210
|
+
// Sheets don't cover the whole screen, so the screen behind is visible
|
|
211
|
+
isNextScreenSheet ||
|
|
212
|
+
// On iPadOS, the base screen is visible while modal is in a smaller area
|
|
213
|
+
// So also keep the screens unpaused
|
|
214
|
+
isNextScreenModal && !isModal || isBeforeLast ? 'normal' : inactiveBehavior === 'unmount' && !('state' in route && route.state) ? 'unmounted' : 'paused';
|
|
215
|
+
const content = /*#__PURE__*/_jsx(AnimatedHeaderHeightContext.Provider, {
|
|
216
|
+
value: animatedHeaderHeight,
|
|
217
|
+
children: /*#__PURE__*/_jsxs(HeaderHeightContext.Provider, {
|
|
218
|
+
value: headerShown !== false ? headerHeight : parentHeaderHeight ?? 0,
|
|
219
|
+
children: [headerBackground != null ?
|
|
220
|
+
/*#__PURE__*/
|
|
221
|
+
/**
|
|
222
|
+
* To show a custom header background, we render it at the top of the screen below the header
|
|
223
|
+
* The header also needs to be positioned absolutely (with `translucent` style)
|
|
224
|
+
*/
|
|
225
|
+
_jsx(View, {
|
|
226
|
+
style: [styles.background, headerTransparent ? styles.translucent : null, {
|
|
227
|
+
height: headerHeight
|
|
228
|
+
}],
|
|
229
|
+
children: headerBackground()
|
|
230
|
+
}) : null, header != null && headerShown !== false ? /*#__PURE__*/_jsx(View, {
|
|
231
|
+
style: [styles.header, headerTransparent ? [styles.absolute,
|
|
232
|
+
// Specify an explicit min height for Android screen readers
|
|
233
|
+
{
|
|
234
|
+
minHeight: headerHeight
|
|
235
|
+
}] : null],
|
|
236
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
237
|
+
ref: headerContainerRef,
|
|
238
|
+
onLayout: e => {
|
|
239
|
+
const headerHeight = e.nativeEvent.layout.height;
|
|
240
|
+
animatedHeaderHeight.setValue(headerHeight);
|
|
241
|
+
setHeaderHeight(headerHeight);
|
|
242
|
+
},
|
|
243
|
+
style: {
|
|
244
|
+
pointerEvents: 'box-none'
|
|
245
|
+
},
|
|
246
|
+
children: header({
|
|
247
|
+
back: headerBack,
|
|
248
|
+
options,
|
|
249
|
+
route,
|
|
250
|
+
navigation
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
}) : null, /*#__PURE__*/_jsx(HeaderShownContext.Provider, {
|
|
254
|
+
value: isParentHeaderShown || headerShown !== false,
|
|
255
|
+
children: /*#__PURE__*/_jsx(HeaderBackContext.Provider, {
|
|
256
|
+
value: headerBack,
|
|
257
|
+
children: render()
|
|
258
|
+
})
|
|
259
|
+
})]
|
|
260
|
+
})
|
|
261
|
+
});
|
|
191
262
|
return /*#__PURE__*/_jsx(NavigationProvider, {
|
|
192
263
|
navigation: navigation,
|
|
193
264
|
route: route,
|
|
194
265
|
children: /*#__PURE__*/_jsx(ScreenStackItem, {
|
|
195
266
|
screenId: route.key,
|
|
196
|
-
activityState:
|
|
267
|
+
activityState: isInactive ? 0 : 2,
|
|
197
268
|
style: StyleSheet.absoluteFill,
|
|
198
269
|
"aria-hidden": !focused,
|
|
199
270
|
customAnimationOnSwipe: animationMatchesGesture,
|
|
200
271
|
fullScreenSwipeEnabled: fullScreenGestureEnabled,
|
|
201
272
|
fullScreenSwipeShadowEnabled: fullScreenGestureShadowEnabled,
|
|
202
|
-
freezeOnBlur: freezeOnBlur,
|
|
203
273
|
gestureEnabled: Platform.OS === 'android' ?
|
|
204
274
|
// This prop enables handling of system back gestures on Android
|
|
205
275
|
// Since we handle them in JS side, we disable this
|
|
@@ -250,48 +320,16 @@ const SceneView = ({
|
|
|
250
320
|
backgroundColor: colors.background
|
|
251
321
|
}, contentStyle],
|
|
252
322
|
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
|
-
})
|
|
323
|
+
unstable_sheetFooter: unstable_sheetFooter,
|
|
324
|
+
children: activityMode === 'unmounted' ? null : /*#__PURE__*/_jsx(ActivityView, {
|
|
325
|
+
mode: activityMode,
|
|
326
|
+
visible:
|
|
327
|
+
// We don't need to hide the content since it's handled natively
|
|
328
|
+
// Hiding may also cause flash due to lag after native tab switch
|
|
329
|
+
// So we leave it always visible
|
|
330
|
+
true,
|
|
331
|
+
style: styles.content,
|
|
332
|
+
children: content
|
|
295
333
|
})
|
|
296
334
|
}, route.key)
|
|
297
335
|
});
|
|
@@ -305,34 +343,38 @@ export function NativeStackView({
|
|
|
305
343
|
setNextDismissedKey
|
|
306
344
|
} = useDismissedRouteError(state);
|
|
307
345
|
useInvalidPreventRemoveError(descriptors);
|
|
308
|
-
const
|
|
346
|
+
const activeRoutes = state.routes.slice(0, state.index + 1);
|
|
347
|
+
const modalRouteKeys = getModalRouteKeys(activeRoutes, descriptors);
|
|
309
348
|
return /*#__PURE__*/_jsx(SafeAreaProviderCompat, {
|
|
310
349
|
children: /*#__PURE__*/_jsx(ScreenStack, {
|
|
311
350
|
style: styles.container,
|
|
312
|
-
children: state.routes.
|
|
351
|
+
children: state.routes.map((route, index) => {
|
|
313
352
|
const descriptor = descriptors[route.key];
|
|
353
|
+
if (descriptor == null) {
|
|
354
|
+
throw new Error(`Couldn't find a descriptor for route '${route.key}'.`);
|
|
355
|
+
}
|
|
314
356
|
const isFocused = state.index === index;
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
const nextKey = state.routes[index + 1]?.key;
|
|
357
|
+
const previousKey = activeRoutes[index - 1]?.key;
|
|
358
|
+
const nextKey = activeRoutes[index + 1]?.key;
|
|
318
359
|
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
319
360
|
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
361
|
+
const nextPresentation = nextDescriptor?.options.presentation;
|
|
362
|
+
const isNextScreenTransparent = nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation);
|
|
363
|
+
const isNextScreenSheet = nextPresentation != null && SHEET_PRESENTATIONS.includes(nextPresentation);
|
|
364
|
+
const isNextScreenModal = nextKey ? modalRouteKeys.includes(nextKey) : false;
|
|
320
365
|
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
366
|
return /*#__PURE__*/_jsx(SceneView, {
|
|
328
367
|
index: index,
|
|
329
368
|
focused: isFocused,
|
|
330
|
-
shouldFreeze: shouldFreeze,
|
|
331
369
|
descriptor: descriptor,
|
|
332
370
|
previousDescriptor: previousDescriptor,
|
|
333
371
|
nextDescriptor: nextDescriptor,
|
|
334
372
|
isPresentationModal: isModal,
|
|
335
|
-
|
|
373
|
+
isNextScreenTransparent: isNextScreenTransparent,
|
|
374
|
+
isNextScreenSheet: isNextScreenSheet,
|
|
375
|
+
isNextScreenModal: isNextScreenModal,
|
|
376
|
+
isInactive: index > state.index,
|
|
377
|
+
isBeforeLast: index === activeRoutes.length - 2,
|
|
336
378
|
onWillDisappear: () => {
|
|
337
379
|
navigation.emit({
|
|
338
380
|
type: 'transitionStart',
|
|
@@ -416,6 +458,9 @@ const styles = StyleSheet.create({
|
|
|
416
458
|
container: {
|
|
417
459
|
flex: 1
|
|
418
460
|
},
|
|
461
|
+
content: {
|
|
462
|
+
flex: 1
|
|
463
|
+
},
|
|
419
464
|
header: {
|
|
420
465
|
zIndex: 1
|
|
421
466
|
},
|