@react-navigation/native-stack 6.6.1 → 6.8.0
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/utils/useDismissedRouteError.js +29 -0
- package/lib/commonjs/utils/useDismissedRouteError.js.map +1 -0
- package/lib/commonjs/utils/useInvalidPreventRemoveError.js +33 -0
- package/lib/commonjs/utils/useInvalidPreventRemoveError.js.map +1 -0
- package/lib/commonjs/views/HeaderConfig.js +6 -3
- package/lib/commonjs/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.js +16 -14
- package/lib/commonjs/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.native.js +99 -24
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/utils/useDismissedRouteError.js +17 -0
- package/lib/module/utils/useDismissedRouteError.js.map +1 -0
- package/lib/module/utils/useInvalidPreventRemoveError.js +20 -0
- package/lib/module/utils/useInvalidPreventRemoveError.js.map +1 -0
- package/lib/module/views/HeaderConfig.js +7 -4
- package/lib/module/views/HeaderConfig.js.map +1 -1
- package/lib/module/views/NativeStackView.js +17 -15
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +99 -26
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/typescript/src/types.d.ts +48 -0
- package/lib/typescript/src/utils/useDismissedRouteError.d.ts +5 -0
- package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts +2 -0
- package/package.json +12 -11
- package/src/types.tsx +48 -0
- package/src/utils/useDismissedRouteError.tsx +30 -0
- package/src/utils/useInvalidPreventRemoveError.tsx +31 -0
- package/src/views/HeaderConfig.tsx +8 -5
- package/src/views/NativeStackView.native.tsx +108 -32
- package/src/views/NativeStackView.tsx +27 -26
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useInvalidPreventRemoveError;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
|
|
14
|
+
function useInvalidPreventRemoveError(state) {
|
|
15
|
+
var _state$routes$find;
|
|
16
|
+
|
|
17
|
+
const [nextDismissedKey, setNextDismissedKey] = React.useState(null);
|
|
18
|
+
const dismissedRouteName = nextDismissedKey ? (_state$routes$find = state.routes.find(route => route.key === nextDismissedKey)) === null || _state$routes$find === void 0 ? void 0 : _state$routes$find.name : null;
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (dismissedRouteName) {
|
|
21
|
+
const message = `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` + `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\n\n` + `Consider using a 'usePreventRemove' hook with 'headerBackButtonMenuEnabled: false' to prevent users from natively going back multiple screens.`;
|
|
22
|
+
console.error(message);
|
|
23
|
+
}
|
|
24
|
+
}, [dismissedRouteName]);
|
|
25
|
+
return {
|
|
26
|
+
setNextDismissedKey
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=useDismissedRouteError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useDismissedRouteError.tsx"],"names":["useInvalidPreventRemoveError","state","nextDismissedKey","setNextDismissedKey","React","useState","dismissedRouteName","routes","find","route","key","name","useEffect","message","console","error"],"mappings":";;;;;;;AAIA;;;;;;AAEe,SAASA,4BAAT,CACbC,KADa,EAEb;AAAA;;AACA,QAAM,CAACC,gBAAD,EAAmBC,mBAAnB,IAA0CC,KAAK,CAACC,QAAN,CAC9C,IAD8C,CAAhD;AAIA,QAAMC,kBAAkB,GAAGJ,gBAAgB,yBACvCD,KAAK,CAACM,MAAN,CAAaC,IAAb,CAAmBC,KAAD,IAAWA,KAAK,CAACC,GAAN,KAAcR,gBAA3C,CADuC,uDACvC,mBAA8DS,IADvB,GAEvC,IAFJ;AAIAP,EAAAA,KAAK,CAACQ,SAAN,CAAgB,MAAM;AACpB,QAAIN,kBAAJ,EAAwB;AACtB,YAAMO,OAAO,GACV,eAAcP,kBAAmB,+DAAlC,GACC,6HADD,GAEC,gJAHH;AAKAQ,MAAAA,OAAO,CAACC,KAAR,CAAcF,OAAd;AACD;AACF,GATD,EASG,CAACP,kBAAD,CATH;AAWA,SAAO;AAAEH,IAAAA;AAAF,GAAP;AACD","sourcesContent":["import type {\n ParamListBase,\n StackNavigationState,\n} from '@react-navigation/native';\nimport * as React from 'react';\n\nexport default function useInvalidPreventRemoveError(\n state: StackNavigationState<ParamListBase>\n) {\n const [nextDismissedKey, setNextDismissedKey] = React.useState<string | null>(\n null\n );\n\n const dismissedRouteName = nextDismissedKey\n ? state.routes.find((route) => route.key === nextDismissedKey)?.name\n : null;\n\n React.useEffect(() => {\n if (dismissedRouteName) {\n const message =\n `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` +\n `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\\n\\n` +\n `Consider using a 'usePreventRemove' hook with 'headerBackButtonMenuEnabled: false' to prevent users from natively going back multiple screens.`;\n\n console.error(message);\n }\n }, [dismissedRouteName]);\n\n return { setNextDismissedKey };\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useInvalidPreventRemoveError;
|
|
7
|
+
|
|
8
|
+
var _native = require("@react-navigation/native");
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
|
|
16
|
+
function useInvalidPreventRemoveError(descriptors) {
|
|
17
|
+
var _preventedDescriptor$, _preventedDescriptor$2;
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
preventedRoutes
|
|
21
|
+
} = (0, _native.usePreventRemoveContext)();
|
|
22
|
+
const preventedRouteKey = Object.keys(preventedRoutes)[0];
|
|
23
|
+
const preventedDescriptor = descriptors[preventedRouteKey];
|
|
24
|
+
const isHeaderBackButtonMenuEnabledOnPreventedScreen = preventedDescriptor === null || preventedDescriptor === void 0 ? void 0 : (_preventedDescriptor$ = preventedDescriptor.options) === null || _preventedDescriptor$ === void 0 ? void 0 : _preventedDescriptor$.headerBackButtonMenuEnabled;
|
|
25
|
+
const preventedRouteName = preventedDescriptor === null || preventedDescriptor === void 0 ? void 0 : (_preventedDescriptor$2 = preventedDescriptor.route) === null || _preventedDescriptor$2 === void 0 ? void 0 : _preventedDescriptor$2.name;
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
if (preventedRouteKey != null && isHeaderBackButtonMenuEnabledOnPreventedScreen) {
|
|
28
|
+
const message = `The screen ${preventedRouteName} uses 'usePreventRemove' hook alongside 'headerBackButtonMenuEnabled: true', which is not supported. \n\n` + `Consider removing 'headerBackButtonMenuEnabled: true' from ${preventedRouteName} screen to get rid of this error.`;
|
|
29
|
+
console.error(message);
|
|
30
|
+
}
|
|
31
|
+
}, [preventedRouteKey, isHeaderBackButtonMenuEnabledOnPreventedScreen, preventedRouteName]);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=useInvalidPreventRemoveError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useInvalidPreventRemoveError.tsx"],"names":["useInvalidPreventRemoveError","descriptors","preventedRoutes","preventedRouteKey","Object","keys","preventedDescriptor","isHeaderBackButtonMenuEnabledOnPreventedScreen","options","headerBackButtonMenuEnabled","preventedRouteName","route","name","React","useEffect","message","console","error"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAIe,SAASA,4BAAT,CACbC,WADa,EAEb;AAAA;;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAsB,sCAA5B;AACA,QAAMC,iBAAiB,GAAGC,MAAM,CAACC,IAAP,CAAYH,eAAZ,EAA6B,CAA7B,CAA1B;AACA,QAAMI,mBAAmB,GAAGL,WAAW,CAACE,iBAAD,CAAvC;AACA,QAAMI,8CAA8C,GAClDD,mBADkD,aAClDA,mBADkD,gDAClDA,mBAAmB,CAAEE,OAD6B,0DAClD,sBAA8BC,2BADhC;AAEA,QAAMC,kBAAkB,GAAGJ,mBAAH,aAAGA,mBAAH,iDAAGA,mBAAmB,CAAEK,KAAxB,2DAAG,uBAA4BC,IAAvD;AAEAC,EAAAA,KAAK,CAACC,SAAN,CAAgB,MAAM;AACpB,QACEX,iBAAiB,IAAI,IAArB,IACAI,8CAFF,EAGE;AACA,YAAMQ,OAAO,GACV,cAAaL,kBAAmB,2GAAjC,GACC,8DAA6DA,kBAAmB,mCAFnF;AAGAM,MAAAA,OAAO,CAACC,KAAR,CAAcF,OAAd;AACD;AACF,GAVD,EAUG,CACDZ,iBADC,EAEDI,8CAFC,EAGDG,kBAHC,CAVH;AAeD","sourcesContent":["import { usePreventRemoveContext } from '@react-navigation/native';\nimport * as React from 'react';\n\nimport type { NativeStackDescriptorMap } from '../types';\n\nexport default function useInvalidPreventRemoveError(\n descriptors: NativeStackDescriptorMap\n) {\n const { preventedRoutes } = usePreventRemoveContext();\n const preventedRouteKey = Object.keys(preventedRoutes)[0];\n const preventedDescriptor = descriptors[preventedRouteKey];\n const isHeaderBackButtonMenuEnabledOnPreventedScreen =\n preventedDescriptor?.options?.headerBackButtonMenuEnabled;\n const preventedRouteName = preventedDescriptor?.route?.name;\n\n React.useEffect(() => {\n if (\n preventedRouteKey != null &&\n isHeaderBackButtonMenuEnabledOnPreventedScreen\n ) {\n const message =\n `The screen ${preventedRouteName} uses 'usePreventRemove' hook alongside 'headerBackButtonMenuEnabled: true', which is not supported. \\n\\n` +\n `Consider removing 'headerBackButtonMenuEnabled: true' from ${preventedRouteName} screen to get rid of this error.`;\n console.error(message);\n }\n }, [\n preventedRouteKey,\n isHeaderBackButtonMenuEnabledOnPreventedScreen,\n preventedRouteName,\n ]);\n}\n"]}
|
|
@@ -66,7 +66,10 @@ function HeaderConfig(_ref) {
|
|
|
66
66
|
const headerStyleFlattened = _reactNative.StyleSheet.flatten(headerStyle) || {};
|
|
67
67
|
const headerLargeStyleFlattened = _reactNative.StyleSheet.flatten(headerLargeStyle) || {};
|
|
68
68
|
const [backTitleFontFamily, largeTitleFontFamily, titleFontFamily] = (0, _FontProcessor.processFonts)([headerBackTitleStyleFlattened.fontFamily, headerLargeTitleStyleFlattened.fontFamily, headerTitleStyleFlattened.fontFamily]);
|
|
69
|
-
const titleText =
|
|
69
|
+
const titleText = (0, _elements.getHeaderTitle)({
|
|
70
|
+
title,
|
|
71
|
+
headerTitle
|
|
72
|
+
}, route.name);
|
|
70
73
|
const titleColor = (_ref2 = (_headerTitleStyleFlat = headerTitleStyleFlattened.color) !== null && _headerTitleStyleFlat !== void 0 ? _headerTitleStyleFlat : headerTintColor) !== null && _ref2 !== void 0 ? _ref2 : colors.text;
|
|
71
74
|
const titleFontSize = headerTitleStyleFlattened.fontSize;
|
|
72
75
|
const titleFontWeight = headerTitleStyleFlattened.fontWeight;
|
|
@@ -128,7 +131,7 @@ function HeaderConfig(_ref) {
|
|
|
128
131
|
backTitleFontSize: headerBackTitleStyleFlattened.fontSize,
|
|
129
132
|
blurEffect: headerBlurEffect,
|
|
130
133
|
color: tintColor,
|
|
131
|
-
direction: _reactNative.I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
134
|
+
direction: _reactNative.I18nManager.getConstants().isRTL ? 'rtl' : 'ltr',
|
|
132
135
|
disableBackButtonMenu: headerBackButtonMenuEnabled === false,
|
|
133
136
|
hidden: headerShown === false,
|
|
134
137
|
hideBackButton: headerBackVisible === false,
|
|
@@ -140,7 +143,7 @@ function HeaderConfig(_ref) {
|
|
|
140
143
|
largeTitleFontSize: headerLargeTitleStyleFlattened.fontSize,
|
|
141
144
|
largeTitleFontWeight: headerLargeTitleStyleFlattened.fontWeight,
|
|
142
145
|
largeTitleHideShadow: headerLargeTitleShadowVisible === false,
|
|
143
|
-
title:
|
|
146
|
+
title: titleText,
|
|
144
147
|
titleColor: titleColor,
|
|
145
148
|
titleFontFamily: titleFontFamily,
|
|
146
149
|
titleFontSize: titleFontSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["HeaderConfig.tsx"],"names":["HeaderConfig","headerHeight","headerBackImageSource","headerBackButtonMenuEnabled","headerBackTitle","headerBackTitleStyle","headerBackTitleVisible","headerBackVisible","headerShadowVisible","headerLargeStyle","headerLargeTitle","headerLargeTitleShadowVisible","headerLargeTitleStyle","headerBackground","headerLeft","headerRight","headerShown","headerStyle","headerBlurEffect","headerTintColor","headerTitle","headerTitleAlign","headerTitleStyle","headerTransparent","headerSearchBarOptions","route","title","canGoBack","insets","colors","tintColor","Platform","OS","primary","text","headerBackTitleStyleFlattened","StyleSheet","flatten","headerLargeTitleStyleFlattened","headerTitleStyleFlattened","headerStyleFlattened","headerLargeStyleFlattened","backTitleFontFamily","largeTitleFontFamily","titleFontFamily","fontFamily","titleText","undefined","name","titleColor","color","titleFontSize","fontSize","titleFontWeight","fontWeight","headerTitleStyleSupported","headerLeftElement","label","headerRightElement","headerTitleElement","children","supportsHeaderSearchBar","isSearchBarAvailableForCurrentPlatform","SearchBar","hasHeaderSearchBar","Error","backButtonInCustomView","translucent","styles","background","height","backgroundColor","card","I18nManager","isRTL","top","row","create","flexDirection","alignItems","position","left","right","zIndex","overflow"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAYA;;;;;;AAQe,SAASA,YAAT,OA4BQ;AAAA;;AAAA,MA5Bc;AACnCC,IAAAA,YADmC;AAEnCC,IAAAA,qBAFmC;AAGnCC,IAAAA,2BAHmC;AAInCC,IAAAA,eAJmC;AAKnCC,IAAAA,oBALmC;AAMnCC,IAAAA,sBAAsB,GAAG,IANU;AAOnCC,IAAAA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;AACVe,IAAAA,QAAQ,EAAE;AADA;AAZmB,CAAlB,CAAf","sourcesContent":["import { HeaderTitle } from '@react-navigation/elements';\nimport { Route, useTheme } from '@react-navigation/native';\nimport * as React from 'react';\nimport {\n I18nManager,\n Platform,\n StyleSheet,\n TextStyle,\n View,\n} from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport {\n isSearchBarAvailableForCurrentPlatform,\n ScreenStackHeaderBackButtonImage,\n ScreenStackHeaderCenterView,\n ScreenStackHeaderConfig,\n ScreenStackHeaderLeftView,\n ScreenStackHeaderRightView,\n ScreenStackHeaderSearchBarView,\n SearchBar,\n} from 'react-native-screens';\n\nimport type { NativeStackNavigationOptions } from '../types';\nimport { processFonts } from './FontProcessor';\n\ntype Props = NativeStackNavigationOptions & {\n headerHeight: number;\n route: Route<string>;\n canGoBack: boolean;\n};\n\nexport default function HeaderConfig({\n headerHeight,\n headerBackImageSource,\n headerBackButtonMenuEnabled,\n headerBackTitle,\n headerBackTitleStyle,\n headerBackTitleVisible = true,\n headerBackVisible,\n headerShadowVisible,\n headerLargeStyle,\n headerLargeTitle,\n headerLargeTitleShadowVisible,\n headerLargeTitleStyle,\n headerBackground,\n headerLeft,\n headerRight,\n headerShown,\n headerStyle,\n headerBlurEffect,\n headerTintColor,\n headerTitle,\n headerTitleAlign,\n headerTitleStyle,\n headerTransparent,\n headerSearchBarOptions,\n route,\n title,\n canGoBack,\n}: Props): JSX.Element {\n const insets = useSafeAreaInsets();\n\n const { colors } = useTheme();\n const tintColor =\n headerTintColor ?? (Platform.OS === 'ios' ? colors.primary : colors.text);\n\n const headerBackTitleStyleFlattened =\n StyleSheet.flatten(headerBackTitleStyle) || {};\n const headerLargeTitleStyleFlattened =\n StyleSheet.flatten(headerLargeTitleStyle) || {};\n const headerTitleStyleFlattened = StyleSheet.flatten(headerTitleStyle) || {};\n const headerStyleFlattened = StyleSheet.flatten(headerStyle) || {};\n const headerLargeStyleFlattened = StyleSheet.flatten(headerLargeStyle) || {};\n\n const [backTitleFontFamily, largeTitleFontFamily, titleFontFamily] =\n processFonts([\n headerBackTitleStyleFlattened.fontFamily,\n headerLargeTitleStyleFlattened.fontFamily,\n headerTitleStyleFlattened.fontFamily,\n ]);\n\n const titleText = title !== undefined ? title : route.name;\n const titleColor =\n headerTitleStyleFlattened.color ?? headerTintColor ?? colors.text;\n const titleFontSize = headerTitleStyleFlattened.fontSize;\n const titleFontWeight = headerTitleStyleFlattened.fontWeight;\n\n const headerTitleStyleSupported: TextStyle = { color: titleColor };\n\n if (headerTitleStyleFlattened.fontFamily != null) {\n headerTitleStyleSupported.fontFamily = headerTitleStyleFlattened.fontFamily;\n }\n\n if (titleFontSize != null) {\n headerTitleStyleSupported.fontSize = titleFontSize;\n }\n\n if (titleFontWeight != null) {\n headerTitleStyleSupported.fontWeight = titleFontWeight;\n }\n\n const headerLeftElement = headerLeft?.({\n tintColor,\n canGoBack,\n label: headerBackTitle,\n });\n const headerRightElement = headerRight?.({\n tintColor,\n canGoBack,\n });\n const headerTitleElement =\n typeof headerTitle === 'function'\n ? headerTitle({ tintColor, children: titleText })\n : null;\n\n const supportsHeaderSearchBar =\n typeof isSearchBarAvailableForCurrentPlatform === 'boolean'\n ? isSearchBarAvailableForCurrentPlatform\n : // Fallback for older versions of react-native-screens\n Platform.OS === 'ios' && SearchBar != null;\n\n const hasHeaderSearchBar =\n supportsHeaderSearchBar && headerSearchBarOptions != null;\n\n if (headerSearchBarOptions != null && !supportsHeaderSearchBar) {\n throw new Error(\n `The current version of 'react-native-screens' doesn't support SearchBar in the header. Please update to the latest version to use this option.`\n );\n }\n\n /**\n * We need to set this in if:\n * - Back button should stay visible when `headerLeft` is specified\n * - If `headerTitle` for Android is specified, so we only need to remove the title and keep the back button\n */\n const backButtonInCustomView = headerBackVisible\n ? headerLeftElement != null\n : Platform.OS === 'android' && headerTitleElement != null;\n\n const translucent =\n headerBackground != null ||\n headerTransparent ||\n // When using a SearchBar or large title, the header needs to be translucent for it to work on iOS\n ((hasHeaderSearchBar || headerLargeTitle) &&\n Platform.OS === 'ios' &&\n headerTransparent !== false);\n\n return (\n <>\n {headerBackground != null ? (\n <View\n style={[\n styles.background,\n headerTransparent ? styles.translucent : null,\n { height: headerHeight },\n ]}\n >\n {headerBackground()}\n </View>\n ) : null}\n <ScreenStackHeaderConfig\n backButtonInCustomView={backButtonInCustomView}\n backgroundColor={\n headerStyleFlattened.backgroundColor ??\n (headerBackground != null || headerTransparent\n ? 'transparent'\n : colors.card)\n }\n backTitle={headerBackTitleVisible ? headerBackTitle : ' '}\n backTitleFontFamily={backTitleFontFamily}\n backTitleFontSize={headerBackTitleStyleFlattened.fontSize}\n blurEffect={headerBlurEffect}\n color={tintColor}\n direction={I18nManager.isRTL ? 'rtl' : 'ltr'}\n disableBackButtonMenu={headerBackButtonMenuEnabled === false}\n hidden={headerShown === false}\n hideBackButton={headerBackVisible === false}\n hideShadow={\n headerShadowVisible === false ||\n headerBackground != null ||\n headerTransparent\n }\n largeTitle={headerLargeTitle}\n largeTitleBackgroundColor={headerLargeStyleFlattened.backgroundColor}\n largeTitleColor={headerLargeTitleStyleFlattened.color}\n largeTitleFontFamily={largeTitleFontFamily}\n largeTitleFontSize={headerLargeTitleStyleFlattened.fontSize}\n largeTitleFontWeight={headerLargeTitleStyleFlattened.fontWeight}\n largeTitleHideShadow={headerLargeTitleShadowVisible === false}\n title={typeof headerTitle === 'string' ? headerTitle : titleText}\n titleColor={titleColor}\n titleFontFamily={titleFontFamily}\n titleFontSize={titleFontSize}\n titleFontWeight={titleFontWeight}\n topInsetEnabled={insets.top !== 0}\n translucent={\n // This defaults to `true`, so we can't pass `undefined`\n translucent === true\n }\n >\n {Platform.OS === 'ios' ? (\n <>\n {headerLeftElement != null ? (\n <ScreenStackHeaderLeftView>\n {headerLeftElement}\n </ScreenStackHeaderLeftView>\n ) : null}\n {headerTitleElement != null ? (\n <ScreenStackHeaderCenterView>\n {headerTitleElement}\n </ScreenStackHeaderCenterView>\n ) : null}\n </>\n ) : (\n <>\n {headerLeftElement != null || typeof headerTitle === 'function' ? (\n <ScreenStackHeaderLeftView>\n <View style={styles.row}>\n {headerLeftElement}\n {headerTitleAlign !== 'center' ? (\n typeof headerTitle === 'function' ? (\n headerTitleElement\n ) : (\n <HeaderTitle\n tintColor={tintColor}\n style={headerTitleStyleSupported}\n >\n {titleText}\n </HeaderTitle>\n )\n ) : null}\n </View>\n </ScreenStackHeaderLeftView>\n ) : null}\n {headerTitleAlign === 'center' ? (\n <ScreenStackHeaderCenterView>\n {typeof headerTitle === 'function' ? (\n headerTitleElement\n ) : (\n <HeaderTitle\n tintColor={tintColor}\n style={headerTitleStyleSupported}\n >\n {titleText}\n </HeaderTitle>\n )}\n </ScreenStackHeaderCenterView>\n ) : null}\n </>\n )}\n {headerBackImageSource !== undefined ? (\n <ScreenStackHeaderBackButtonImage source={headerBackImageSource} />\n ) : null}\n {headerRightElement != null ? (\n <ScreenStackHeaderRightView>\n {headerRightElement}\n </ScreenStackHeaderRightView>\n ) : null}\n {hasHeaderSearchBar ? (\n <ScreenStackHeaderSearchBarView>\n <SearchBar {...headerSearchBarOptions} />\n </ScreenStackHeaderSearchBarView>\n ) : null}\n </ScreenStackHeaderConfig>\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n translucent: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n zIndex: 1,\n },\n background: {\n overflow: 'hidden',\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["HeaderConfig.tsx"],"names":["HeaderConfig","headerHeight","headerBackImageSource","headerBackButtonMenuEnabled","headerBackTitle","headerBackTitleStyle","headerBackTitleVisible","headerBackVisible","headerShadowVisible","headerLargeStyle","headerLargeTitle","headerLargeTitleShadowVisible","headerLargeTitleStyle","headerBackground","headerLeft","headerRight","headerShown","headerStyle","headerBlurEffect","headerTintColor","headerTitle","headerTitleAlign","headerTitleStyle","headerTransparent","headerSearchBarOptions","route","title","canGoBack","insets","colors","tintColor","Platform","OS","primary","text","headerBackTitleStyleFlattened","StyleSheet","flatten","headerLargeTitleStyleFlattened","headerTitleStyleFlattened","headerStyleFlattened","headerLargeStyleFlattened","backTitleFontFamily","largeTitleFontFamily","titleFontFamily","fontFamily","titleText","name","titleColor","color","titleFontSize","fontSize","titleFontWeight","fontWeight","headerTitleStyleSupported","headerLeftElement","label","headerRightElement","headerTitleElement","children","supportsHeaderSearchBar","isSearchBarAvailableForCurrentPlatform","SearchBar","hasHeaderSearchBar","Error","backButtonInCustomView","translucent","styles","background","height","backgroundColor","card","I18nManager","getConstants","isRTL","top","row","undefined","create","flexDirection","alignItems","position","left","right","zIndex","overflow"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAYA;;;;;;AAQe,SAASA,YAAT,OA4BQ;AAAA;;AAAA,MA5Bc;AACnCC,IAAAA,YADmC;AAEnCC,IAAAA,qBAFmC;AAGnCC,IAAAA,2BAHmC;AAInCC,IAAAA,eAJmC;AAKnCC,IAAAA,oBALmC;AAMnCC,IAAAA,sBAAsB,GAAG,IANU;AAOnCC,IAAAA,iBAPmC;AAQnCC,IAAAA,mBARmC;AASnCC,IAAAA,gBATmC;AAUnCC,IAAAA,gBAVmC;AAWnCC,IAAAA,6BAXmC;AAYnCC,IAAAA,qBAZmC;AAanCC,IAAAA,gBAbmC;AAcnCC,IAAAA,UAdmC;AAenCC,IAAAA,WAfmC;AAgBnCC,IAAAA,WAhBmC;AAiBnCC,IAAAA,WAjBmC;AAkBnCC,IAAAA,gBAlBmC;AAmBnCC,IAAAA,eAnBmC;AAoBnCC,IAAAA,WApBmC;AAqBnCC,IAAAA,gBArBmC;AAsBnCC,IAAAA,gBAtBmC;AAuBnCC,IAAAA,iBAvBmC;AAwBnCC,IAAAA,sBAxBmC;AAyBnCC,IAAAA,KAzBmC;AA0BnCC,IAAAA,KA1BmC;AA2BnCC,IAAAA;AA3BmC,GA4Bd;AACrB,QAAMC,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,IAjCN,CAtDJ,EA0FG5C,qBAAqB,KAAK2E,SAA1B,gBACC,oBAAC,oDAAD;AAAkC,IAAA,MAAM,EAAE3E;AAA1C,IADD,GAEG,IA5FN,EA6FGuD,kBAAkB,IAAI,IAAtB,gBACC,oBAAC,8CAAD,QACGA,kBADH,CADD,GAIG,IAjGN,EAkGGM,kBAAkB,gBACjB,oBAAC,kDAAD,qBACE,oBAAC,6BAAD,EAAevC,sBAAf,CADF,CADiB,GAIf,IAtGN,CAZF,CADF;AAuHD;;AAED,MAAM2C,MAAM,GAAG/B,wBAAW0C,MAAX,CAAkB;AAC/BF,EAAAA,GAAG,EAAE;AACHG,IAAAA,aAAa,EAAE,KADZ;AAEHC,IAAAA,UAAU,EAAE;AAFT,GAD0B;AAK/Bd,EAAAA,WAAW,EAAE;AACXe,IAAAA,QAAQ,EAAE,UADC;AAEXN,IAAAA,GAAG,EAAE,CAFM;AAGXO,IAAAA,IAAI,EAAE,CAHK;AAIXC,IAAAA,KAAK,EAAE,CAJI;AAKXC,IAAAA,MAAM,EAAE;AALG,GALkB;AAY/BhB,EAAAA,UAAU,EAAE;AACViB,IAAAA,QAAQ,EAAE;AADA;AAZmB,CAAlB,CAAf","sourcesContent":["import { getHeaderTitle, HeaderTitle } from '@react-navigation/elements';\nimport { Route, useTheme } from '@react-navigation/native';\nimport * as React from 'react';\nimport {\n I18nManager,\n Platform,\n StyleSheet,\n TextStyle,\n View,\n} from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport {\n isSearchBarAvailableForCurrentPlatform,\n ScreenStackHeaderBackButtonImage,\n ScreenStackHeaderCenterView,\n ScreenStackHeaderConfig,\n ScreenStackHeaderLeftView,\n ScreenStackHeaderRightView,\n ScreenStackHeaderSearchBarView,\n SearchBar,\n} from 'react-native-screens';\n\nimport type { NativeStackNavigationOptions } from '../types';\nimport { processFonts } from './FontProcessor';\n\ntype Props = NativeStackNavigationOptions & {\n headerHeight: number;\n route: Route<string>;\n canGoBack: boolean;\n};\n\nexport default function HeaderConfig({\n headerHeight,\n headerBackImageSource,\n headerBackButtonMenuEnabled,\n headerBackTitle,\n headerBackTitleStyle,\n headerBackTitleVisible = true,\n headerBackVisible,\n headerShadowVisible,\n headerLargeStyle,\n headerLargeTitle,\n headerLargeTitleShadowVisible,\n headerLargeTitleStyle,\n headerBackground,\n headerLeft,\n headerRight,\n headerShown,\n headerStyle,\n headerBlurEffect,\n headerTintColor,\n headerTitle,\n headerTitleAlign,\n headerTitleStyle,\n headerTransparent,\n headerSearchBarOptions,\n route,\n title,\n canGoBack,\n}: Props): JSX.Element {\n const insets = useSafeAreaInsets();\n\n const { colors } = useTheme();\n const tintColor =\n headerTintColor ?? (Platform.OS === 'ios' ? colors.primary : colors.text);\n\n const headerBackTitleStyleFlattened =\n StyleSheet.flatten(headerBackTitleStyle) || {};\n const headerLargeTitleStyleFlattened =\n StyleSheet.flatten(headerLargeTitleStyle) || {};\n const headerTitleStyleFlattened = StyleSheet.flatten(headerTitleStyle) || {};\n const headerStyleFlattened = StyleSheet.flatten(headerStyle) || {};\n const headerLargeStyleFlattened = StyleSheet.flatten(headerLargeStyle) || {};\n\n const [backTitleFontFamily, largeTitleFontFamily, titleFontFamily] =\n processFonts([\n headerBackTitleStyleFlattened.fontFamily,\n headerLargeTitleStyleFlattened.fontFamily,\n headerTitleStyleFlattened.fontFamily,\n ]);\n\n const titleText = getHeaderTitle({ title, headerTitle }, route.name);\n const titleColor =\n headerTitleStyleFlattened.color ?? headerTintColor ?? colors.text;\n const titleFontSize = headerTitleStyleFlattened.fontSize;\n const titleFontWeight = headerTitleStyleFlattened.fontWeight;\n\n const headerTitleStyleSupported: TextStyle = { color: titleColor };\n\n if (headerTitleStyleFlattened.fontFamily != null) {\n headerTitleStyleSupported.fontFamily = headerTitleStyleFlattened.fontFamily;\n }\n\n if (titleFontSize != null) {\n headerTitleStyleSupported.fontSize = titleFontSize;\n }\n\n if (titleFontWeight != null) {\n headerTitleStyleSupported.fontWeight = titleFontWeight;\n }\n\n const headerLeftElement = headerLeft?.({\n tintColor,\n canGoBack,\n label: headerBackTitle,\n });\n const headerRightElement = headerRight?.({\n tintColor,\n canGoBack,\n });\n const headerTitleElement =\n typeof headerTitle === 'function'\n ? headerTitle({\n tintColor,\n children: titleText,\n })\n : null;\n\n const supportsHeaderSearchBar =\n typeof isSearchBarAvailableForCurrentPlatform === 'boolean'\n ? isSearchBarAvailableForCurrentPlatform\n : // Fallback for older versions of react-native-screens\n Platform.OS === 'ios' && SearchBar != null;\n\n const hasHeaderSearchBar =\n supportsHeaderSearchBar && headerSearchBarOptions != null;\n\n if (headerSearchBarOptions != null && !supportsHeaderSearchBar) {\n throw new Error(\n `The current version of 'react-native-screens' doesn't support SearchBar in the header. Please update to the latest version to use this option.`\n );\n }\n\n /**\n * We need to set this in if:\n * - Back button should stay visible when `headerLeft` is specified\n * - If `headerTitle` for Android is specified, so we only need to remove the title and keep the back button\n */\n const backButtonInCustomView = headerBackVisible\n ? headerLeftElement != null\n : Platform.OS === 'android' && headerTitleElement != null;\n\n const translucent =\n headerBackground != null ||\n headerTransparent ||\n // When using a SearchBar or large title, the header needs to be translucent for it to work on iOS\n ((hasHeaderSearchBar || headerLargeTitle) &&\n Platform.OS === 'ios' &&\n headerTransparent !== false);\n\n return (\n <>\n {headerBackground != null ? (\n <View\n style={[\n styles.background,\n headerTransparent ? styles.translucent : null,\n { height: headerHeight },\n ]}\n >\n {headerBackground()}\n </View>\n ) : null}\n <ScreenStackHeaderConfig\n backButtonInCustomView={backButtonInCustomView}\n backgroundColor={\n headerStyleFlattened.backgroundColor ??\n (headerBackground != null || headerTransparent\n ? 'transparent'\n : colors.card)\n }\n backTitle={headerBackTitleVisible ? headerBackTitle : ' '}\n backTitleFontFamily={backTitleFontFamily}\n backTitleFontSize={headerBackTitleStyleFlattened.fontSize}\n blurEffect={headerBlurEffect}\n color={tintColor}\n direction={I18nManager.getConstants().isRTL ? 'rtl' : 'ltr'}\n disableBackButtonMenu={headerBackButtonMenuEnabled === false}\n hidden={headerShown === false}\n hideBackButton={headerBackVisible === false}\n hideShadow={\n headerShadowVisible === false ||\n headerBackground != null ||\n headerTransparent\n }\n largeTitle={headerLargeTitle}\n largeTitleBackgroundColor={headerLargeStyleFlattened.backgroundColor}\n largeTitleColor={headerLargeTitleStyleFlattened.color}\n largeTitleFontFamily={largeTitleFontFamily}\n largeTitleFontSize={headerLargeTitleStyleFlattened.fontSize}\n largeTitleFontWeight={headerLargeTitleStyleFlattened.fontWeight}\n largeTitleHideShadow={headerLargeTitleShadowVisible === false}\n title={titleText}\n titleColor={titleColor}\n titleFontFamily={titleFontFamily}\n titleFontSize={titleFontSize}\n titleFontWeight={titleFontWeight}\n topInsetEnabled={insets.top !== 0}\n translucent={\n // This defaults to `true`, so we can't pass `undefined`\n translucent === true\n }\n >\n {Platform.OS === 'ios' ? (\n <>\n {headerLeftElement != null ? (\n <ScreenStackHeaderLeftView>\n {headerLeftElement}\n </ScreenStackHeaderLeftView>\n ) : null}\n {headerTitleElement != null ? (\n <ScreenStackHeaderCenterView>\n {headerTitleElement}\n </ScreenStackHeaderCenterView>\n ) : null}\n </>\n ) : (\n <>\n {headerLeftElement != null || typeof headerTitle === 'function' ? (\n <ScreenStackHeaderLeftView>\n <View style={styles.row}>\n {headerLeftElement}\n {headerTitleAlign !== 'center' ? (\n typeof headerTitle === 'function' ? (\n headerTitleElement\n ) : (\n <HeaderTitle\n tintColor={tintColor}\n style={headerTitleStyleSupported}\n >\n {titleText}\n </HeaderTitle>\n )\n ) : null}\n </View>\n </ScreenStackHeaderLeftView>\n ) : null}\n {headerTitleAlign === 'center' ? (\n <ScreenStackHeaderCenterView>\n {typeof headerTitle === 'function' ? (\n headerTitleElement\n ) : (\n <HeaderTitle\n tintColor={tintColor}\n style={headerTitleStyleSupported}\n >\n {titleText}\n </HeaderTitle>\n )}\n </ScreenStackHeaderCenterView>\n ) : null}\n </>\n )}\n {headerBackImageSource !== undefined ? (\n <ScreenStackHeaderBackButtonImage source={headerBackImageSource} />\n ) : null}\n {headerRightElement != null ? (\n <ScreenStackHeaderRightView>\n {headerRightElement}\n </ScreenStackHeaderRightView>\n ) : null}\n {hasHeaderSearchBar ? (\n <ScreenStackHeaderSearchBarView>\n <SearchBar {...headerSearchBarOptions} />\n </ScreenStackHeaderSearchBarView>\n ) : null}\n </ScreenStackHeaderConfig>\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n translucent: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n zIndex: 1,\n },\n background: {\n overflow: 'hidden',\n },\n});\n"]}
|
|
@@ -22,22 +22,26 @@ function NativeStackView(_ref) {
|
|
|
22
22
|
state,
|
|
23
23
|
descriptors
|
|
24
24
|
} = _ref;
|
|
25
|
+
const parentHeaderBack = React.useContext(_elements.HeaderBackContext);
|
|
25
26
|
return /*#__PURE__*/React.createElement(_elements.SafeAreaProviderCompat, null, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
26
27
|
style: styles.container
|
|
27
28
|
}, state.routes.map((route, i) => {
|
|
28
29
|
var _state$routes, _state$routes2;
|
|
29
30
|
|
|
30
31
|
const isFocused = state.index === i;
|
|
31
|
-
const canGoBack = i !== 0;
|
|
32
32
|
const previousKey = (_state$routes = state.routes[i - 1]) === null || _state$routes === void 0 ? void 0 : _state$routes.key;
|
|
33
33
|
const nextKey = (_state$routes2 = state.routes[i + 1]) === null || _state$routes2 === void 0 ? void 0 : _state$routes2.key;
|
|
34
34
|
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
35
|
-
const
|
|
35
|
+
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
36
36
|
const {
|
|
37
37
|
options,
|
|
38
38
|
navigation,
|
|
39
39
|
render
|
|
40
40
|
} = descriptors[route.key];
|
|
41
|
+
const headerBack = previousDescriptor ? {
|
|
42
|
+
title: (0, _elements.getHeaderTitle)(previousDescriptor.options, previousDescriptor.route.name)
|
|
43
|
+
} : parentHeaderBack;
|
|
44
|
+
const canGoBack = headerBack !== undefined;
|
|
41
45
|
const {
|
|
42
46
|
header,
|
|
43
47
|
headerShown,
|
|
@@ -51,11 +55,12 @@ function NativeStackView(_ref) {
|
|
|
51
55
|
headerStyle,
|
|
52
56
|
headerShadowVisible,
|
|
53
57
|
headerTransparent,
|
|
58
|
+
headerBackground,
|
|
54
59
|
headerBackTitle,
|
|
55
60
|
presentation,
|
|
56
61
|
contentStyle
|
|
57
62
|
} = options;
|
|
58
|
-
const nextPresentation =
|
|
63
|
+
const nextPresentation = nextDescriptor === null || nextDescriptor === void 0 ? void 0 : nextDescriptor.options.presentation;
|
|
59
64
|
return /*#__PURE__*/React.createElement(_elements.Screen, {
|
|
60
65
|
key: route.key,
|
|
61
66
|
focused: isFocused,
|
|
@@ -64,9 +69,7 @@ function NativeStackView(_ref) {
|
|
|
64
69
|
headerShown: headerShown,
|
|
65
70
|
headerTransparent: headerTransparent,
|
|
66
71
|
header: header !== undefined ? header({
|
|
67
|
-
back:
|
|
68
|
-
title: (0, _elements.getHeaderTitle)(previousDescriptor.options, previousDescriptor.route.name)
|
|
69
|
-
} : undefined,
|
|
72
|
+
back: headerBack,
|
|
70
73
|
options,
|
|
71
74
|
route,
|
|
72
75
|
navigation
|
|
@@ -119,22 +122,21 @@ function NativeStackView(_ref) {
|
|
|
119
122
|
} : headerTitle,
|
|
120
123
|
headerTitleAlign: headerTitleAlign,
|
|
121
124
|
headerTitleStyle: headerTitleStyle,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
shadowOpacity: 0,
|
|
127
|
-
borderBottomWidth: 0
|
|
128
|
-
} : null]
|
|
125
|
+
headerTransparent: headerTransparent,
|
|
126
|
+
headerShadowVisible: headerShadowVisible,
|
|
127
|
+
headerBackground: headerBackground,
|
|
128
|
+
headerStyle: headerStyle
|
|
129
129
|
}),
|
|
130
130
|
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
131
131
|
display: isFocused || nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation) ? 'flex' : 'none'
|
|
132
132
|
}, presentation != null && TRANSPARENT_PRESENTATIONS.includes(presentation) ? {
|
|
133
133
|
backgroundColor: 'transparent'
|
|
134
134
|
} : null]
|
|
135
|
+
}, /*#__PURE__*/React.createElement(_elements.HeaderBackContext.Provider, {
|
|
136
|
+
value: headerBack
|
|
135
137
|
}, /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
136
138
|
style: [styles.contentContainer, contentStyle]
|
|
137
|
-
}, render()));
|
|
139
|
+
}, render())));
|
|
138
140
|
})));
|
|
139
141
|
}
|
|
140
142
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeStackView.tsx"],"names":["TRANSPARENT_PRESENTATIONS","NativeStackView","state","descriptors","styles","container","routes","map","route","i","isFocused","index","canGoBack","previousKey","key","nextKey","previousDescriptor","undefined","nexDescriptor","options","navigation","render","header","headerShown","headerTintColor","headerBackImageSource","headerLeft","headerRight","headerTitle","headerTitleAlign","headerTitleStyle","headerStyle","headerShadowVisible","headerTransparent","headerBackTitle","presentation","contentStyle","nextPresentation","back","title","name","tintColor","label","backImage","goBack","children","position","backgroundColor","shadowOpacity","borderBottomWidth","StyleSheet","absoluteFill","display","includes","contentContainer","create","flex","height","width","margin","resizeMode"],"mappings":";;;;;;;AAAA;;AAWA;;AACA;;;;;;AAeA,MAAMA,yBAAyB,GAAG,CAChC,kBADgC,EAEhC,2BAFgC,CAAlC;;AAKe,SAASC,eAAT,OAAwD;AAAA,MAA/B;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAA+B;AACrE,sBACE,oBAAC,gCAAD,qBACE,oBAAC,iBAAD;AAAM,IAAA,KAAK,EAAEC,MAAM,CAACC;AAApB,KACGH,KAAK,CAACI,MAAN,CAAaC,GAAb,CAAiB,CAACC,KAAD,EAAQC,CAAR,KAAc;AAAA;;AAC9B,UAAMC,S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mD,IAAAA,IAAI,EAAE;AADG,GADoB;AAI/BF,EAAAA,gBAAgB,EAAE;AAChBE,IAAAA,IAAI,EAAE;AADU,GAJa;AAO/Bb,EAAAA,SAAS,EAAE;AACTc,IAAAA,MAAM,EAAE,EADC;AAETC,IAAAA,KAAK,EAAE,EAFE;AAGTC,IAAAA,MAAM,EAAE,CAHC;AAITC,IAAAA,UAAU,EAAE;AAJH;AAPoB,CAAlB,CAAf","sourcesContent":["import {\n getHeaderTitle,\n Header,\n HeaderBackButton,\n SafeAreaProviderCompat,\n Screen,\n} from '@react-navigation/elements';\nimport type {\n ParamListBase,\n StackNavigationState,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Image, StyleSheet, View } from 'react-native';\n\nimport type {\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n} from '../types';\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n // This is used for the native implementation of the stack.\n // eslint-disable-next-line react/no-unused-prop-types\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nconst TRANSPARENT_PRESENTATIONS = [\n 'transparentModal',\n 'containedTransparentModal',\n];\n\nexport default function NativeStackView({ state, descriptors }: Props) {\n return (\n <SafeAreaProviderCompat>\n <View style={styles.container}>\n {state.routes.map((route, i) => {\n const isFocused = state.index === i;\n const canGoBack = i !== 0;\n const previousKey = state.routes[i - 1]?.key;\n const nextKey = state.routes[i + 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n const nexDescriptor = nextKey ? descriptors[nextKey] : undefined;\n const { options, navigation, render } = descriptors[route.key];\n\n const {\n header,\n headerShown,\n headerTintColor,\n headerBackImageSource,\n headerLeft,\n headerRight,\n headerTitle,\n headerTitleAlign,\n headerTitleStyle,\n headerStyle,\n headerShadowVisible,\n headerTransparent,\n headerBackTitle,\n presentation,\n contentStyle,\n } = options;\n\n const nextPresentation = nexDescriptor?.options.presentation;\n\n return (\n <Screen\n key={route.key}\n focused={isFocused}\n route={route}\n navigation={navigation}\n headerShown={headerShown}\n headerTransparent={headerTransparent}\n header={\n header !== undefined ? (\n header({\n back: previousDescriptor\n ? {\n title: getHeaderTitle(\n previousDescriptor.options,\n previousDescriptor.route.name\n ),\n }\n : undefined,\n options,\n route,\n navigation,\n })\n ) : (\n <Header\n title={getHeaderTitle(options, route.name)}\n headerTintColor={headerTintColor}\n headerLeft={\n typeof headerLeft === 'function'\n ? ({ tintColor }) =>\n headerLeft({\n tintColor,\n canGoBack,\n label: headerBackTitle,\n })\n : headerLeft === undefined && canGoBack\n ? ({ tintColor }) => (\n <HeaderBackButton\n tintColor={tintColor}\n backImage={\n headerBackImageSource !== undefined\n ? () => (\n <Image\n source={headerBackImageSource}\n style={[\n styles.backImage,\n { tintColor },\n ]}\n />\n )\n : undefined\n }\n onPress={navigation.goBack}\n canGoBack={canGoBack}\n />\n )\n : headerLeft\n }\n headerRight={\n typeof headerRight === 'function'\n ? ({ tintColor }) =>\n headerRight({ tintColor, canGoBack })\n : headerRight\n }\n headerTitle={\n typeof headerTitle === 'function'\n ? ({ children, tintColor }) =>\n headerTitle({ children, tintColor })\n : headerTitle\n }\n headerTitleAlign={headerTitleAlign}\n headerTitleStyle={headerTitleStyle}\n headerStyle={[\n headerTransparent\n ? {\n position: 'absolute',\n backgroundColor: 'transparent',\n }\n : null,\n headerStyle,\n headerShadowVisible === false\n ? { shadowOpacity: 0, borderBottomWidth: 0 }\n : null,\n ]}\n />\n )\n }\n style={[\n StyleSheet.absoluteFill,\n {\n display:\n isFocused ||\n (nextPresentation != null &&\n TRANSPARENT_PRESENTATIONS.includes(nextPresentation))\n ? 'flex'\n : 'none',\n },\n presentation != null &&\n TRANSPARENT_PRESENTATIONS.includes(presentation)\n ? { backgroundColor: 'transparent' }\n : null,\n ]}\n >\n <View style={[styles.contentContainer, contentStyle]}>\n {render()}\n </View>\n </Screen>\n );\n })}\n </View>\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n contentContainer: {\n flex: 1,\n },\n backImage: {\n height: 24,\n width: 24,\n margin: 3,\n resizeMode: 'contain',\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["NativeStackView.tsx"],"names":["TRANSPARENT_PRESENTATIONS","NativeStackView","state","descriptors","parentHeaderBack","React","useContext","HeaderBackContext","styles","container","routes","map","route","i","isFocused","index","previousKey","key","nextKey","previousDescriptor","undefined","nextDescriptor","options","navigation","render","headerBack","title","name","canGoBack","header","headerShown","headerTintColor","headerBackImageSource","headerLeft","headerRight","headerTitle","headerTitleAlign","headerTitleStyle","headerStyle","headerShadowVisible","headerTransparent","headerBackground","headerBackTitle","presentation","contentStyle","nextPresentation","back","tintColor","label","backImage","goBack","children","StyleSheet","absoluteFill","display","includes","backgroundColor","contentContainer","create","flex","height","width","margin","resizeMode"],"mappings":";;;;;;;AAAA;;AAYA;;AACA;;;;;;AAeA,MAAMA,yBAAyB,GAAG,CAChC,kBADgC,EAEhC,2BAFgC,CAAlC;;AAKe,SAASC,eAAT,OAAwD;AAAA,MAA/B;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAA+B;AACrE,QAAMC,gBAAgB,GAAGC,KAAK,CAACC,UAAN,CAAiBC,2BAAjB,CAAzB;AAEA,sBACE,oBAAC,gCAAD,qBACE,oBAAC,iBAAD;AAAM,IAAA,KAAK,EAAEC,MAAM,CAACC;AAApB,KACGP,KAAK,CAACQ,MAAN,CAAaC,GAAb,CAAiB,CAACC,KAAD,EAAQC,CAAR,KAAc;AAAA;;AAC9B,UAAMC,SAAS,GAAGZ,KAAK,CAACa,KAAN,KAAgBF,CAAlC;AACA,UAAMG,WAAW,oBAAGd,KAAK,CAACQ,MAAN,CAAaG,CAAC,GAAG,CAAjB,CAAH,kDAAG,cAAqBI,GAAzC;AACA,UAAMC,OAAO,qBAAGhB,KAAK,CAACQ,MAAN,CAAaG,CAAC,GAAG,CAAjB,CAAH,mDAAG,eAAqBI,GAArC;AACA,UA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AE;AAJH;AAPoB,CAAlB,CAAf","sourcesContent":["import {\n getHeaderTitle,\n Header,\n HeaderBackButton,\n HeaderBackContext,\n SafeAreaProviderCompat,\n Screen,\n} from '@react-navigation/elements';\nimport type {\n ParamListBase,\n StackNavigationState,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Image, StyleSheet, View } from 'react-native';\n\nimport type {\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n} from '../types';\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n // This is used for the native implementation of the stack.\n // eslint-disable-next-line react/no-unused-prop-types\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nconst TRANSPARENT_PRESENTATIONS = [\n 'transparentModal',\n 'containedTransparentModal',\n];\n\nexport default function NativeStackView({ state, descriptors }: Props) {\n const parentHeaderBack = React.useContext(HeaderBackContext);\n\n return (\n <SafeAreaProviderCompat>\n <View style={styles.container}>\n {state.routes.map((route, i) => {\n const isFocused = state.index === i;\n const previousKey = state.routes[i - 1]?.key;\n const nextKey = state.routes[i + 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;\n const { options, navigation, render } = descriptors[route.key];\n\n const headerBack = previousDescriptor\n ? {\n title: getHeaderTitle(\n previousDescriptor.options,\n previousDescriptor.route.name\n ),\n }\n : parentHeaderBack;\n\n const canGoBack = headerBack !== undefined;\n\n const {\n header,\n headerShown,\n headerTintColor,\n headerBackImageSource,\n headerLeft,\n headerRight,\n headerTitle,\n headerTitleAlign,\n headerTitleStyle,\n headerStyle,\n headerShadowVisible,\n headerTransparent,\n headerBackground,\n headerBackTitle,\n presentation,\n contentStyle,\n } = options;\n\n const nextPresentation = nextDescriptor?.options.presentation;\n\n return (\n <Screen\n key={route.key}\n focused={isFocused}\n route={route}\n navigation={navigation}\n headerShown={headerShown}\n headerTransparent={headerTransparent}\n header={\n header !== undefined ? (\n header({\n back: headerBack,\n options,\n route,\n navigation,\n })\n ) : (\n <Header\n title={getHeaderTitle(options, route.name)}\n headerTintColor={headerTintColor}\n headerLeft={\n typeof headerLeft === 'function'\n ? ({ tintColor }) =>\n headerLeft({\n tintColor,\n canGoBack,\n label: headerBackTitle,\n })\n : headerLeft === undefined && canGoBack\n ? ({ tintColor }) => (\n <HeaderBackButton\n tintColor={tintColor}\n backImage={\n headerBackImageSource !== undefined\n ? () => (\n <Image\n source={headerBackImageSource}\n style={[\n styles.backImage,\n { tintColor },\n ]}\n />\n )\n : undefined\n }\n onPress={navigation.goBack}\n canGoBack={canGoBack}\n />\n )\n : headerLeft\n }\n headerRight={\n typeof headerRight === 'function'\n ? ({ tintColor }) =>\n headerRight({ tintColor, canGoBack })\n : headerRight\n }\n headerTitle={\n typeof headerTitle === 'function'\n ? ({ children, tintColor }) =>\n headerTitle({ children, tintColor })\n : headerTitle\n }\n headerTitleAlign={headerTitleAlign}\n headerTitleStyle={headerTitleStyle}\n headerTransparent={headerTransparent}\n headerShadowVisible={headerShadowVisible}\n headerBackground={headerBackground}\n headerStyle={headerStyle}\n />\n )\n }\n style={[\n StyleSheet.absoluteFill,\n {\n display:\n isFocused ||\n (nextPresentation != null &&\n TRANSPARENT_PRESENTATIONS.includes(nextPresentation))\n ? 'flex'\n : 'none',\n },\n presentation != null &&\n TRANSPARENT_PRESENTATIONS.includes(presentation)\n ? { backgroundColor: 'transparent' }\n : null,\n ]}\n >\n <HeaderBackContext.Provider value={headerBack}>\n <View style={[styles.contentContainer, contentStyle]}>\n {render()}\n </View>\n </HeaderBackContext.Provider>\n </Screen>\n );\n })}\n </View>\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n contentContainer: {\n flex: 1,\n },\n backImage: {\n height: 24,\n width: 24,\n margin: 3,\n resizeMode: 'contain',\n },\n});\n"]}
|
|
@@ -19,6 +19,10 @@ var _reactNativeScreens = require("react-native-screens");
|
|
|
19
19
|
|
|
20
20
|
var _warnOnce = _interopRequireDefault(require("warn-once"));
|
|
21
21
|
|
|
22
|
+
var _useDismissedRouteError = _interopRequireDefault(require("../utils/useDismissedRouteError"));
|
|
23
|
+
|
|
24
|
+
var _useInvalidPreventRemoveError = _interopRequireDefault(require("../utils/useInvalidPreventRemoveError"));
|
|
25
|
+
|
|
22
26
|
var _DebugContainer = _interopRequireDefault(require("./DebugContainer"));
|
|
23
27
|
|
|
24
28
|
var _HeaderConfig = _interopRequireDefault(require("./HeaderConfig"));
|
|
@@ -79,14 +83,19 @@ const MaybeNestedStack = _ref => {
|
|
|
79
83
|
};
|
|
80
84
|
|
|
81
85
|
const SceneView = _ref2 => {
|
|
86
|
+
var _preventedRoutes$rout;
|
|
87
|
+
|
|
82
88
|
let {
|
|
83
89
|
descriptor,
|
|
84
90
|
previousDescriptor,
|
|
91
|
+
nextDescriptor,
|
|
85
92
|
index,
|
|
86
93
|
onWillDisappear,
|
|
87
94
|
onAppear,
|
|
88
95
|
onDisappear,
|
|
89
|
-
onDismissed
|
|
96
|
+
onDismissed,
|
|
97
|
+
onHeaderBackButtonClicked,
|
|
98
|
+
onNativeDismissCancelled
|
|
90
99
|
} = _ref2;
|
|
91
100
|
const {
|
|
92
101
|
route,
|
|
@@ -95,22 +104,54 @@ const SceneView = _ref2 => {
|
|
|
95
104
|
render
|
|
96
105
|
} = descriptor;
|
|
97
106
|
const {
|
|
98
|
-
|
|
107
|
+
animationDuration,
|
|
99
108
|
animationTypeForReplace = 'push',
|
|
100
|
-
customAnimationOnGesture,
|
|
101
|
-
fullScreenGestureEnabled,
|
|
102
109
|
gestureEnabled,
|
|
103
110
|
header,
|
|
111
|
+
headerBackButtonMenuEnabled,
|
|
104
112
|
headerShown,
|
|
113
|
+
autoHideHomeIndicator,
|
|
114
|
+
navigationBarColor,
|
|
115
|
+
navigationBarHidden,
|
|
105
116
|
orientation,
|
|
106
117
|
statusBarAnimation,
|
|
107
118
|
statusBarHidden,
|
|
108
|
-
statusBarStyle
|
|
119
|
+
statusBarStyle,
|
|
120
|
+
statusBarTranslucent,
|
|
121
|
+
statusBarColor
|
|
109
122
|
} = options;
|
|
110
123
|
let {
|
|
111
|
-
|
|
124
|
+
animation,
|
|
125
|
+
customAnimationOnGesture,
|
|
126
|
+
fullScreenGestureEnabled,
|
|
127
|
+
presentation = 'card',
|
|
128
|
+
gestureDirection = presentation === 'card' ? 'horizontal' : 'vertical'
|
|
112
129
|
} = options;
|
|
113
130
|
|
|
131
|
+
if (gestureDirection === 'vertical' && _reactNative.Platform.OS === 'ios') {
|
|
132
|
+
// for `vertical` direction to work, we need to set `fullScreenGestureEnabled` to `true`
|
|
133
|
+
// so the screen can be dismissed from any point on screen.
|
|
134
|
+
// `customAnimationOnGesture` needs to be set to `true` so the `animation` set by user can be used,
|
|
135
|
+
// otherwise `simple_push` will be used.
|
|
136
|
+
// Also, the default animation for this direction seems to be `slide_from_bottom`.
|
|
137
|
+
if (fullScreenGestureEnabled === undefined) {
|
|
138
|
+
fullScreenGestureEnabled = true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (customAnimationOnGesture === undefined) {
|
|
142
|
+
customAnimationOnGesture = true;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (animation === undefined) {
|
|
146
|
+
animation = 'slide_from_bottom';
|
|
147
|
+
}
|
|
148
|
+
} // workaround for rn-screens where gestureDirection has to be set on both
|
|
149
|
+
// current and previous screen - software-mansion/react-native-screens/pull/1509
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
const nextGestureDirection = nextDescriptor === null || nextDescriptor === void 0 ? void 0 : nextDescriptor.options.gestureDirection;
|
|
153
|
+
const gestureDirectionOverride = nextGestureDirection != null ? nextGestureDirection : gestureDirection;
|
|
154
|
+
|
|
114
155
|
if (index === 0) {
|
|
115
156
|
// first screen should always be treated as `card`, it resolves problems with no header animation
|
|
116
157
|
// for navigator with first screen as `modal` and the next as `card`
|
|
@@ -123,14 +164,22 @@ const SceneView = _ref2 => {
|
|
|
123
164
|
|
|
124
165
|
const isModal = presentation === 'modal' || presentation === 'formSheet'; // Modals are fullscreen in landscape only on iPhone
|
|
125
166
|
|
|
126
|
-
const isIPhone = _reactNative.Platform.OS === 'ios' && !(_reactNative.Platform.isPad
|
|
167
|
+
const isIPhone = _reactNative.Platform.OS === 'ios' && !(_reactNative.Platform.isPad || _reactNative.Platform.isTVOS);
|
|
127
168
|
const isLandscape = frame.width > frame.height;
|
|
128
169
|
const topInset = isModal || isIPhone && isLandscape ? 0 : insets.top;
|
|
129
170
|
const isParentHeaderShown = React.useContext(_elements.HeaderShownContext);
|
|
130
171
|
const parentHeaderHeight = React.useContext(_elements.HeaderHeightContext);
|
|
172
|
+
const parentHeaderBack = React.useContext(_elements.HeaderBackContext);
|
|
173
|
+
const {
|
|
174
|
+
preventedRoutes
|
|
175
|
+
} = (0, _native.usePreventRemoveContext)();
|
|
131
176
|
const defaultHeaderHeight = (0, _elements.getDefaultHeaderHeight)(frame, isModal, topInset);
|
|
132
177
|
const [customHeaderHeight, setCustomHeaderHeight] = React.useState(defaultHeaderHeight);
|
|
133
178
|
const headerHeight = header ? customHeaderHeight : defaultHeaderHeight;
|
|
179
|
+
const headerBack = previousDescriptor ? {
|
|
180
|
+
title: (0, _elements.getHeaderTitle)(previousDescriptor.options, previousDescriptor.route.name)
|
|
181
|
+
} : parentHeaderBack;
|
|
182
|
+
const isRemovePrevented = (_preventedRoutes$rout = preventedRoutes[route.key]) === null || _preventedRoutes$rout === void 0 ? void 0 : _preventedRoutes$rout.preventRemove;
|
|
134
183
|
return /*#__PURE__*/React.createElement(_reactNativeScreens.Screen, {
|
|
135
184
|
key: route.key,
|
|
136
185
|
enabled: true,
|
|
@@ -140,6 +189,9 @@ const SceneView = _ref2 => {
|
|
|
140
189
|
gestureEnabled: isAndroid ? // This prop enables handling of system back gestures on Android
|
|
141
190
|
// Since we handle them in JS side, we disable this
|
|
142
191
|
false : gestureEnabled,
|
|
192
|
+
homeIndicatorHidden: autoHideHomeIndicator,
|
|
193
|
+
navigationBarColor: navigationBarColor,
|
|
194
|
+
navigationBarHidden: navigationBarHidden,
|
|
143
195
|
replaceAnimation: animationTypeForReplace,
|
|
144
196
|
stackPresentation: presentation === 'card' ? 'push' : presentation,
|
|
145
197
|
stackAnimation: animation,
|
|
@@ -147,11 +199,23 @@ const SceneView = _ref2 => {
|
|
|
147
199
|
statusBarAnimation: statusBarAnimation,
|
|
148
200
|
statusBarHidden: statusBarHidden,
|
|
149
201
|
statusBarStyle: statusBarStyle,
|
|
202
|
+
statusBarColor: statusBarColor,
|
|
203
|
+
statusBarTranslucent: statusBarTranslucent,
|
|
204
|
+
swipeDirection: gestureDirectionOverride,
|
|
205
|
+
transitionDuration: animationDuration,
|
|
150
206
|
onWillDisappear: onWillDisappear,
|
|
151
207
|
onAppear: onAppear,
|
|
152
208
|
onDisappear: onDisappear,
|
|
153
209
|
onDismissed: onDismissed,
|
|
154
|
-
isNativeStack: true
|
|
210
|
+
isNativeStack: true // Props for enabling preventing removal in native-stack
|
|
211
|
+
,
|
|
212
|
+
nativeBackButtonDismissalEnabled: false // on Android
|
|
213
|
+
// @ts-expect-error prop not publicly exported from rn-screens
|
|
214
|
+
,
|
|
215
|
+
preventNativeDismiss: isRemovePrevented // on iOS
|
|
216
|
+
,
|
|
217
|
+
onHeaderBackButtonClicked: onHeaderBackButtonClicked,
|
|
218
|
+
onNativeDismissCancelled: onNativeDismissCancelled
|
|
155
219
|
}, /*#__PURE__*/React.createElement(_native.NavigationContext.Provider, {
|
|
156
220
|
value: navigation
|
|
157
221
|
}, /*#__PURE__*/React.createElement(_native.NavigationRouteContext.Provider, {
|
|
@@ -165,54 +229,53 @@ const SceneView = _ref2 => {
|
|
|
165
229
|
setCustomHeaderHeight(e.nativeEvent.layout.height);
|
|
166
230
|
}
|
|
167
231
|
}, header({
|
|
168
|
-
back:
|
|
169
|
-
title: (0, _elements.getHeaderTitle)(previousDescriptor.options, previousDescriptor.route.name)
|
|
170
|
-
} : undefined,
|
|
232
|
+
back: headerBack,
|
|
171
233
|
options,
|
|
172
234
|
route,
|
|
173
235
|
navigation
|
|
174
236
|
})) : /*#__PURE__*/React.createElement(_HeaderConfig.default, _extends({}, options, {
|
|
175
237
|
route: route,
|
|
238
|
+
headerBackButtonMenuEnabled: isRemovePrevented !== undefined ? !isRemovePrevented : headerBackButtonMenuEnabled,
|
|
176
239
|
headerShown: isHeaderInPush,
|
|
177
240
|
headerHeight: headerHeight,
|
|
178
|
-
|
|
241
|
+
headerBackTitle: options.headerBackTitle !== undefined ? options.headerBackTitle : headerBack === null || headerBack === void 0 ? void 0 : headerBack.title,
|
|
242
|
+
canGoBack: headerBack !== undefined
|
|
179
243
|
})), /*#__PURE__*/React.createElement(MaybeNestedStack, {
|
|
180
244
|
options: options,
|
|
181
245
|
route: route,
|
|
182
246
|
presentation: presentation,
|
|
183
247
|
headerHeight: headerHeight
|
|
184
|
-
},
|
|
248
|
+
}, /*#__PURE__*/React.createElement(_elements.HeaderBackContext.Provider, {
|
|
249
|
+
value: headerBack
|
|
250
|
+
}, render())))))));
|
|
185
251
|
};
|
|
186
252
|
|
|
187
253
|
function NativeStackViewInner(_ref3) {
|
|
188
|
-
var _state$routes$find;
|
|
189
|
-
|
|
190
254
|
let {
|
|
191
255
|
state,
|
|
192
256
|
navigation,
|
|
193
257
|
descriptors
|
|
194
258
|
} = _ref3;
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const message = `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` + `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\n\n` + `Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;
|
|
200
|
-
console.error(message);
|
|
201
|
-
}
|
|
202
|
-
}, [dismissedRouteName]);
|
|
259
|
+
const {
|
|
260
|
+
setNextDismissedKey
|
|
261
|
+
} = (0, _useDismissedRouteError.default)(state);
|
|
262
|
+
(0, _useInvalidPreventRemoveError.default)(descriptors);
|
|
203
263
|
return /*#__PURE__*/React.createElement(_reactNativeScreens.ScreenStack, {
|
|
204
264
|
style: styles.container
|
|
205
265
|
}, state.routes.map((route, index) => {
|
|
206
|
-
var _state$routes;
|
|
266
|
+
var _state$routes, _state$routes2;
|
|
207
267
|
|
|
208
268
|
const descriptor = descriptors[route.key];
|
|
209
269
|
const previousKey = (_state$routes = state.routes[index - 1]) === null || _state$routes === void 0 ? void 0 : _state$routes.key;
|
|
270
|
+
const nextKey = (_state$routes2 = state.routes[index + 1]) === null || _state$routes2 === void 0 ? void 0 : _state$routes2.key;
|
|
210
271
|
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
272
|
+
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
211
273
|
return /*#__PURE__*/React.createElement(SceneView, {
|
|
212
274
|
key: route.key,
|
|
213
275
|
index: index,
|
|
214
276
|
descriptor: descriptor,
|
|
215
277
|
previousDescriptor: previousDescriptor,
|
|
278
|
+
nextDescriptor: nextDescriptor,
|
|
216
279
|
onWillDisappear: () => {
|
|
217
280
|
navigation.emit({
|
|
218
281
|
type: 'transitionStart',
|
|
@@ -246,6 +309,18 @@ function NativeStackViewInner(_ref3) {
|
|
|
246
309
|
target: state.key
|
|
247
310
|
});
|
|
248
311
|
setNextDismissedKey(route.key);
|
|
312
|
+
},
|
|
313
|
+
onHeaderBackButtonClicked: () => {
|
|
314
|
+
navigation.dispatch({ ..._native.StackActions.pop(),
|
|
315
|
+
source: route.key,
|
|
316
|
+
target: state.key
|
|
317
|
+
});
|
|
318
|
+
},
|
|
319
|
+
onNativeDismissCancelled: event => {
|
|
320
|
+
navigation.dispatch({ ..._native.StackActions.pop(event.nativeEvent.dismissCount),
|
|
321
|
+
source: route.key,
|
|
322
|
+
target: state.key
|
|
323
|
+
});
|
|
249
324
|
}
|
|
250
325
|
});
|
|
251
326
|
}));
|