@react-navigation/native-stack 6.2.5 → 6.5.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/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/navigators/createNativeStackNavigator.js +12 -10
- package/lib/commonjs/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/views/HeaderConfig.js +62 -39
- package/lib/commonjs/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.js +62 -40
- package/lib/commonjs/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.native.js +57 -41
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createNativeStackNavigator.js +12 -10
- package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/views/HeaderConfig.js +62 -39
- package/lib/module/views/HeaderConfig.js.map +1 -1
- package/lib/module/views/NativeStackView.js +61 -40
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +59 -43
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -1
- package/lib/typescript/src/types.d.ts +40 -11
- package/lib/typescript/src/views/HeaderConfig.d.ts +2 -1
- package/package.json +6 -6
- package/src/index.tsx +6 -0
- package/src/navigators/createNativeStackNavigator.tsx +21 -18
- package/src/types.tsx +41 -9
- package/src/views/HeaderConfig.tsx +153 -103
- package/src/views/NativeStackView.native.tsx +65 -47
- package/src/views/NativeStackView.tsx +25 -3
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { getHeaderTitle, Header, HeaderBackButton, SafeAreaProviderCompat, Screen } from '@react-navigation/elements';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Image, StyleSheet, View } from 'react-native';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const TRANSPARENT_PRESENTATIONS = ['transparentModal', 'containedTransparentModal'];
|
|
5
|
+
export default function NativeStackView(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
state,
|
|
8
|
+
descriptors
|
|
9
|
+
} = _ref;
|
|
8
10
|
return /*#__PURE__*/React.createElement(SafeAreaProviderCompat, null, /*#__PURE__*/React.createElement(View, {
|
|
9
11
|
style: styles.container
|
|
10
12
|
}, state.routes.map((route, i) => {
|
|
11
|
-
var _state$routes;
|
|
13
|
+
var _state$routes, _state$routes2;
|
|
12
14
|
|
|
13
15
|
const isFocused = state.index === i;
|
|
14
16
|
const canGoBack = i !== 0;
|
|
15
17
|
const previousKey = (_state$routes = state.routes[i - 1]) === null || _state$routes === void 0 ? void 0 : _state$routes.key;
|
|
18
|
+
const nextKey = (_state$routes2 = state.routes[i + 1]) === null || _state$routes2 === void 0 ? void 0 : _state$routes2.key;
|
|
16
19
|
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
20
|
+
const nexDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
17
21
|
const {
|
|
18
22
|
options,
|
|
19
23
|
navigation,
|
|
@@ -32,9 +36,11 @@ export default function NativeStackView({
|
|
|
32
36
|
headerStyle,
|
|
33
37
|
headerShadowVisible,
|
|
34
38
|
headerTransparent,
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
headerBackTitle,
|
|
40
|
+
presentation,
|
|
41
|
+
contentStyle
|
|
37
42
|
} = options;
|
|
43
|
+
const nextPresentation = nexDescriptor === null || nexDescriptor === void 0 ? void 0 : nexDescriptor.options.presentation;
|
|
38
44
|
return /*#__PURE__*/React.createElement(Screen, {
|
|
39
45
|
key: route.key,
|
|
40
46
|
focused: isFocused,
|
|
@@ -52,37 +58,50 @@ export default function NativeStackView({
|
|
|
52
58
|
}) : /*#__PURE__*/React.createElement(Header, {
|
|
53
59
|
title: getHeaderTitle(options, route.name),
|
|
54
60
|
headerTintColor: headerTintColor,
|
|
55
|
-
headerLeft: typeof headerLeft === 'function' ?
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
61
|
+
headerLeft: typeof headerLeft === 'function' ? _ref2 => {
|
|
62
|
+
let {
|
|
63
|
+
tintColor
|
|
64
|
+
} = _ref2;
|
|
65
|
+
return headerLeft({
|
|
66
|
+
tintColor,
|
|
67
|
+
canGoBack,
|
|
68
|
+
label: headerBackTitle
|
|
69
|
+
});
|
|
70
|
+
} : headerLeft === undefined && canGoBack ? _ref3 => {
|
|
71
|
+
let {
|
|
72
|
+
tintColor
|
|
73
|
+
} = _ref3;
|
|
74
|
+
return /*#__PURE__*/React.createElement(HeaderBackButton, {
|
|
75
|
+
tintColor: tintColor,
|
|
76
|
+
backImage: headerBackImageSource !== undefined ? () => /*#__PURE__*/React.createElement(Image, {
|
|
77
|
+
source: headerBackImageSource,
|
|
78
|
+
style: [styles.backImage, {
|
|
79
|
+
tintColor
|
|
80
|
+
}]
|
|
81
|
+
}) : undefined,
|
|
82
|
+
onPress: navigation.goBack,
|
|
83
|
+
canGoBack: canGoBack
|
|
84
|
+
});
|
|
85
|
+
} : headerLeft,
|
|
86
|
+
headerRight: typeof headerRight === 'function' ? _ref4 => {
|
|
87
|
+
let {
|
|
88
|
+
tintColor
|
|
89
|
+
} = _ref4;
|
|
90
|
+
return headerRight({
|
|
91
|
+
tintColor,
|
|
92
|
+
canGoBack
|
|
93
|
+
});
|
|
94
|
+
} : headerRight,
|
|
95
|
+
headerTitle: typeof headerTitle === 'function' ? _ref5 => {
|
|
96
|
+
let {
|
|
97
|
+
children,
|
|
98
|
+
tintColor
|
|
99
|
+
} = _ref5;
|
|
100
|
+
return headerTitle({
|
|
101
|
+
children,
|
|
102
|
+
tintColor
|
|
103
|
+
});
|
|
104
|
+
} : headerTitle,
|
|
86
105
|
headerTitleAlign: headerTitleAlign,
|
|
87
106
|
headerTitleStyle: headerTitleStyle,
|
|
88
107
|
headerStyle: [headerTransparent ? {
|
|
@@ -94,8 +113,10 @@ export default function NativeStackView({
|
|
|
94
113
|
} : null]
|
|
95
114
|
}),
|
|
96
115
|
style: [StyleSheet.absoluteFill, {
|
|
97
|
-
display: isFocused ? 'flex' : 'none'
|
|
98
|
-
}
|
|
116
|
+
display: isFocused || nextPresentation != null && TRANSPARENT_PRESENTATIONS.includes(nextPresentation) ? 'flex' : 'none'
|
|
117
|
+
}, presentation != null && TRANSPARENT_PRESENTATIONS.includes(presentation) ? {
|
|
118
|
+
backgroundColor: 'transparent'
|
|
119
|
+
} : null]
|
|
99
120
|
}, /*#__PURE__*/React.createElement(View, {
|
|
100
121
|
style: [styles.contentContainer, contentStyle]
|
|
101
122
|
}, render()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeStackView.tsx"],"names":["getHeaderTitle","Header","HeaderBackButton","SafeAreaProviderCompat","Screen","React","Image","StyleSheet","View","NativeStackView","state","descriptors","styles","container","routes","map","route","i","isFocused","index","canGoBack","previousKey","key","previousDescriptor","undefined","options","navigation","render","header","headerShown","headerTintColor","headerBackImageSource","headerLeft","headerRight","headerTitle","headerTitleAlign","headerTitleStyle","headerStyle","headerShadowVisible","headerTransparent","contentStyle","headerBackTitle","back","title","name","tintColor","label","backImage","goBack","children","position","backgroundColor","shadowOpacity","borderBottomWidth","absoluteFill","display","contentContainer","create","flex","height","width","margin","resizeMode"],"mappings":"AAAA,SACEA,cADF,EAEEC,MAFF,EAGEC,gBAHF,EAIEC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AAAA,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\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 previousDescriptor = previousKey\n ? descriptors[previousKey]\n : 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 contentStyle,\n headerBackTitle,\n } = options;\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 }) => headerRight({ tintColor })\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 { display: isFocused ? 'flex' : 'none' },\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":["getHeaderTitle","Header","HeaderBackButton","SafeAreaProviderCompat","Screen","React","Image","StyleSheet","View","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","absoluteFill","display","includes","contentContainer","create","flex","height","width","margin","resizeMode"],"mappings":"AAAA,SACEA,cADF,EAEEC,MAFF,EAGEC,gBAHF,EAIEC,sBAJF,EAKEC,MALF,QAMO,4BANP;AAWA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,KAAT,EAAgBC,UAAhB,EAA4BC,IAA5B,QAAwC,cAAxC;AAeA,MAAMC,yBAAyB,GAAG,CAChC,kBADgC,EAEhC,2BAFgC,CAAlC;AAKA,eAAe,SAASC,eAAT,OAAwD;AAAA,MAA/B;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAA+B;AACrE,sBACE,oBAAC,sBAAD,qBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEC,MAAM,CAACC;AAApB,KACGH,KAAK,CAACI,MAAN,CAAaC,GAAb,CAAiB,CAACC,KAAD,EAAQC,CAAR,KAAc;AAAA;;AAC9B,UAAMC,SAAS,GAAGR,KAAK,CAACS,KAAN,KAAgBF,CAAlC;AACA,UAAMG,SAAS,GAAGH,CAAC,KAAK,CAAxB;AACA,UAAMI,WAAW,oBAAGX,KAAK,CAACI,MAAN,CAAaG,CAAC,GAAG,CAAjB,CAAH,kDAAG,cAAqBK,GAAzC;AACA,UAAMC,OAAO,qBAAGb,KAAK,CAACI,MAAN,CAAaG,CAAC,GAAG,CAAjB,CAAH,mDAAG,eAAqBK,GAArC;AACA,UAAME,kBAAkB,GAAGH,WAAW,GAClCV,WAAW,CAACU,WAAD,CADuB,GAElCI,SAFJ;AAGA,UAAMC,aAAa,GAAGH,OAAO,GAAGZ,WAAW,CAACY,OAAD,CAAd,GAA0BE,SAAvD;AACA,UAAM;AAAEE,MAAAA,OAAF;AAAWC,MAAAA,UAAX;AAAuBC,MAAAA;AAAvB,QAAkClB,WAAW,CAACK,KAAK,CAACM,GAAP,CAAnD;AAEA,UAAM;AACJQ,MAAAA,MADI;AAEJC,MAAAA,WAFI;AAGJC,MAAAA,eAHI;AAIJC,MAAAA,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Df,QAvBN;AAsFE,MAAA,KAAK,EAAE,CACLnD,UAAU,CAACoD,YADN,EAEL;AACEC,QAAAA,OAAO,EACLzC,SAAS,IACR2B,gBAAgB,IAAI,IAApB,IACCrC,yBAAyB,CAACoD,QAA1B,CAAmCf,gBAAnC,CAFF,GAGI,MAHJ,GAII;AANR,OAFK,EAULF,YAAY,IAAI,IAAhB,IACAnC,yBAAyB,CAACoD,QAA1B,CAAmCjB,YAAnC,CADA,GAEI;AAAEY,QAAAA,eAAe,EAAE;AAAnB,OAFJ,GAGI,IAbC;AAtFT,oBAsGE,oBAAC,IAAD;AAAM,MAAA,KAAK,EAAE,CAAC3C,MAAM,CAACiD,gBAAR,EAA0BjB,YAA1B;AAAb,OACGf,MAAM,EADT,CAtGF,CADF;AA4GD,GA3IA,CADH,CADF,CADF;AAkJD;AAED,MAAMjB,MAAM,GAAGN,UAAU,CAACwD,MAAX,CAAkB;AAC/BjD,EAAAA,SAAS,EAAE;AACTkD,IAAAA,IAAI,EAAE;AADG,GADoB;AAI/BF,EAAAA,gBAAgB,EAAE;AAChBE,IAAAA,IAAI,EAAE;AADU,GAJa;AAO/BZ,EAAAA,SAAS,EAAE;AACTa,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,9 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import { getDefaultHeaderHeight, getHeaderTitle, HeaderHeightContext, HeaderShownContext, SafeAreaProviderCompat } from '@react-navigation/elements';
|
|
4
|
-
import { StackActions, useTheme } from '@react-navigation/native';
|
|
4
|
+
import { NavigationContext, NavigationRouteContext, StackActions, useTheme } from '@react-navigation/native';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import { Platform, StyleSheet } from 'react-native';
|
|
6
|
+
import { Platform, StyleSheet, View } from 'react-native';
|
|
7
7
|
import { useSafeAreaFrame, useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
8
8
|
import { Screen, ScreenStack } from 'react-native-screens';
|
|
9
9
|
import warnOnce from 'warn-once';
|
|
@@ -11,12 +11,14 @@ import DebugContainer from './DebugContainer';
|
|
|
11
11
|
import HeaderConfig from './HeaderConfig';
|
|
12
12
|
const isAndroid = Platform.OS === 'android';
|
|
13
13
|
|
|
14
|
-
const MaybeNestedStack =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const MaybeNestedStack = _ref => {
|
|
15
|
+
let {
|
|
16
|
+
options,
|
|
17
|
+
route,
|
|
18
|
+
presentation,
|
|
19
|
+
headerHeight,
|
|
20
|
+
children
|
|
21
|
+
} = _ref;
|
|
20
22
|
const {
|
|
21
23
|
colors
|
|
22
24
|
} = useTheme();
|
|
@@ -37,14 +39,6 @@ const MaybeNestedStack = ({
|
|
|
37
39
|
}, contentStyle],
|
|
38
40
|
stackPresentation: presentation === 'card' ? 'push' : presentation
|
|
39
41
|
}, children);
|
|
40
|
-
const insets = useSafeAreaInsets();
|
|
41
|
-
const dimensions = useSafeAreaFrame(); // landscape is meaningful only for iPhone
|
|
42
|
-
|
|
43
|
-
const isLandscape = dimensions.width > dimensions.height && !Platform.isPad && !Platform.isTVOS; // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.
|
|
44
|
-
|
|
45
|
-
const isFullScreenModal = presentation !== 'modal' && presentation !== 'formSheet';
|
|
46
|
-
const topInset = isFullScreenModal && !isLandscape ? insets.top : 0;
|
|
47
|
-
const headerHeight = getDefaultHeaderHeight(dimensions, !isFullScreenModal, topInset);
|
|
48
42
|
|
|
49
43
|
if (isHeaderInModal) {
|
|
50
44
|
return /*#__PURE__*/React.createElement(ScreenStack, {
|
|
@@ -52,28 +46,26 @@ const MaybeNestedStack = ({
|
|
|
52
46
|
}, /*#__PURE__*/React.createElement(Screen, {
|
|
53
47
|
enabled: true,
|
|
54
48
|
style: StyleSheet.absoluteFill
|
|
55
|
-
}, /*#__PURE__*/React.createElement(HeaderShownContext.Provider, {
|
|
56
|
-
value: true
|
|
57
|
-
}, /*#__PURE__*/React.createElement(HeaderHeightContext.Provider, {
|
|
58
|
-
value: headerHeight
|
|
59
49
|
}, /*#__PURE__*/React.createElement(HeaderConfig, _extends({}, options, {
|
|
60
50
|
route: route,
|
|
51
|
+
headerHeight: headerHeight,
|
|
61
52
|
canGoBack: true
|
|
62
|
-
})), content))
|
|
53
|
+
})), content));
|
|
63
54
|
}
|
|
64
55
|
|
|
65
56
|
return content;
|
|
66
57
|
};
|
|
67
58
|
|
|
68
|
-
const SceneView =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
59
|
+
const SceneView = _ref2 => {
|
|
60
|
+
let {
|
|
61
|
+
descriptor,
|
|
62
|
+
previousDescriptor,
|
|
63
|
+
index,
|
|
64
|
+
onWillDisappear,
|
|
65
|
+
onAppear,
|
|
66
|
+
onDisappear,
|
|
67
|
+
onDismissed
|
|
68
|
+
} = _ref2;
|
|
77
69
|
const {
|
|
78
70
|
route,
|
|
79
71
|
navigation,
|
|
@@ -81,11 +73,13 @@ const SceneView = ({
|
|
|
81
73
|
render
|
|
82
74
|
} = descriptor;
|
|
83
75
|
const {
|
|
76
|
+
animation,
|
|
77
|
+
animationTypeForReplace = 'push',
|
|
78
|
+
customAnimationOnGesture,
|
|
79
|
+
fullScreenGestureEnabled,
|
|
84
80
|
gestureEnabled,
|
|
85
81
|
header,
|
|
86
82
|
headerShown,
|
|
87
|
-
animationTypeForReplace = 'push',
|
|
88
|
-
animation,
|
|
89
83
|
orientation,
|
|
90
84
|
statusBarAnimation,
|
|
91
85
|
statusBarHidden,
|
|
@@ -103,13 +97,24 @@ const SceneView = ({
|
|
|
103
97
|
|
|
104
98
|
const isHeaderInPush = isAndroid ? headerShown : presentation === 'card' && headerShown !== false;
|
|
105
99
|
const insets = useSafeAreaInsets();
|
|
100
|
+
const frame = useSafeAreaFrame(); // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.
|
|
101
|
+
|
|
102
|
+
const isModal = presentation === 'modal' || presentation === 'formSheet'; // Modals are fullscreen in landscape only on iPhone
|
|
103
|
+
|
|
104
|
+
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad && Platform.isTVOS);
|
|
105
|
+
const isLandscape = frame.width > frame.height;
|
|
106
|
+
const topInset = isModal || isIPhone && isLandscape ? 0 : insets.top;
|
|
106
107
|
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
|
107
108
|
const parentHeaderHeight = React.useContext(HeaderHeightContext);
|
|
108
|
-
const
|
|
109
|
+
const defaultHeaderHeight = getDefaultHeaderHeight(frame, isModal, topInset);
|
|
110
|
+
const [customHeaderHeight, setCustomHeaderHeight] = React.useState(defaultHeaderHeight);
|
|
111
|
+
const headerHeight = header ? customHeaderHeight : defaultHeaderHeight;
|
|
109
112
|
return /*#__PURE__*/React.createElement(Screen, {
|
|
110
113
|
key: route.key,
|
|
111
114
|
enabled: true,
|
|
112
115
|
style: StyleSheet.absoluteFill,
|
|
116
|
+
customAnimationOnSwipe: customAnimationOnGesture,
|
|
117
|
+
fullScreenSwipeEnabled: fullScreenGestureEnabled,
|
|
113
118
|
gestureEnabled: isAndroid ? // This prop enables handling of system back gestures on Android
|
|
114
119
|
// Since we handle them in JS side, we disable this
|
|
115
120
|
false : gestureEnabled,
|
|
@@ -123,37 +128,48 @@ const SceneView = ({
|
|
|
123
128
|
onWillDisappear: onWillDisappear,
|
|
124
129
|
onAppear: onAppear,
|
|
125
130
|
onDisappear: onDisappear,
|
|
126
|
-
onDismissed: onDismissed
|
|
131
|
+
onDismissed: onDismissed,
|
|
132
|
+
isNativeStack: true
|
|
127
133
|
}, /*#__PURE__*/React.createElement(HeaderShownContext.Provider, {
|
|
128
134
|
value: isParentHeaderShown || isHeaderInPush !== false
|
|
129
135
|
}, /*#__PURE__*/React.createElement(HeaderHeightContext.Provider, {
|
|
130
136
|
value: isHeaderInPush !== false ? headerHeight : parentHeaderHeight !== null && parentHeaderHeight !== void 0 ? parentHeaderHeight : 0
|
|
131
|
-
}, header !== undefined && headerShown !== false ?
|
|
132
|
-
|
|
137
|
+
}, header !== undefined && headerShown !== false ? /*#__PURE__*/React.createElement(NavigationContext.Provider, {
|
|
138
|
+
value: navigation
|
|
139
|
+
}, /*#__PURE__*/React.createElement(NavigationRouteContext.Provider, {
|
|
140
|
+
value: route
|
|
141
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
142
|
+
onLayout: e => {
|
|
143
|
+
setCustomHeaderHeight(e.nativeEvent.layout.height);
|
|
144
|
+
}
|
|
145
|
+
}, header({
|
|
133
146
|
back: previousDescriptor ? {
|
|
134
147
|
title: getHeaderTitle(previousDescriptor.options, previousDescriptor.route.name)
|
|
135
148
|
} : undefined,
|
|
136
149
|
options,
|
|
137
150
|
route,
|
|
138
151
|
navigation
|
|
139
|
-
}) : /*#__PURE__*/React.createElement(HeaderConfig, _extends({}, options, {
|
|
152
|
+
})))) : /*#__PURE__*/React.createElement(HeaderConfig, _extends({}, options, {
|
|
140
153
|
route: route,
|
|
141
154
|
headerShown: isHeaderInPush,
|
|
155
|
+
headerHeight: headerHeight,
|
|
142
156
|
canGoBack: index !== 0
|
|
143
157
|
})), /*#__PURE__*/React.createElement(MaybeNestedStack, {
|
|
144
158
|
options: options,
|
|
145
159
|
route: route,
|
|
146
|
-
presentation: presentation
|
|
160
|
+
presentation: presentation,
|
|
161
|
+
headerHeight: headerHeight
|
|
147
162
|
}, render()))));
|
|
148
163
|
};
|
|
149
164
|
|
|
150
|
-
function NativeStackViewInner({
|
|
151
|
-
state,
|
|
152
|
-
navigation,
|
|
153
|
-
descriptors
|
|
154
|
-
}) {
|
|
165
|
+
function NativeStackViewInner(_ref3) {
|
|
155
166
|
var _state$routes$find;
|
|
156
167
|
|
|
168
|
+
let {
|
|
169
|
+
state,
|
|
170
|
+
navigation,
|
|
171
|
+
descriptors
|
|
172
|
+
} = _ref3;
|
|
157
173
|
const [nextDismissedKey, setNextDismissedKey] = React.useState(null);
|
|
158
174
|
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;
|
|
159
175
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["NativeStackView.native.tsx"],"names":["getDefaultHeaderHeight","getHeaderTitle","HeaderHeightContext","HeaderShownContext","SafeAreaProviderCompat","StackActions","useTheme","React","Platform","StyleSheet","useSafeAreaFrame","useSafeAreaInsets","Screen","ScreenStack","warnOnce","DebugContainer","HeaderConfig","isAndroid","OS","MaybeNestedStack","options","route","presentation","children","colors","header","headerShown","contentStyle","isHeaderInModal","undefined","headerShownPreviousRef","useRef","useEffect","current","name","content","styles","container","backgroundColor","background","insets","dimensions","isLandscape","width","height","isPad","isTVOS","isFullScreenModal","topInset","top","headerHeight","absoluteFill","SceneView","descriptor","previousDescriptor","index","onWillDisappear","onAppear","onDisappear","onDismissed","navigation","render","gestureEnabled","animationTypeForReplace","animation","orientation","statusBarAnimation","statusBarHidden","statusBarStyle","isHeaderInPush","isParentHeaderShown","useContext","parentHeaderHeight","key","back","title","NativeStackViewInner","state","descriptors","nextDismissedKey","setNextDismissedKey","useState","dismissedRouteName","routes","find","message","console","error","map","previousKey","emit","type","data","closing","target","dispatch","pop","source","NativeStackView","props","create","flex"],"mappings":";;AAAA,SACEA,sBADF,EAEEC,cAFF,EAGEC,mBAHF,EAIEC,kBAJF,EAKEC,sBALF,QAMO,4BANP;AAOA,SAGEC,YAHF,EAKEC,QALF,QAMO,0BANP;AAOA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAsCC,UAAtC,QAAwD,cAAxD;AACA,SACEC,gBADF,EAEEC,iBAFF,QAGO,gCAHP;AAIA,SACEC,MADF,EAEEC,WAFF,Q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D,EAAAA,SAAS,EAAE;AACTgE,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n getDefaultHeaderHeight,\n getHeaderTitle,\n HeaderHeightContext,\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Platform, PlatformIOSStatic, StyleSheet } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport {\n Screen,\n ScreenStack,\n StackPresentationTypes,\n} from 'react-native-screens';\nimport warnOnce from 'warn-once';\n\nimport type {\n NativeStackDescriptor,\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n NativeStackNavigationOptions,\n} from '../types';\nimport DebugContainer from './DebugContainer';\nimport HeaderConfig from './HeaderConfig';\n\nconst isAndroid = Platform.OS === 'android';\n\nconst MaybeNestedStack = ({\n options,\n route,\n presentation,\n children,\n}: {\n options: NativeStackNavigationOptions;\n route: Route<string>;\n presentation: Exclude<StackPresentationTypes, 'push'> | 'card';\n children: React.ReactNode;\n}) => {\n const { colors } = useTheme();\n const { header, headerShown = true, contentStyle } = options;\n\n const isHeaderInModal = isAndroid\n ? false\n : presentation !== 'card' && headerShown === true && header === undefined;\n\n const headerShownPreviousRef = React.useRef(headerShown);\n\n React.useEffect(() => {\n warnOnce(\n !isAndroid &&\n presentation !== 'card' &&\n headerShownPreviousRef.current !== headerShown,\n `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`\n );\n\n headerShownPreviousRef.current = headerShown;\n }, [headerShown, presentation, route.name]);\n\n const content = (\n <DebugContainer\n style={[\n styles.container,\n presentation !== 'transparentModal' &&\n presentation !== 'containedTransparentModal' && {\n backgroundColor: colors.background,\n },\n contentStyle,\n ]}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n >\n {children}\n </DebugContainer>\n );\n\n const insets = useSafeAreaInsets();\n const dimensions = useSafeAreaFrame();\n // landscape is meaningful only for iPhone\n const isLandscape =\n dimensions.width > dimensions.height &&\n !(Platform as PlatformIOSStatic).isPad &&\n !(Platform as PlatformIOSStatic).isTVOS;\n // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.\n const isFullScreenModal =\n presentation !== 'modal' && presentation !== 'formSheet';\n const topInset = isFullScreenModal && !isLandscape ? insets.top : 0;\n const headerHeight = getDefaultHeaderHeight(\n dimensions,\n !isFullScreenModal,\n topInset\n );\n\n if (isHeaderInModal) {\n return (\n <ScreenStack style={styles.container}>\n <Screen enabled style={StyleSheet.absoluteFill}>\n <HeaderShownContext.Provider value>\n <HeaderHeightContext.Provider value={headerHeight}>\n <HeaderConfig {...options} route={route} canGoBack />\n {content}\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </Screen>\n </ScreenStack>\n );\n }\n\n return content;\n};\n\ntype SceneViewProps = {\n index: number;\n descriptor: NativeStackDescriptor;\n previousDescriptor?: NativeStackDescriptor;\n onWillDisappear: () => void;\n onAppear: () => void;\n onDisappear: () => void;\n onDismissed: () => void;\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n gestureEnabled,\n header,\n headerShown,\n animationTypeForReplace = 'push',\n animation,\n orientation,\n statusBarAnimation,\n statusBarHidden,\n statusBarStyle,\n } = options;\n\n let { presentation = 'card' } = options;\n\n if (index === 0) {\n // first screen should always be treated as `card`, it resolves problems with no header animation\n // for navigator with first screen as `modal` and the next as `card`\n presentation = 'card';\n }\n\n const isHeaderInPush = isAndroid\n ? headerShown\n : presentation === 'card' && headerShown !== false;\n\n const insets = useSafeAreaInsets();\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n const parentHeaderHeight = React.useContext(HeaderHeightContext);\n const headerHeight = getDefaultHeaderHeight(\n useSafeAreaFrame(),\n false,\n insets.top\n );\n\n return (\n <Screen\n key={route.key}\n enabled\n style={StyleSheet.absoluteFill}\n gestureEnabled={\n isAndroid\n ? // This prop enables handling of system back gestures on Android\n // Since we handle them in JS side, we disable this\n false\n : gestureEnabled\n }\n replaceAnimation={animationTypeForReplace}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n stackAnimation={animation}\n screenOrientation={orientation}\n statusBarAnimation={statusBarAnimation}\n statusBarHidden={statusBarHidden}\n statusBarStyle={statusBarStyle}\n onWillDisappear={onWillDisappear}\n onAppear={onAppear}\n onDisappear={onDisappear}\n onDismissed={onDismissed}\n >\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false ? headerHeight : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\n // TODO: expose custom header height\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 <HeaderConfig\n {...options}\n route={route}\n headerShown={isHeaderInPush}\n canGoBack={index !== 0}\n />\n )}\n <MaybeNestedStack\n options={options}\n route={route}\n presentation={presentation}\n >\n {render()}\n </MaybeNestedStack>\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </Screen>\n );\n};\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nfunction NativeStackViewInner({ state, navigation, descriptors }: Props) {\n const [nextDismissedKey, setNextDismissedKey] =\n React.useState<string | null>(null);\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 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;\n\n console.error(message);\n }\n }, [dismissedRouteName]);\n\n return (\n <ScreenStack style={styles.container}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const previousKey = state.routes[index - 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n\n return (\n <SceneView\n key={route.key}\n index={index}\n descriptor={descriptor}\n previousDescriptor={previousDescriptor}\n onWillDisappear={() => {\n navigation.emit({\n type: 'transitionStart',\n data: { closing: true },\n target: route.key,\n });\n }}\n onAppear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: false },\n target: route.key,\n });\n }}\n onDisappear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: true },\n target: route.key,\n });\n }}\n onDismissed={() => {\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key,\n });\n\n setNextDismissedKey(route.key);\n }}\n />\n );\n })}\n </ScreenStack>\n );\n}\n\nexport default function NativeStackView(props: Props) {\n return (\n <SafeAreaProviderCompat>\n <NativeStackViewInner {...props} />\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["NativeStackView.native.tsx"],"names":["getDefaultHeaderHeight","getHeaderTitle","HeaderHeightContext","HeaderShownContext","SafeAreaProviderCompat","NavigationContext","NavigationRouteContext","StackActions","useTheme","React","Platform","StyleSheet","View","useSafeAreaFrame","useSafeAreaInsets","Screen","ScreenStack","warnOnce","DebugContainer","HeaderConfig","isAndroid","OS","MaybeNestedStack","options","route","presentation","headerHeight","children","colors","header","headerShown","contentStyle","isHeaderInModal","undefined","headerShownPreviousRef","useRef","useEffect","current","name","content","styles","container","backgroundColor","background","absoluteFill","SceneView","descriptor","previousDescriptor","index","onWillDisappear","onAppear","onDisappear","onDismissed","navigation","render","animation","animationTypeForReplace","customAnimationOnGesture","fullScreenGestureEnabled","gestureEnabled","orientation","statusBarAnimation","statusBarHidden","statusBarStyle","isHeaderInPush","insets","frame","isModal","isIPhone","isPad","isTVOS","isLandscape","width","height","topInset","top","isParentHeaderShown","useContext","parentHeaderHeight","defaultHeaderHeight","customHeaderHeight","setCustomHeaderHeight","useState","key","e","nativeEvent","layout","back","title","NativeStackViewInner","state","descriptors","nextDismissedKey","setNextDismissedKey","dismissedRouteName","routes","find","message","console","error","map","previousKey","emit","type","data","closing","target","dispatch","pop","source","NativeStackView","props","create","flex"],"mappings":";;AAAA,SACEA,sBADF,EAEEC,cAFF,EAGEC,mBAHF,EAIEC,kBAJF,EAKEC,sBALF,QAMO,4BANP;AAOA,SACEC,iBADF,EAEEC,sBAFF,EAKEC,YALF,EAOEC,QAPF,QAQO,0BARP;AASA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,EAAmBC,UAAnB,EAA+BC,IAA/B,QAA2C,cAA3C;AACA,SACEC,gBADF,EAEEC,iBAFF,QAGO,gCAHP;AAIA,SACEC,MADF,EAEEC,WAFF,QAIO,sBAJP;AAKA,OAAOC,QAAP,MAAqB,WAArB;AAQA,OAAOC,cAAP,MAA2B,kBAA3B;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA,MAAMC,SAAS,GAAGV,QAAQ,CAACW,EAAT,KAAgB,SAAlC;;AAEA,MAAMC,gBAAgB,GAAG,QAYnB;AAAA,MAZoB;AACxBC,IAAAA,OADwB;AAExBC,IAAAA,KAFwB;AAGxBC,IAAAA,YAHwB;AAIxBC,IAAAA,YAJwB;AAKxBC,IAAAA;AALwB,GAYpB;AACJ,QAAM;AAAEC,IAAAA;AAAF,MAAapB,QAAQ,EAA3B;AACA,QAAM;AAAEqB,IAAAA,MAAF;AAAUC,IAAAA,WAAW,GAAG,IAAxB;AAA8BC,IAAAA;AAA9B,MAA+CR,OAArD;AAEA,QAAMS,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C/BvE,EAAAA,SAAS,EAAE;AACTwE,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n getDefaultHeaderHeight,\n getHeaderTitle,\n HeaderHeightContext,\n HeaderShownContext,\n SafeAreaProviderCompat,\n} from '@react-navigation/elements';\nimport {\n NavigationContext,\n NavigationRouteContext,\n ParamListBase,\n Route,\n StackActions,\n StackNavigationState,\n useTheme,\n} from '@react-navigation/native';\nimport * as React from 'react';\nimport { Platform, StyleSheet, View } from 'react-native';\nimport {\n useSafeAreaFrame,\n useSafeAreaInsets,\n} from 'react-native-safe-area-context';\nimport {\n Screen,\n ScreenStack,\n StackPresentationTypes,\n} from 'react-native-screens';\nimport warnOnce from 'warn-once';\n\nimport type {\n NativeStackDescriptor,\n NativeStackDescriptorMap,\n NativeStackNavigationHelpers,\n NativeStackNavigationOptions,\n} from '../types';\nimport DebugContainer from './DebugContainer';\nimport HeaderConfig from './HeaderConfig';\n\nconst isAndroid = Platform.OS === 'android';\n\nconst MaybeNestedStack = ({\n options,\n route,\n presentation,\n headerHeight,\n children,\n}: {\n options: NativeStackNavigationOptions;\n route: Route<string>;\n presentation: Exclude<StackPresentationTypes, 'push'> | 'card';\n headerHeight: number;\n children: React.ReactNode;\n}) => {\n const { colors } = useTheme();\n const { header, headerShown = true, contentStyle } = options;\n\n const isHeaderInModal = isAndroid\n ? false\n : presentation !== 'card' && headerShown === true && header === undefined;\n\n const headerShownPreviousRef = React.useRef(headerShown);\n\n React.useEffect(() => {\n warnOnce(\n !isAndroid &&\n presentation !== 'card' &&\n headerShownPreviousRef.current !== headerShown,\n `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`\n );\n\n headerShownPreviousRef.current = headerShown;\n }, [headerShown, presentation, route.name]);\n\n const content = (\n <DebugContainer\n style={[\n styles.container,\n presentation !== 'transparentModal' &&\n presentation !== 'containedTransparentModal' && {\n backgroundColor: colors.background,\n },\n contentStyle,\n ]}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n >\n {children}\n </DebugContainer>\n );\n\n if (isHeaderInModal) {\n return (\n <ScreenStack style={styles.container}>\n <Screen enabled style={StyleSheet.absoluteFill}>\n <HeaderConfig\n {...options}\n route={route}\n headerHeight={headerHeight}\n canGoBack\n />\n {content}\n </Screen>\n </ScreenStack>\n );\n }\n\n return content;\n};\n\ntype SceneViewProps = {\n index: number;\n descriptor: NativeStackDescriptor;\n previousDescriptor?: NativeStackDescriptor;\n onWillDisappear: () => void;\n onAppear: () => void;\n onDisappear: () => void;\n onDismissed: () => void;\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n animation,\n animationTypeForReplace = 'push',\n customAnimationOnGesture,\n fullScreenGestureEnabled,\n gestureEnabled,\n header,\n headerShown,\n orientation,\n statusBarAnimation,\n statusBarHidden,\n statusBarStyle,\n } = options;\n\n let { presentation = 'card' } = options;\n\n if (index === 0) {\n // first screen should always be treated as `card`, it resolves problems with no header animation\n // for navigator with first screen as `modal` and the next as `card`\n presentation = 'card';\n }\n\n const isHeaderInPush = isAndroid\n ? headerShown\n : presentation === 'card' && headerShown !== false;\n\n const insets = useSafeAreaInsets();\n const frame = useSafeAreaFrame();\n\n // `modal` and `formSheet` presentations do not take whole screen, so should not take the inset.\n const isModal = presentation === 'modal' || presentation === 'formSheet';\n\n // Modals are fullscreen in landscape only on iPhone\n const isIPhone =\n Platform.OS === 'ios' && !(Platform.isPad && Platform.isTVOS);\n const isLandscape = frame.width > frame.height;\n\n const topInset = isModal || (isIPhone && isLandscape) ? 0 : insets.top;\n\n const isParentHeaderShown = React.useContext(HeaderShownContext);\n const parentHeaderHeight = React.useContext(HeaderHeightContext);\n\n const defaultHeaderHeight = getDefaultHeaderHeight(frame, isModal, topInset);\n\n const [customHeaderHeight, setCustomHeaderHeight] =\n React.useState(defaultHeaderHeight);\n\n const headerHeight = header ? customHeaderHeight : defaultHeaderHeight;\n\n return (\n <Screen\n key={route.key}\n enabled\n style={StyleSheet.absoluteFill}\n customAnimationOnSwipe={customAnimationOnGesture}\n fullScreenSwipeEnabled={fullScreenGestureEnabled}\n gestureEnabled={\n isAndroid\n ? // This prop enables handling of system back gestures on Android\n // Since we handle them in JS side, we disable this\n false\n : gestureEnabled\n }\n replaceAnimation={animationTypeForReplace}\n stackPresentation={presentation === 'card' ? 'push' : presentation}\n stackAnimation={animation}\n screenOrientation={orientation}\n statusBarAnimation={statusBarAnimation}\n statusBarHidden={statusBarHidden}\n statusBarStyle={statusBarStyle}\n onWillDisappear={onWillDisappear}\n onAppear={onAppear}\n onDisappear={onDisappear}\n onDismissed={onDismissed}\n isNativeStack\n >\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false ? headerHeight : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <View\n onLayout={(e) => {\n setCustomHeaderHeight(e.nativeEvent.layout.height);\n }}\n >\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 </View>\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n ) : (\n <HeaderConfig\n {...options}\n route={route}\n headerShown={isHeaderInPush}\n headerHeight={headerHeight}\n canGoBack={index !== 0}\n />\n )}\n <MaybeNestedStack\n options={options}\n route={route}\n presentation={presentation}\n headerHeight={headerHeight}\n >\n {render()}\n </MaybeNestedStack>\n </HeaderHeightContext.Provider>\n </HeaderShownContext.Provider>\n </Screen>\n );\n};\n\ntype Props = {\n state: StackNavigationState<ParamListBase>;\n navigation: NativeStackNavigationHelpers;\n descriptors: NativeStackDescriptorMap;\n};\n\nfunction NativeStackViewInner({ state, navigation, descriptors }: Props) {\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 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;\n\n console.error(message);\n }\n }, [dismissedRouteName]);\n\n return (\n <ScreenStack style={styles.container}>\n {state.routes.map((route, index) => {\n const descriptor = descriptors[route.key];\n const previousKey = state.routes[index - 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n\n return (\n <SceneView\n key={route.key}\n index={index}\n descriptor={descriptor}\n previousDescriptor={previousDescriptor}\n onWillDisappear={() => {\n navigation.emit({\n type: 'transitionStart',\n data: { closing: true },\n target: route.key,\n });\n }}\n onAppear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: false },\n target: route.key,\n });\n }}\n onDisappear={() => {\n navigation.emit({\n type: 'transitionEnd',\n data: { closing: true },\n target: route.key,\n });\n }}\n onDismissed={() => {\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key,\n });\n\n setNextDismissedKey(route.key);\n }}\n />\n );\n })}\n </ScreenStack>\n );\n}\n\nexport default function NativeStackView(props: Props) {\n return (\n <SafeAreaProviderCompat>\n <NativeStackViewInner {...props} />\n </SafeAreaProviderCompat>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n});\n"]}
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* Navigators
|
|
3
3
|
*/
|
|
4
4
|
export { default as createNativeStackNavigator } from './navigators/createNativeStackNavigator';
|
|
5
|
+
/**
|
|
6
|
+
* Views
|
|
7
|
+
*/
|
|
8
|
+
export { default as NativeStackView } from './views/NativeStackView';
|
|
5
9
|
/**
|
|
6
10
|
* Types
|
|
7
11
|
*/
|
|
8
|
-
export type { NativeStackHeaderProps, NativeStackNavigationOptions, NativeStackNavigationProp, NativeStackScreenProps, } from './types';
|
|
12
|
+
export type { NativeStackHeaderProps, NativeStackNavigationEventMap, NativeStackNavigationOptions, NativeStackNavigationProp, NativeStackScreenProps, } from './types';
|
|
@@ -50,20 +50,22 @@ export declare type NativeStackHeaderProps = {
|
|
|
50
50
|
*/
|
|
51
51
|
navigation: NativeStackNavigationProp<ParamListBase>;
|
|
52
52
|
};
|
|
53
|
-
export declare type
|
|
53
|
+
export declare type HeaderButtonProps = {
|
|
54
54
|
/**
|
|
55
55
|
* Tint color for the header.
|
|
56
56
|
*/
|
|
57
57
|
tintColor?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Whether it's possible to navigate back in stack.
|
|
60
|
+
*/
|
|
61
|
+
canGoBack: boolean;
|
|
62
|
+
};
|
|
63
|
+
export declare type HeaderBackButtonProps = HeaderButtonProps & {
|
|
58
64
|
/**
|
|
59
65
|
* Label text for the button. Usually the title of the previous screen.
|
|
60
66
|
* By default, this is only shown on iOS.
|
|
61
67
|
*/
|
|
62
68
|
label?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Whether it's possible to navigate back in stack.
|
|
65
|
-
*/
|
|
66
|
-
canGoBack: boolean;
|
|
67
69
|
};
|
|
68
70
|
export declare type NativeStackNavigationOptions = {
|
|
69
71
|
/**
|
|
@@ -143,6 +145,7 @@ export declare type NativeStackNavigationOptions = {
|
|
|
143
145
|
*
|
|
144
146
|
* For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as `ScrollView` or `FlatList`.
|
|
145
147
|
* If the scrollable area doesn't fill the screen, the large title won't collapse on scroll.
|
|
148
|
+
* You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
|
|
146
149
|
*
|
|
147
150
|
* Only supported on iOS.
|
|
148
151
|
*
|
|
@@ -209,6 +212,12 @@ export declare type NativeStackNavigationOptions = {
|
|
|
209
212
|
* Tint color for the header. Changes the color of back button and title.
|
|
210
213
|
*/
|
|
211
214
|
headerTintColor?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Function which returns a React Element to render as the background of the header.
|
|
217
|
+
* This is useful for using backgrounds such as an image, a gradient, blur effect etc.
|
|
218
|
+
* You can use this with `headerTransparent` to render content underneath a translucent header.
|
|
219
|
+
*/
|
|
220
|
+
headerBackground?: () => React.ReactNode;
|
|
212
221
|
/**
|
|
213
222
|
* Function which returns a React Element to display on the left side of the header.
|
|
214
223
|
* This replaces the back button. See `headerBackVisible` to show the back button along side left element.
|
|
@@ -217,9 +226,7 @@ export declare type NativeStackNavigationOptions = {
|
|
|
217
226
|
/**
|
|
218
227
|
* Function which returns a React Element to display on the right side of the header.
|
|
219
228
|
*/
|
|
220
|
-
headerRight?: (props:
|
|
221
|
-
tintColor?: string;
|
|
222
|
-
}) => React.ReactNode;
|
|
229
|
+
headerRight?: (props: HeaderButtonProps) => React.ReactNode;
|
|
223
230
|
/**
|
|
224
231
|
* String or a function that returns a React Element to be used by the header.
|
|
225
232
|
* Defaults to screen `title` or route name.
|
|
@@ -257,9 +264,11 @@ export declare type NativeStackNavigationOptions = {
|
|
|
257
264
|
color?: string;
|
|
258
265
|
}>;
|
|
259
266
|
/**
|
|
260
|
-
* Options to render a native search bar
|
|
267
|
+
* Options to render a native search bar.
|
|
268
|
+
* You also need to specify `contentInsetAdjustmentBehavior="automatic"` in your `ScrollView`, `FlatList` etc.
|
|
269
|
+
* If you don't have a `ScrollView`, specify `headerTransparent: false`.
|
|
261
270
|
*
|
|
262
|
-
*
|
|
271
|
+
* Only supported on iOS and Android.
|
|
263
272
|
*/
|
|
264
273
|
headerSearchBarOptions?: SearchBarProps;
|
|
265
274
|
/**
|
|
@@ -302,6 +311,24 @@ export declare type NativeStackNavigationOptions = {
|
|
|
302
311
|
* Style object for the scene content.
|
|
303
312
|
*/
|
|
304
313
|
contentStyle?: StyleProp<ViewStyle>;
|
|
314
|
+
/**
|
|
315
|
+
* Whether the gesture to dismiss should use animation provided to `animation` prop. Defaults to `false`.
|
|
316
|
+
*
|
|
317
|
+
* Doesn't affect the behavior of screens presented modally.
|
|
318
|
+
*
|
|
319
|
+
* @platform ios
|
|
320
|
+
*/
|
|
321
|
+
customAnimationOnGesture?: boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Whether the gesture to dismiss should work on the whole screen. Using gesture to dismiss with this option results in the same
|
|
324
|
+
* transition animation as `simple_push`. This behavior can be changed by setting `customAnimationOnGesture` prop. Achieving the
|
|
325
|
+
* default iOS animation isn't possible due to platform limitations. Defaults to `false`.
|
|
326
|
+
*
|
|
327
|
+
* Doesn't affect the behavior of screens presented modally.
|
|
328
|
+
*
|
|
329
|
+
* @platform ios
|
|
330
|
+
*/
|
|
331
|
+
fullScreenGestureEnabled?: boolean;
|
|
305
332
|
/**
|
|
306
333
|
* Whether you can use gestures to dismiss this screen. Defaults to `true`.
|
|
307
334
|
*
|
|
@@ -326,7 +353,9 @@ export declare type NativeStackNavigationOptions = {
|
|
|
326
353
|
* Supported values:
|
|
327
354
|
* - "default": use the platform default animation
|
|
328
355
|
* - "fade": fade screen in or out
|
|
329
|
-
* - "flip": flip the screen, requires
|
|
356
|
+
* - "flip": flip the screen, requires presentation: "modal" (iOS only)
|
|
357
|
+
* - "simple_push": use the platform default animation, but without shadow and native header transition (iOS only)
|
|
358
|
+
* - "slide_from_bottom": slide in the new screen from bottom
|
|
330
359
|
* - "slide_from_right": slide in the new screen from right (Android only, uses default animation on iOS)
|
|
331
360
|
* - "slide_from_left": slide in the new screen from left (Android only, uses default animation on iOS)
|
|
332
361
|
* - "none": don't animate the screen
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { Route } from '@react-navigation/native';
|
|
3
3
|
import type { NativeStackNavigationOptions } from '../types';
|
|
4
4
|
declare type Props = NativeStackNavigationOptions & {
|
|
5
|
+
headerHeight: number;
|
|
5
6
|
route: Route<string>;
|
|
6
7
|
canGoBack: boolean;
|
|
7
8
|
};
|
|
8
|
-
export default function HeaderConfig({ headerBackImageSource, headerBackButtonMenuEnabled, headerBackTitle, headerBackTitleStyle, headerBackTitleVisible, headerBackVisible, headerShadowVisible, headerLargeStyle, headerLargeTitle, headerLargeTitleShadowVisible, headerLargeTitleStyle, headerLeft, headerRight, headerShown, headerStyle, headerBlurEffect, headerTintColor, headerTitle, headerTitleAlign, headerTitleStyle, headerTransparent, headerSearchBarOptions, route, title, canGoBack, }: Props): JSX.Element;
|
|
9
|
+
export default function 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, }: Props): JSX.Element;
|
|
9
10
|
export {};
|