@react-navigation/native-stack 6.6.0 → 6.7.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/views/HeaderConfig.js +5 -2
- package/lib/commonjs/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.js +7 -9
- package/lib/commonjs/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.native.js +49 -7
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/views/HeaderConfig.js +6 -3
- package/lib/module/views/HeaderConfig.js.map +1 -1
- package/lib/module/views/NativeStackView.js +7 -9
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +49 -7
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/typescript/src/types.d.ts +48 -0
- package/package.json +10 -11
- package/src/types.tsx +48 -0
- package/src/views/HeaderConfig.tsx +7 -4
- package/src/views/NativeStackView.native.tsx +49 -5
- package/src/views/NativeStackView.tsx +7 -14
|
@@ -1 +1 @@
|
|
|
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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BAAyB,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
|
+
{"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","nextDescriptor","options","navigation","render","header","headerShown","headerTintColor","headerBackImageSource","headerLeft","headerRight","headerTitle","headerTitleAlign","headerTitleStyle","headerStyle","headerShadowVisible","headerTransparent","headerBackground","headerBackTitle","presentation","contentStyle","nextPresentation","back","title","name","tintColor","label","backImage","goBack","children","absoluteFill","display","includes","backgroundColor","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,CA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AAC,IAAD;AAAM,MAAA,KAAK,EAAE,CAAC9C,MAAM,CAAC+C,gBAAR,EAA0Bd,YAA1B;AAAb,OACGhB,MAAM,EADT,CA9FF,CADF;AAoGD,GApIA,CADH,CADF,CADF;AA2ID;AAED,MAAMjB,MAAM,GAAGN,UAAU,CAACsD,MAAX,CAAkB;AAC/B/C,EAAAA,SAAS,EAAE;AACTgD,IAAAA,IAAI,EAAE;AADG,GADoB;AAI/BF,EAAAA,gBAAgB,EAAE;AAChBE,IAAAA,IAAI,EAAE;AADU,GAJa;AAO/BT,EAAAA,SAAS,EAAE;AACTU,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 nextDescriptor = 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 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: 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 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 <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"]}
|
|
@@ -60,6 +60,7 @@ const SceneView = _ref2 => {
|
|
|
60
60
|
let {
|
|
61
61
|
descriptor,
|
|
62
62
|
previousDescriptor,
|
|
63
|
+
nextDescriptor,
|
|
63
64
|
index,
|
|
64
65
|
onWillDisappear,
|
|
65
66
|
onAppear,
|
|
@@ -73,22 +74,53 @@ const SceneView = _ref2 => {
|
|
|
73
74
|
render
|
|
74
75
|
} = descriptor;
|
|
75
76
|
const {
|
|
76
|
-
|
|
77
|
+
animationDuration,
|
|
77
78
|
animationTypeForReplace = 'push',
|
|
78
|
-
customAnimationOnGesture,
|
|
79
|
-
fullScreenGestureEnabled,
|
|
80
79
|
gestureEnabled,
|
|
81
80
|
header,
|
|
82
81
|
headerShown,
|
|
82
|
+
autoHideHomeIndicator,
|
|
83
|
+
navigationBarColor,
|
|
84
|
+
navigationBarHidden,
|
|
83
85
|
orientation,
|
|
84
86
|
statusBarAnimation,
|
|
85
87
|
statusBarHidden,
|
|
86
|
-
statusBarStyle
|
|
88
|
+
statusBarStyle,
|
|
89
|
+
statusBarTranslucent,
|
|
90
|
+
statusBarColor
|
|
87
91
|
} = options;
|
|
88
92
|
let {
|
|
89
|
-
|
|
93
|
+
animation,
|
|
94
|
+
customAnimationOnGesture,
|
|
95
|
+
fullScreenGestureEnabled,
|
|
96
|
+
presentation = 'card',
|
|
97
|
+
gestureDirection = presentation === 'card' ? 'horizontal' : 'vertical'
|
|
90
98
|
} = options;
|
|
91
99
|
|
|
100
|
+
if (gestureDirection === 'vertical' && Platform.OS === 'ios') {
|
|
101
|
+
// for `vertical` direction to work, we need to set `fullScreenGestureEnabled` to `true`
|
|
102
|
+
// so the screen can be dismissed from any point on screen.
|
|
103
|
+
// `customAnimationOnGesture` needs to be set to `true` so the `animation` set by user can be used,
|
|
104
|
+
// otherwise `simple_push` will be used.
|
|
105
|
+
// Also, the default animation for this direction seems to be `slide_from_bottom`.
|
|
106
|
+
if (fullScreenGestureEnabled === undefined) {
|
|
107
|
+
fullScreenGestureEnabled = true;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (customAnimationOnGesture === undefined) {
|
|
111
|
+
customAnimationOnGesture = true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (animation === undefined) {
|
|
115
|
+
animation = 'slide_from_bottom';
|
|
116
|
+
}
|
|
117
|
+
} // workaround for rn-screens where gestureDirection has to be set on both
|
|
118
|
+
// current and previous screen - software-mansion/react-native-screens/pull/1509
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
const nextGestureDirection = nextDescriptor === null || nextDescriptor === void 0 ? void 0 : nextDescriptor.options.gestureDirection;
|
|
122
|
+
const gestureDirectionOverride = nextGestureDirection != null ? nextGestureDirection : gestureDirection;
|
|
123
|
+
|
|
92
124
|
if (index === 0) {
|
|
93
125
|
// first screen should always be treated as `card`, it resolves problems with no header animation
|
|
94
126
|
// for navigator with first screen as `modal` and the next as `card`
|
|
@@ -101,7 +133,7 @@ const SceneView = _ref2 => {
|
|
|
101
133
|
|
|
102
134
|
const isModal = presentation === 'modal' || presentation === 'formSheet'; // Modals are fullscreen in landscape only on iPhone
|
|
103
135
|
|
|
104
|
-
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad
|
|
136
|
+
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad || Platform.isTVOS);
|
|
105
137
|
const isLandscape = frame.width > frame.height;
|
|
106
138
|
const topInset = isModal || isIPhone && isLandscape ? 0 : insets.top;
|
|
107
139
|
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
|
@@ -118,6 +150,9 @@ const SceneView = _ref2 => {
|
|
|
118
150
|
gestureEnabled: isAndroid ? // This prop enables handling of system back gestures on Android
|
|
119
151
|
// Since we handle them in JS side, we disable this
|
|
120
152
|
false : gestureEnabled,
|
|
153
|
+
homeIndicatorHidden: autoHideHomeIndicator,
|
|
154
|
+
navigationBarColor: navigationBarColor,
|
|
155
|
+
navigationBarHidden: navigationBarHidden,
|
|
121
156
|
replaceAnimation: animationTypeForReplace,
|
|
122
157
|
stackPresentation: presentation === 'card' ? 'push' : presentation,
|
|
123
158
|
stackAnimation: animation,
|
|
@@ -125,6 +160,10 @@ const SceneView = _ref2 => {
|
|
|
125
160
|
statusBarAnimation: statusBarAnimation,
|
|
126
161
|
statusBarHidden: statusBarHidden,
|
|
127
162
|
statusBarStyle: statusBarStyle,
|
|
163
|
+
statusBarColor: statusBarColor,
|
|
164
|
+
statusBarTranslucent: statusBarTranslucent,
|
|
165
|
+
swipeDirection: gestureDirectionOverride,
|
|
166
|
+
transitionDuration: animationDuration,
|
|
128
167
|
onWillDisappear: onWillDisappear,
|
|
129
168
|
onAppear: onAppear,
|
|
130
169
|
onDisappear: onDisappear,
|
|
@@ -181,16 +220,19 @@ function NativeStackViewInner(_ref3) {
|
|
|
181
220
|
return /*#__PURE__*/React.createElement(ScreenStack, {
|
|
182
221
|
style: styles.container
|
|
183
222
|
}, state.routes.map((route, index) => {
|
|
184
|
-
var _state$routes;
|
|
223
|
+
var _state$routes, _state$routes2;
|
|
185
224
|
|
|
186
225
|
const descriptor = descriptors[route.key];
|
|
187
226
|
const previousKey = (_state$routes = state.routes[index - 1]) === null || _state$routes === void 0 ? void 0 : _state$routes.key;
|
|
227
|
+
const nextKey = (_state$routes2 = state.routes[index + 1]) === null || _state$routes2 === void 0 ? void 0 : _state$routes2.key;
|
|
188
228
|
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
229
|
+
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
189
230
|
return /*#__PURE__*/React.createElement(SceneView, {
|
|
190
231
|
key: route.key,
|
|
191
232
|
index: index,
|
|
192
233
|
descriptor: descriptor,
|
|
193
234
|
previousDescriptor: previousDescriptor,
|
|
235
|
+
nextDescriptor: nextDescriptor,
|
|
194
236
|
onWillDisappear: () => {
|
|
195
237
|
navigation.emit({
|
|
196
238
|
type: 'transitionStart',
|
|
@@ -1 +1 @@
|
|
|
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","event","dispatch","pop","dismissCount","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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AI,EAAE,eADQ;AAEdC,UAAAA,IAAI,EAAE;AAAEC,YAAAA,OAAO,EAAE;AAAX,WAFQ;AAGdC,UAAAA,MAAM,EAAElF,KAAK,CAAC2D;AAHA,SAAhB;AAKD,OAzBH;AA0BE,MAAA,WAAW,EAAGwB,KAAD,IAAW;AACtBtD,QAAAA,UAAU,CAACuD,QAAX,CAAoB,EAClB,GAAGrG,YAAY,CAACsG,GAAb,CAAiBF,KAAK,CAACtB,WAAN,CAAkByB,YAAnC,CADe;AAElBC,UAAAA,MAAM,EAAEvF,KAAK,CAAC2D,GAFI;AAGlBuB,UAAAA,MAAM,EAAEhB,KAAK,CAACP;AAHI,SAApB;AAMAU,QAAAA,mBAAmB,CAACrE,KAAK,CAAC2D,GAAP,CAAnB;AACD;AAlCH,MADF;AAsCD,GA7CA,CADH,CADF;AAkDD;;AAED,eAAe,SAAS6B,eAAT,CAAyBC,KAAzB,EAAuC;AACpD,sBACE,oBAAC,sBAAD,qBACE,oBAAC,oBAAD,EAA0BA,KAA1B,CADF,CADF;AAKD;AAED,MAAMzE,MAAM,GAAG7B,UAAU,CAACuG,MAAX,CAAkB;AAC/BzE,EAAAA,SAAS,EAAE;AACT0E,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 type { ScreenProps } from 'react-native-screens';\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: ScreenProps['onDismissed'];\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 <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false\n ? headerHeight\n : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\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 ) : (\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 </NavigationRouteContext.Provider>\n </NavigationContext.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={(event) => {\n navigation.dispatch({\n ...StackActions.pop(event.nativeEvent.dismissCount),\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","nextDescriptor","index","onWillDisappear","onAppear","onDisappear","onDismissed","navigation","render","animationDuration","animationTypeForReplace","gestureEnabled","autoHideHomeIndicator","navigationBarColor","navigationBarHidden","orientation","statusBarAnimation","statusBarHidden","statusBarStyle","statusBarTranslucent","statusBarColor","animation","customAnimationOnGesture","fullScreenGestureEnabled","gestureDirection","nextGestureDirection","gestureDirectionOverride","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","nextKey","emit","type","data","closing","target","event","dispatch","pop","dismissCount","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;AAKA,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,eAAe,GAAGZ,SAAS,GAC7B,KAD6B,GAE7BK,YAAY,KAAK,MAAjB,IAA2BK,WAAW,KAAK,I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AAX,CAAkB;AAC/BpF,EAAAA,SAAS,EAAE;AACTqF,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 type { ScreenProps } from 'react-native-screens';\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 nextDescriptor?: NativeStackDescriptor;\n onWillDisappear: () => void;\n onAppear: () => void;\n onDisappear: () => void;\n onDismissed: ScreenProps['onDismissed'];\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n nextDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n animationDuration,\n animationTypeForReplace = 'push',\n gestureEnabled,\n header,\n headerShown,\n autoHideHomeIndicator,\n navigationBarColor,\n navigationBarHidden,\n orientation,\n statusBarAnimation,\n statusBarHidden,\n statusBarStyle,\n statusBarTranslucent,\n statusBarColor,\n } = options;\n\n let {\n animation,\n customAnimationOnGesture,\n fullScreenGestureEnabled,\n presentation = 'card',\n gestureDirection = presentation === 'card' ? 'horizontal' : 'vertical',\n } = options;\n\n if (gestureDirection === 'vertical' && Platform.OS === 'ios') {\n // for `vertical` direction to work, we need to set `fullScreenGestureEnabled` to `true`\n // so the screen can be dismissed from any point on screen.\n // `customAnimationOnGesture` needs to be set to `true` so the `animation` set by user can be used,\n // otherwise `simple_push` will be used.\n // Also, the default animation for this direction seems to be `slide_from_bottom`.\n if (fullScreenGestureEnabled === undefined) {\n fullScreenGestureEnabled = true;\n }\n if (customAnimationOnGesture === undefined) {\n customAnimationOnGesture = true;\n }\n if (animation === undefined) {\n animation = 'slide_from_bottom';\n }\n }\n\n // workaround for rn-screens where gestureDirection has to be set on both\n // current and previous screen - software-mansion/react-native-screens/pull/1509\n const nextGestureDirection = nextDescriptor?.options.gestureDirection;\n const gestureDirectionOverride =\n nextGestureDirection != null ? nextGestureDirection : gestureDirection;\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 homeIndicatorHidden={autoHideHomeIndicator}\n navigationBarColor={navigationBarColor}\n navigationBarHidden={navigationBarHidden}\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 statusBarColor={statusBarColor}\n statusBarTranslucent={statusBarTranslucent}\n swipeDirection={gestureDirectionOverride}\n transitionDuration={animationDuration}\n onWillDisappear={onWillDisappear}\n onAppear={onAppear}\n onDisappear={onDisappear}\n onDismissed={onDismissed}\n isNativeStack\n >\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n <HeaderShownContext.Provider\n value={isParentHeaderShown || isHeaderInPush !== false}\n >\n <HeaderHeightContext.Provider\n value={\n isHeaderInPush !== false\n ? headerHeight\n : parentHeaderHeight ?? 0\n }\n >\n {header !== undefined && headerShown !== false ? (\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 ) : (\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 </NavigationRouteContext.Provider>\n </NavigationContext.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 nextKey = state.routes[index + 1]?.key;\n const previousDescriptor = previousKey\n ? descriptors[previousKey]\n : undefined;\n const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;\n\n return (\n <SceneView\n key={route.key}\n index={index}\n descriptor={descriptor}\n previousDescriptor={previousDescriptor}\n nextDescriptor={nextDescriptor}\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={(event) => {\n navigation.dispatch({\n ...StackActions.pop(event.nativeEvent.dismissCount),\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"]}
|
|
@@ -280,6 +280,24 @@ export declare type NativeStackNavigationOptions = {
|
|
|
280
280
|
* @platform ios
|
|
281
281
|
*/
|
|
282
282
|
headerBackButtonMenuEnabled?: boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Whether the home indicator should prefer to stay hidden on this screen. Defaults to `false`.
|
|
285
|
+
*
|
|
286
|
+
* @platform ios
|
|
287
|
+
*/
|
|
288
|
+
autoHideHomeIndicator?: boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Sets the navigation bar color. Defaults to initial navigation bar color.
|
|
291
|
+
*
|
|
292
|
+
* @platform android
|
|
293
|
+
*/
|
|
294
|
+
navigationBarColor?: string;
|
|
295
|
+
/**
|
|
296
|
+
* Sets the visibility of the navigation bar. Defaults to `false`.
|
|
297
|
+
*
|
|
298
|
+
* @platform android
|
|
299
|
+
*/
|
|
300
|
+
navigationBarHidden?: boolean;
|
|
283
301
|
/**
|
|
284
302
|
* Sets the status bar animation (similar to the `StatusBar` component).
|
|
285
303
|
* Requires setting `View controller-based status bar appearance -> YES` (or removing the config) in your `Info.plist` file.
|
|
@@ -289,6 +307,12 @@ export declare type NativeStackNavigationOptions = {
|
|
|
289
307
|
* @platform ios
|
|
290
308
|
*/
|
|
291
309
|
statusBarAnimation?: ScreenProps['statusBarAnimation'];
|
|
310
|
+
/**
|
|
311
|
+
* Sets the status bar color (similar to the `StatusBar` component). Defaults to initial status bar color.
|
|
312
|
+
*
|
|
313
|
+
* @platform android
|
|
314
|
+
*/
|
|
315
|
+
statusBarColor?: string;
|
|
292
316
|
/**
|
|
293
317
|
* Whether the status bar should be hidden on this screen.
|
|
294
318
|
* Requires setting `View controller-based status bar appearance -> YES` in your Info.plist file.
|
|
@@ -307,6 +331,23 @@ export declare type NativeStackNavigationOptions = {
|
|
|
307
331
|
* @platform ios
|
|
308
332
|
*/
|
|
309
333
|
statusBarStyle?: ScreenProps['statusBarStyle'];
|
|
334
|
+
/**
|
|
335
|
+
* Sets the translucency of the status bar. Defaults to `false`.
|
|
336
|
+
*
|
|
337
|
+
* @platform android
|
|
338
|
+
*/
|
|
339
|
+
statusBarTranslucent?: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Sets the direction in which you should swipe to dismiss the screen.
|
|
342
|
+
* When using `vertical` option, options `fullScreenGestureEnabled: true`, `customAnimationOnGesture: true` and `animation: 'slide_from_bottom'` are set by default.
|
|
343
|
+
*
|
|
344
|
+
* Supported values:
|
|
345
|
+
* - `vertical` – dismiss screen vertically
|
|
346
|
+
* - `horizontal` – dismiss screen horizontally (default)
|
|
347
|
+
*
|
|
348
|
+
* @platform ios
|
|
349
|
+
*/
|
|
350
|
+
gestureDirection?: ScreenProps['swipeDirection'];
|
|
310
351
|
/**
|
|
311
352
|
* Style object for the scene content.
|
|
312
353
|
*/
|
|
@@ -363,6 +404,13 @@ export declare type NativeStackNavigationOptions = {
|
|
|
363
404
|
* Only supported on iOS and Android.
|
|
364
405
|
*/
|
|
365
406
|
animation?: ScreenProps['stackAnimation'];
|
|
407
|
+
/**
|
|
408
|
+
* Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
|
|
409
|
+
* The duration of `default` and `flip` transitions isn't customizable.
|
|
410
|
+
*
|
|
411
|
+
* @platform ios
|
|
412
|
+
*/
|
|
413
|
+
animationDuration?: number;
|
|
366
414
|
/**
|
|
367
415
|
* How should the screen be presented.
|
|
368
416
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-navigation/native-stack",
|
|
3
3
|
"description": "Native stack navigator using react-native-screens",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.7.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native-component",
|
|
7
7
|
"react-component",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"clean": "del lib"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@react-navigation/elements": "^1.3.
|
|
44
|
+
"@react-navigation/elements": "^1.3.4",
|
|
45
45
|
"warn-once": "^0.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@react-navigation/native": "^6.0.
|
|
48
|
+
"@react-navigation/native": "^6.0.11",
|
|
49
49
|
"@testing-library/react-native": "^7.2.0",
|
|
50
|
-
"@types/react": "^17.0.
|
|
51
|
-
"@types/react-native": "~0.
|
|
52
|
-
"react": "17.0.
|
|
53
|
-
"react-native": "~0.
|
|
50
|
+
"@types/react": "^17.0.47",
|
|
51
|
+
"@types/react-native": "~0.68.1",
|
|
52
|
+
"react": "17.0.2",
|
|
53
|
+
"react-native": "~0.68.2",
|
|
54
54
|
"react-native-builder-bob": "^0.18.1",
|
|
55
|
-
"react-native-screens": "^3.
|
|
56
|
-
"typescript": "^4.
|
|
55
|
+
"react-native-screens": "^3.11.1",
|
|
56
|
+
"typescript": "^4.7.4"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@react-navigation/native": "^6.0.0",
|
|
@@ -75,6 +75,5 @@
|
|
|
75
75
|
}
|
|
76
76
|
]
|
|
77
77
|
]
|
|
78
|
-
}
|
|
79
|
-
"gitHead": "c5ef6b5e88426e658123ea8590da583314b9001e"
|
|
78
|
+
}
|
|
80
79
|
}
|
package/src/types.tsx
CHANGED
|
@@ -324,6 +324,24 @@ export type NativeStackNavigationOptions = {
|
|
|
324
324
|
* @platform ios
|
|
325
325
|
*/
|
|
326
326
|
headerBackButtonMenuEnabled?: boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Whether the home indicator should prefer to stay hidden on this screen. Defaults to `false`.
|
|
329
|
+
*
|
|
330
|
+
* @platform ios
|
|
331
|
+
*/
|
|
332
|
+
autoHideHomeIndicator?: boolean;
|
|
333
|
+
/**
|
|
334
|
+
* Sets the navigation bar color. Defaults to initial navigation bar color.
|
|
335
|
+
*
|
|
336
|
+
* @platform android
|
|
337
|
+
*/
|
|
338
|
+
navigationBarColor?: string;
|
|
339
|
+
/**
|
|
340
|
+
* Sets the visibility of the navigation bar. Defaults to `false`.
|
|
341
|
+
*
|
|
342
|
+
* @platform android
|
|
343
|
+
*/
|
|
344
|
+
navigationBarHidden?: boolean;
|
|
327
345
|
/**
|
|
328
346
|
* Sets the status bar animation (similar to the `StatusBar` component).
|
|
329
347
|
* Requires setting `View controller-based status bar appearance -> YES` (or removing the config) in your `Info.plist` file.
|
|
@@ -333,6 +351,12 @@ export type NativeStackNavigationOptions = {
|
|
|
333
351
|
* @platform ios
|
|
334
352
|
*/
|
|
335
353
|
statusBarAnimation?: ScreenProps['statusBarAnimation'];
|
|
354
|
+
/**
|
|
355
|
+
* Sets the status bar color (similar to the `StatusBar` component). Defaults to initial status bar color.
|
|
356
|
+
*
|
|
357
|
+
* @platform android
|
|
358
|
+
*/
|
|
359
|
+
statusBarColor?: string;
|
|
336
360
|
/**
|
|
337
361
|
* Whether the status bar should be hidden on this screen.
|
|
338
362
|
* Requires setting `View controller-based status bar appearance -> YES` in your Info.plist file.
|
|
@@ -351,6 +375,23 @@ export type NativeStackNavigationOptions = {
|
|
|
351
375
|
* @platform ios
|
|
352
376
|
*/
|
|
353
377
|
statusBarStyle?: ScreenProps['statusBarStyle'];
|
|
378
|
+
/**
|
|
379
|
+
* Sets the translucency of the status bar. Defaults to `false`.
|
|
380
|
+
*
|
|
381
|
+
* @platform android
|
|
382
|
+
*/
|
|
383
|
+
statusBarTranslucent?: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Sets the direction in which you should swipe to dismiss the screen.
|
|
386
|
+
* When using `vertical` option, options `fullScreenGestureEnabled: true`, `customAnimationOnGesture: true` and `animation: 'slide_from_bottom'` are set by default.
|
|
387
|
+
*
|
|
388
|
+
* Supported values:
|
|
389
|
+
* - `vertical` – dismiss screen vertically
|
|
390
|
+
* - `horizontal` – dismiss screen horizontally (default)
|
|
391
|
+
*
|
|
392
|
+
* @platform ios
|
|
393
|
+
*/
|
|
394
|
+
gestureDirection?: ScreenProps['swipeDirection'];
|
|
354
395
|
/**
|
|
355
396
|
* Style object for the scene content.
|
|
356
397
|
*/
|
|
@@ -407,6 +448,13 @@ export type NativeStackNavigationOptions = {
|
|
|
407
448
|
* Only supported on iOS and Android.
|
|
408
449
|
*/
|
|
409
450
|
animation?: ScreenProps['stackAnimation'];
|
|
451
|
+
/**
|
|
452
|
+
* Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
|
|
453
|
+
* The duration of `default` and `flip` transitions isn't customizable.
|
|
454
|
+
*
|
|
455
|
+
* @platform ios
|
|
456
|
+
*/
|
|
457
|
+
animationDuration?: number;
|
|
410
458
|
/**
|
|
411
459
|
* How should the screen be presented.
|
|
412
460
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HeaderTitle } from '@react-navigation/elements';
|
|
1
|
+
import { getHeaderTitle, HeaderTitle } from '@react-navigation/elements';
|
|
2
2
|
import { Route, useTheme } from '@react-navigation/native';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import {
|
|
@@ -79,7 +79,7 @@ export default function HeaderConfig({
|
|
|
79
79
|
headerTitleStyleFlattened.fontFamily,
|
|
80
80
|
]);
|
|
81
81
|
|
|
82
|
-
const titleText = title
|
|
82
|
+
const titleText = getHeaderTitle({ title, headerTitle }, route.name);
|
|
83
83
|
const titleColor =
|
|
84
84
|
headerTitleStyleFlattened.color ?? headerTintColor ?? colors.text;
|
|
85
85
|
const titleFontSize = headerTitleStyleFlattened.fontSize;
|
|
@@ -110,7 +110,10 @@ export default function HeaderConfig({
|
|
|
110
110
|
});
|
|
111
111
|
const headerTitleElement =
|
|
112
112
|
typeof headerTitle === 'function'
|
|
113
|
-
? headerTitle({
|
|
113
|
+
? headerTitle({
|
|
114
|
+
tintColor,
|
|
115
|
+
children: titleText,
|
|
116
|
+
})
|
|
114
117
|
: null;
|
|
115
118
|
|
|
116
119
|
const supportsHeaderSearchBar =
|
|
@@ -187,7 +190,7 @@ export default function HeaderConfig({
|
|
|
187
190
|
largeTitleFontSize={headerLargeTitleStyleFlattened.fontSize}
|
|
188
191
|
largeTitleFontWeight={headerLargeTitleStyleFlattened.fontWeight}
|
|
189
192
|
largeTitleHideShadow={headerLargeTitleShadowVisible === false}
|
|
190
|
-
title={
|
|
193
|
+
title={titleText}
|
|
191
194
|
titleColor={titleColor}
|
|
192
195
|
titleFontFamily={titleFontFamily}
|
|
193
196
|
titleFontSize={titleFontSize}
|
|
@@ -111,6 +111,7 @@ type SceneViewProps = {
|
|
|
111
111
|
index: number;
|
|
112
112
|
descriptor: NativeStackDescriptor;
|
|
113
113
|
previousDescriptor?: NativeStackDescriptor;
|
|
114
|
+
nextDescriptor?: NativeStackDescriptor;
|
|
114
115
|
onWillDisappear: () => void;
|
|
115
116
|
onAppear: () => void;
|
|
116
117
|
onDisappear: () => void;
|
|
@@ -120,6 +121,7 @@ type SceneViewProps = {
|
|
|
120
121
|
const SceneView = ({
|
|
121
122
|
descriptor,
|
|
122
123
|
previousDescriptor,
|
|
124
|
+
nextDescriptor,
|
|
123
125
|
index,
|
|
124
126
|
onWillDisappear,
|
|
125
127
|
onAppear,
|
|
@@ -128,20 +130,52 @@ const SceneView = ({
|
|
|
128
130
|
}: SceneViewProps) => {
|
|
129
131
|
const { route, navigation, options, render } = descriptor;
|
|
130
132
|
const {
|
|
131
|
-
|
|
133
|
+
animationDuration,
|
|
132
134
|
animationTypeForReplace = 'push',
|
|
133
|
-
customAnimationOnGesture,
|
|
134
|
-
fullScreenGestureEnabled,
|
|
135
135
|
gestureEnabled,
|
|
136
136
|
header,
|
|
137
137
|
headerShown,
|
|
138
|
+
autoHideHomeIndicator,
|
|
139
|
+
navigationBarColor,
|
|
140
|
+
navigationBarHidden,
|
|
138
141
|
orientation,
|
|
139
142
|
statusBarAnimation,
|
|
140
143
|
statusBarHidden,
|
|
141
144
|
statusBarStyle,
|
|
145
|
+
statusBarTranslucent,
|
|
146
|
+
statusBarColor,
|
|
142
147
|
} = options;
|
|
143
148
|
|
|
144
|
-
let {
|
|
149
|
+
let {
|
|
150
|
+
animation,
|
|
151
|
+
customAnimationOnGesture,
|
|
152
|
+
fullScreenGestureEnabled,
|
|
153
|
+
presentation = 'card',
|
|
154
|
+
gestureDirection = presentation === 'card' ? 'horizontal' : 'vertical',
|
|
155
|
+
} = options;
|
|
156
|
+
|
|
157
|
+
if (gestureDirection === 'vertical' && Platform.OS === 'ios') {
|
|
158
|
+
// for `vertical` direction to work, we need to set `fullScreenGestureEnabled` to `true`
|
|
159
|
+
// so the screen can be dismissed from any point on screen.
|
|
160
|
+
// `customAnimationOnGesture` needs to be set to `true` so the `animation` set by user can be used,
|
|
161
|
+
// otherwise `simple_push` will be used.
|
|
162
|
+
// Also, the default animation for this direction seems to be `slide_from_bottom`.
|
|
163
|
+
if (fullScreenGestureEnabled === undefined) {
|
|
164
|
+
fullScreenGestureEnabled = true;
|
|
165
|
+
}
|
|
166
|
+
if (customAnimationOnGesture === undefined) {
|
|
167
|
+
customAnimationOnGesture = true;
|
|
168
|
+
}
|
|
169
|
+
if (animation === undefined) {
|
|
170
|
+
animation = 'slide_from_bottom';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// workaround for rn-screens where gestureDirection has to be set on both
|
|
175
|
+
// current and previous screen - software-mansion/react-native-screens/pull/1509
|
|
176
|
+
const nextGestureDirection = nextDescriptor?.options.gestureDirection;
|
|
177
|
+
const gestureDirectionOverride =
|
|
178
|
+
nextGestureDirection != null ? nextGestureDirection : gestureDirection;
|
|
145
179
|
|
|
146
180
|
if (index === 0) {
|
|
147
181
|
// first screen should always be treated as `card`, it resolves problems with no header animation
|
|
@@ -161,7 +195,7 @@ const SceneView = ({
|
|
|
161
195
|
|
|
162
196
|
// Modals are fullscreen in landscape only on iPhone
|
|
163
197
|
const isIPhone =
|
|
164
|
-
Platform.OS === 'ios' && !(Platform.isPad
|
|
198
|
+
Platform.OS === 'ios' && !(Platform.isPad || Platform.isTVOS);
|
|
165
199
|
const isLandscape = frame.width > frame.height;
|
|
166
200
|
|
|
167
201
|
const topInset = isModal || (isIPhone && isLandscape) ? 0 : insets.top;
|
|
@@ -190,6 +224,9 @@ const SceneView = ({
|
|
|
190
224
|
false
|
|
191
225
|
: gestureEnabled
|
|
192
226
|
}
|
|
227
|
+
homeIndicatorHidden={autoHideHomeIndicator}
|
|
228
|
+
navigationBarColor={navigationBarColor}
|
|
229
|
+
navigationBarHidden={navigationBarHidden}
|
|
193
230
|
replaceAnimation={animationTypeForReplace}
|
|
194
231
|
stackPresentation={presentation === 'card' ? 'push' : presentation}
|
|
195
232
|
stackAnimation={animation}
|
|
@@ -197,6 +234,10 @@ const SceneView = ({
|
|
|
197
234
|
statusBarAnimation={statusBarAnimation}
|
|
198
235
|
statusBarHidden={statusBarHidden}
|
|
199
236
|
statusBarStyle={statusBarStyle}
|
|
237
|
+
statusBarColor={statusBarColor}
|
|
238
|
+
statusBarTranslucent={statusBarTranslucent}
|
|
239
|
+
swipeDirection={gestureDirectionOverride}
|
|
240
|
+
transitionDuration={animationDuration}
|
|
200
241
|
onWillDisappear={onWillDisappear}
|
|
201
242
|
onAppear={onAppear}
|
|
202
243
|
onDisappear={onDisappear}
|
|
@@ -291,9 +332,11 @@ function NativeStackViewInner({ state, navigation, descriptors }: Props) {
|
|
|
291
332
|
{state.routes.map((route, index) => {
|
|
292
333
|
const descriptor = descriptors[route.key];
|
|
293
334
|
const previousKey = state.routes[index - 1]?.key;
|
|
335
|
+
const nextKey = state.routes[index + 1]?.key;
|
|
294
336
|
const previousDescriptor = previousKey
|
|
295
337
|
? descriptors[previousKey]
|
|
296
338
|
: undefined;
|
|
339
|
+
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
297
340
|
|
|
298
341
|
return (
|
|
299
342
|
<SceneView
|
|
@@ -301,6 +344,7 @@ function NativeStackViewInner({ state, navigation, descriptors }: Props) {
|
|
|
301
344
|
index={index}
|
|
302
345
|
descriptor={descriptor}
|
|
303
346
|
previousDescriptor={previousDescriptor}
|
|
347
|
+
nextDescriptor={nextDescriptor}
|
|
304
348
|
onWillDisappear={() => {
|
|
305
349
|
navigation.emit({
|
|
306
350
|
type: 'transitionStart',
|