@react-navigation/native-stack 6.6.1 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/utils/useDismissedRouteError.js +29 -0
- package/lib/commonjs/utils/useDismissedRouteError.js.map +1 -0
- package/lib/commonjs/utils/useInvalidPreventRemoveError.js +33 -0
- package/lib/commonjs/utils/useInvalidPreventRemoveError.js.map +1 -0
- package/lib/commonjs/views/HeaderConfig.js +6 -3
- package/lib/commonjs/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.js +16 -14
- package/lib/commonjs/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.native.js +99 -24
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/utils/useDismissedRouteError.js +17 -0
- package/lib/module/utils/useDismissedRouteError.js.map +1 -0
- package/lib/module/utils/useInvalidPreventRemoveError.js +20 -0
- package/lib/module/utils/useInvalidPreventRemoveError.js.map +1 -0
- package/lib/module/views/HeaderConfig.js +7 -4
- package/lib/module/views/HeaderConfig.js.map +1 -1
- package/lib/module/views/NativeStackView.js +17 -15
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +99 -26
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/lib/typescript/src/types.d.ts +48 -0
- package/lib/typescript/src/utils/useDismissedRouteError.d.ts +5 -0
- package/lib/typescript/src/utils/useInvalidPreventRemoveError.d.ts +2 -0
- package/package.json +12 -11
- package/src/types.tsx +48 -0
- package/src/utils/useDismissedRouteError.tsx +30 -0
- package/src/utils/useInvalidPreventRemoveError.tsx +31 -0
- package/src/views/HeaderConfig.tsx +8 -5
- package/src/views/NativeStackView.native.tsx +108 -32
- package/src/views/NativeStackView.tsx +27 -26
|
@@ -1,12 +1,14 @@
|
|
|
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
|
-
import { getDefaultHeaderHeight, getHeaderTitle, HeaderHeightContext, HeaderShownContext, SafeAreaProviderCompat } from '@react-navigation/elements';
|
|
4
|
-
import { NavigationContext, NavigationRouteContext, StackActions, useTheme } from '@react-navigation/native';
|
|
3
|
+
import { getDefaultHeaderHeight, getHeaderTitle, HeaderBackContext, HeaderHeightContext, HeaderShownContext, SafeAreaProviderCompat } from '@react-navigation/elements';
|
|
4
|
+
import { NavigationContext, NavigationRouteContext, StackActions, usePreventRemoveContext, useTheme } from '@react-navigation/native';
|
|
5
5
|
import * as React from 'react';
|
|
6
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';
|
|
10
|
+
import useDismissedRouteError from '../utils/useDismissedRouteError';
|
|
11
|
+
import useInvalidPreventRemoveError from '../utils/useInvalidPreventRemoveError';
|
|
10
12
|
import DebugContainer from './DebugContainer';
|
|
11
13
|
import HeaderConfig from './HeaderConfig';
|
|
12
14
|
const isAndroid = Platform.OS === 'android';
|
|
@@ -57,14 +59,19 @@ const MaybeNestedStack = _ref => {
|
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
const SceneView = _ref2 => {
|
|
62
|
+
var _preventedRoutes$rout;
|
|
63
|
+
|
|
60
64
|
let {
|
|
61
65
|
descriptor,
|
|
62
66
|
previousDescriptor,
|
|
67
|
+
nextDescriptor,
|
|
63
68
|
index,
|
|
64
69
|
onWillDisappear,
|
|
65
70
|
onAppear,
|
|
66
71
|
onDisappear,
|
|
67
|
-
onDismissed
|
|
72
|
+
onDismissed,
|
|
73
|
+
onHeaderBackButtonClicked,
|
|
74
|
+
onNativeDismissCancelled
|
|
68
75
|
} = _ref2;
|
|
69
76
|
const {
|
|
70
77
|
route,
|
|
@@ -73,22 +80,54 @@ const SceneView = _ref2 => {
|
|
|
73
80
|
render
|
|
74
81
|
} = descriptor;
|
|
75
82
|
const {
|
|
76
|
-
|
|
83
|
+
animationDuration,
|
|
77
84
|
animationTypeForReplace = 'push',
|
|
78
|
-
customAnimationOnGesture,
|
|
79
|
-
fullScreenGestureEnabled,
|
|
80
85
|
gestureEnabled,
|
|
81
86
|
header,
|
|
87
|
+
headerBackButtonMenuEnabled,
|
|
82
88
|
headerShown,
|
|
89
|
+
autoHideHomeIndicator,
|
|
90
|
+
navigationBarColor,
|
|
91
|
+
navigationBarHidden,
|
|
83
92
|
orientation,
|
|
84
93
|
statusBarAnimation,
|
|
85
94
|
statusBarHidden,
|
|
86
|
-
statusBarStyle
|
|
95
|
+
statusBarStyle,
|
|
96
|
+
statusBarTranslucent,
|
|
97
|
+
statusBarColor
|
|
87
98
|
} = options;
|
|
88
99
|
let {
|
|
89
|
-
|
|
100
|
+
animation,
|
|
101
|
+
customAnimationOnGesture,
|
|
102
|
+
fullScreenGestureEnabled,
|
|
103
|
+
presentation = 'card',
|
|
104
|
+
gestureDirection = presentation === 'card' ? 'horizontal' : 'vertical'
|
|
90
105
|
} = options;
|
|
91
106
|
|
|
107
|
+
if (gestureDirection === 'vertical' && Platform.OS === 'ios') {
|
|
108
|
+
// for `vertical` direction to work, we need to set `fullScreenGestureEnabled` to `true`
|
|
109
|
+
// so the screen can be dismissed from any point on screen.
|
|
110
|
+
// `customAnimationOnGesture` needs to be set to `true` so the `animation` set by user can be used,
|
|
111
|
+
// otherwise `simple_push` will be used.
|
|
112
|
+
// Also, the default animation for this direction seems to be `slide_from_bottom`.
|
|
113
|
+
if (fullScreenGestureEnabled === undefined) {
|
|
114
|
+
fullScreenGestureEnabled = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (customAnimationOnGesture === undefined) {
|
|
118
|
+
customAnimationOnGesture = true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (animation === undefined) {
|
|
122
|
+
animation = 'slide_from_bottom';
|
|
123
|
+
}
|
|
124
|
+
} // workaround for rn-screens where gestureDirection has to be set on both
|
|
125
|
+
// current and previous screen - software-mansion/react-native-screens/pull/1509
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
const nextGestureDirection = nextDescriptor === null || nextDescriptor === void 0 ? void 0 : nextDescriptor.options.gestureDirection;
|
|
129
|
+
const gestureDirectionOverride = nextGestureDirection != null ? nextGestureDirection : gestureDirection;
|
|
130
|
+
|
|
92
131
|
if (index === 0) {
|
|
93
132
|
// first screen should always be treated as `card`, it resolves problems with no header animation
|
|
94
133
|
// for navigator with first screen as `modal` and the next as `card`
|
|
@@ -101,14 +140,22 @@ const SceneView = _ref2 => {
|
|
|
101
140
|
|
|
102
141
|
const isModal = presentation === 'modal' || presentation === 'formSheet'; // Modals are fullscreen in landscape only on iPhone
|
|
103
142
|
|
|
104
|
-
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad
|
|
143
|
+
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad || Platform.isTVOS);
|
|
105
144
|
const isLandscape = frame.width > frame.height;
|
|
106
145
|
const topInset = isModal || isIPhone && isLandscape ? 0 : insets.top;
|
|
107
146
|
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
|
108
147
|
const parentHeaderHeight = React.useContext(HeaderHeightContext);
|
|
148
|
+
const parentHeaderBack = React.useContext(HeaderBackContext);
|
|
149
|
+
const {
|
|
150
|
+
preventedRoutes
|
|
151
|
+
} = usePreventRemoveContext();
|
|
109
152
|
const defaultHeaderHeight = getDefaultHeaderHeight(frame, isModal, topInset);
|
|
110
153
|
const [customHeaderHeight, setCustomHeaderHeight] = React.useState(defaultHeaderHeight);
|
|
111
154
|
const headerHeight = header ? customHeaderHeight : defaultHeaderHeight;
|
|
155
|
+
const headerBack = previousDescriptor ? {
|
|
156
|
+
title: getHeaderTitle(previousDescriptor.options, previousDescriptor.route.name)
|
|
157
|
+
} : parentHeaderBack;
|
|
158
|
+
const isRemovePrevented = (_preventedRoutes$rout = preventedRoutes[route.key]) === null || _preventedRoutes$rout === void 0 ? void 0 : _preventedRoutes$rout.preventRemove;
|
|
112
159
|
return /*#__PURE__*/React.createElement(Screen, {
|
|
113
160
|
key: route.key,
|
|
114
161
|
enabled: true,
|
|
@@ -118,6 +165,9 @@ const SceneView = _ref2 => {
|
|
|
118
165
|
gestureEnabled: isAndroid ? // This prop enables handling of system back gestures on Android
|
|
119
166
|
// Since we handle them in JS side, we disable this
|
|
120
167
|
false : gestureEnabled,
|
|
168
|
+
homeIndicatorHidden: autoHideHomeIndicator,
|
|
169
|
+
navigationBarColor: navigationBarColor,
|
|
170
|
+
navigationBarHidden: navigationBarHidden,
|
|
121
171
|
replaceAnimation: animationTypeForReplace,
|
|
122
172
|
stackPresentation: presentation === 'card' ? 'push' : presentation,
|
|
123
173
|
stackAnimation: animation,
|
|
@@ -125,11 +175,23 @@ const SceneView = _ref2 => {
|
|
|
125
175
|
statusBarAnimation: statusBarAnimation,
|
|
126
176
|
statusBarHidden: statusBarHidden,
|
|
127
177
|
statusBarStyle: statusBarStyle,
|
|
178
|
+
statusBarColor: statusBarColor,
|
|
179
|
+
statusBarTranslucent: statusBarTranslucent,
|
|
180
|
+
swipeDirection: gestureDirectionOverride,
|
|
181
|
+
transitionDuration: animationDuration,
|
|
128
182
|
onWillDisappear: onWillDisappear,
|
|
129
183
|
onAppear: onAppear,
|
|
130
184
|
onDisappear: onDisappear,
|
|
131
185
|
onDismissed: onDismissed,
|
|
132
|
-
isNativeStack: true
|
|
186
|
+
isNativeStack: true // Props for enabling preventing removal in native-stack
|
|
187
|
+
,
|
|
188
|
+
nativeBackButtonDismissalEnabled: false // on Android
|
|
189
|
+
// @ts-expect-error prop not publicly exported from rn-screens
|
|
190
|
+
,
|
|
191
|
+
preventNativeDismiss: isRemovePrevented // on iOS
|
|
192
|
+
,
|
|
193
|
+
onHeaderBackButtonClicked: onHeaderBackButtonClicked,
|
|
194
|
+
onNativeDismissCancelled: onNativeDismissCancelled
|
|
133
195
|
}, /*#__PURE__*/React.createElement(NavigationContext.Provider, {
|
|
134
196
|
value: navigation
|
|
135
197
|
}, /*#__PURE__*/React.createElement(NavigationRouteContext.Provider, {
|
|
@@ -143,54 +205,53 @@ const SceneView = _ref2 => {
|
|
|
143
205
|
setCustomHeaderHeight(e.nativeEvent.layout.height);
|
|
144
206
|
}
|
|
145
207
|
}, header({
|
|
146
|
-
back:
|
|
147
|
-
title: getHeaderTitle(previousDescriptor.options, previousDescriptor.route.name)
|
|
148
|
-
} : undefined,
|
|
208
|
+
back: headerBack,
|
|
149
209
|
options,
|
|
150
210
|
route,
|
|
151
211
|
navigation
|
|
152
212
|
})) : /*#__PURE__*/React.createElement(HeaderConfig, _extends({}, options, {
|
|
153
213
|
route: route,
|
|
214
|
+
headerBackButtonMenuEnabled: isRemovePrevented !== undefined ? !isRemovePrevented : headerBackButtonMenuEnabled,
|
|
154
215
|
headerShown: isHeaderInPush,
|
|
155
216
|
headerHeight: headerHeight,
|
|
156
|
-
|
|
217
|
+
headerBackTitle: options.headerBackTitle !== undefined ? options.headerBackTitle : headerBack === null || headerBack === void 0 ? void 0 : headerBack.title,
|
|
218
|
+
canGoBack: headerBack !== undefined
|
|
157
219
|
})), /*#__PURE__*/React.createElement(MaybeNestedStack, {
|
|
158
220
|
options: options,
|
|
159
221
|
route: route,
|
|
160
222
|
presentation: presentation,
|
|
161
223
|
headerHeight: headerHeight
|
|
162
|
-
},
|
|
224
|
+
}, /*#__PURE__*/React.createElement(HeaderBackContext.Provider, {
|
|
225
|
+
value: headerBack
|
|
226
|
+
}, render())))))));
|
|
163
227
|
};
|
|
164
228
|
|
|
165
229
|
function NativeStackViewInner(_ref3) {
|
|
166
|
-
var _state$routes$find;
|
|
167
|
-
|
|
168
230
|
let {
|
|
169
231
|
state,
|
|
170
232
|
navigation,
|
|
171
233
|
descriptors
|
|
172
234
|
} = _ref3;
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const message = `The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` + `This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\n\n` + `Consider using 'gestureEnabled: false' to prevent back gesture and use a custom back button with 'headerLeft' option to override the native behavior.`;
|
|
178
|
-
console.error(message);
|
|
179
|
-
}
|
|
180
|
-
}, [dismissedRouteName]);
|
|
235
|
+
const {
|
|
236
|
+
setNextDismissedKey
|
|
237
|
+
} = useDismissedRouteError(state);
|
|
238
|
+
useInvalidPreventRemoveError(descriptors);
|
|
181
239
|
return /*#__PURE__*/React.createElement(ScreenStack, {
|
|
182
240
|
style: styles.container
|
|
183
241
|
}, state.routes.map((route, index) => {
|
|
184
|
-
var _state$routes;
|
|
242
|
+
var _state$routes, _state$routes2;
|
|
185
243
|
|
|
186
244
|
const descriptor = descriptors[route.key];
|
|
187
245
|
const previousKey = (_state$routes = state.routes[index - 1]) === null || _state$routes === void 0 ? void 0 : _state$routes.key;
|
|
246
|
+
const nextKey = (_state$routes2 = state.routes[index + 1]) === null || _state$routes2 === void 0 ? void 0 : _state$routes2.key;
|
|
188
247
|
const previousDescriptor = previousKey ? descriptors[previousKey] : undefined;
|
|
248
|
+
const nextDescriptor = nextKey ? descriptors[nextKey] : undefined;
|
|
189
249
|
return /*#__PURE__*/React.createElement(SceneView, {
|
|
190
250
|
key: route.key,
|
|
191
251
|
index: index,
|
|
192
252
|
descriptor: descriptor,
|
|
193
253
|
previousDescriptor: previousDescriptor,
|
|
254
|
+
nextDescriptor: nextDescriptor,
|
|
194
255
|
onWillDisappear: () => {
|
|
195
256
|
navigation.emit({
|
|
196
257
|
type: 'transitionStart',
|
|
@@ -224,6 +285,18 @@ function NativeStackViewInner(_ref3) {
|
|
|
224
285
|
target: state.key
|
|
225
286
|
});
|
|
226
287
|
setNextDismissedKey(route.key);
|
|
288
|
+
},
|
|
289
|
+
onHeaderBackButtonClicked: () => {
|
|
290
|
+
navigation.dispatch({ ...StackActions.pop(),
|
|
291
|
+
source: route.key,
|
|
292
|
+
target: state.key
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
onNativeDismissCancelled: event => {
|
|
296
|
+
navigation.dispatch({ ...StackActions.pop(event.nativeEvent.dismissCount),
|
|
297
|
+
source: route.key,
|
|
298
|
+
target: state.key
|
|
299
|
+
});
|
|
227
300
|
}
|
|
228
301
|
});
|
|
229
302
|
}));
|
|
@@ -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,SAC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E,MAAA,WAAW,EAAE,MAAM;AACjB9B,QAAAA,UAAU,CAACiD,IAAX,CAAgB;AACdC,UAAAA,IAAI,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","HeaderBackContext","HeaderHeightContext","HeaderShownContext","SafeAreaProviderCompat","NavigationContext","NavigationRouteContext","StackActions","usePreventRemoveContext","useTheme","React","Platform","StyleSheet","View","useSafeAreaFrame","useSafeAreaInsets","Screen","ScreenStack","warnOnce","useDismissedRouteError","useInvalidPreventRemoveError","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","onHeaderBackButtonClicked","onNativeDismissCancelled","navigation","render","animationDuration","animationTypeForReplace","gestureEnabled","headerBackButtonMenuEnabled","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","parentHeaderBack","preventedRoutes","defaultHeaderHeight","customHeaderHeight","setCustomHeaderHeight","useState","headerBack","title","isRemovePrevented","key","preventRemove","e","nativeEvent","layout","back","headerBackTitle","NativeStackViewInner","state","descriptors","setNextDismissedKey","routes","map","previousKey","nextKey","emit","type","data","closing","target","event","dispatch","pop","dismissCount","source","NativeStackView","props","create","flex"],"mappings":";;AAAA,SACEA,sBADF,EAEEC,cAFF,EAGEC,iBAHF,EAIEC,mBAJF,EAKEC,kBALF,EAMEC,sBANF,QAOO,4BAPP;AAQA,SACEC,iBADF,EAEEC,sBAFF,EAKEC,YALF,EAOEC,uBAPF,EAQEC,QARF,QASO,0BATP;AAUA,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,sBAAP,MAAmC,iCAAnC;AACA,OAAOC,4BAAP,MAAyC,uCAAzC;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA,MAAMC,SAAS,GAAGZ,QAAQ,CAACa,EAAT,KAAgB,SAAlC;;AAEA,MAAMC,gBAAgB,GAAG,QAYnB;AAAA,MAZoB;AACxBC,IAAAA,OADwB;AAExBC,IAAAA,KAFwB;AAGxBC,IAAAA,YAHwB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MAAMvF,MAAM,GAAG/B,UAAU,CAACuH,MAAX,CAAkB;AAC/BvF,EAAAA,SAAS,EAAE;AACTwF,IAAAA,IAAI,EAAE;AADG;AADoB,CAAlB,CAAf","sourcesContent":["import {\n getDefaultHeaderHeight,\n getHeaderTitle,\n HeaderBackContext,\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 usePreventRemoveContext,\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 useDismissedRouteError from '../utils/useDismissedRouteError';\nimport useInvalidPreventRemoveError from '../utils/useInvalidPreventRemoveError';\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 onHeaderBackButtonClicked: () => void;\n onNativeDismissCancelled: ScreenProps['onDismissed'];\n};\n\nconst SceneView = ({\n descriptor,\n previousDescriptor,\n nextDescriptor,\n index,\n onWillDisappear,\n onAppear,\n onDisappear,\n onDismissed,\n onHeaderBackButtonClicked,\n onNativeDismissCancelled,\n}: SceneViewProps) => {\n const { route, navigation, options, render } = descriptor;\n const {\n animationDuration,\n animationTypeForReplace = 'push',\n gestureEnabled,\n header,\n headerBackButtonMenuEnabled,\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 const parentHeaderBack = React.useContext(HeaderBackContext);\n\n const { preventedRoutes } = usePreventRemoveContext();\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 const headerBack = previousDescriptor\n ? {\n title: getHeaderTitle(\n previousDescriptor.options,\n previousDescriptor.route.name\n ),\n }\n : parentHeaderBack;\n\n const isRemovePrevented = preventedRoutes[route.key]?.preventRemove;\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 // Props for enabling preventing removal in native-stack\n nativeBackButtonDismissalEnabled={false} // on Android\n // @ts-expect-error prop not publicly exported from rn-screens\n preventNativeDismiss={isRemovePrevented} // on iOS\n onHeaderBackButtonClicked={onHeaderBackButtonClicked}\n onNativeDismissCancelled={onNativeDismissCancelled}\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: headerBack,\n options,\n route,\n navigation,\n })}\n </View>\n ) : (\n <HeaderConfig\n {...options}\n route={route}\n headerBackButtonMenuEnabled={\n isRemovePrevented !== undefined\n ? !isRemovePrevented\n : headerBackButtonMenuEnabled\n }\n headerShown={isHeaderInPush}\n headerHeight={headerHeight}\n headerBackTitle={\n options.headerBackTitle !== undefined\n ? options.headerBackTitle\n : headerBack?.title\n }\n canGoBack={headerBack !== undefined}\n />\n )}\n <MaybeNestedStack\n options={options}\n route={route}\n presentation={presentation}\n headerHeight={headerHeight}\n >\n <HeaderBackContext.Provider value={headerBack}>\n {render()}\n </HeaderBackContext.Provider>\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 { setNextDismissedKey } = useDismissedRouteError(state);\n\n useInvalidPreventRemoveError(descriptors);\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 onHeaderBackButtonClicked={() => {\n navigation.dispatch({\n ...StackActions.pop(),\n source: route.key,\n target: state.key,\n });\n }}\n onNativeDismissCancelled={(event) => {\n navigation.dispatch({\n ...StackActions.pop(event.nativeEvent.dismissCount),\n source: route.key,\n target: state.key,\n });\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
|
*
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ParamListBase, StackNavigationState } from '@react-navigation/native';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export default function useInvalidPreventRemoveError(state: StackNavigationState<ParamListBase>): {
|
|
4
|
+
setNextDismissedKey: React.Dispatch<React.SetStateAction<string | null>>;
|
|
5
|
+
};
|
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.8.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native-component",
|
|
7
7
|
"react-component",
|
|
@@ -37,23 +37,24 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
|
-
"
|
|
40
|
+
"prepack": "bob build",
|
|
41
41
|
"clean": "del lib"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@react-navigation/elements": "^1.3.
|
|
44
|
+
"@react-navigation/elements": "^1.3.5",
|
|
45
45
|
"warn-once": "^0.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@react-navigation/native": "^6.0.
|
|
48
|
+
"@react-navigation/native": "^6.0.12",
|
|
49
49
|
"@testing-library/react-native": "^7.2.0",
|
|
50
|
-
"@types/react": "^17.0.
|
|
51
|
-
"@types/react-native": "~0.
|
|
52
|
-
"
|
|
53
|
-
"react
|
|
50
|
+
"@types/react": "^17.0.47",
|
|
51
|
+
"@types/react-native": "~0.68.1",
|
|
52
|
+
"del-cli": "^3.0.1",
|
|
53
|
+
"react": "17.0.2",
|
|
54
|
+
"react-native": "~0.68.2",
|
|
54
55
|
"react-native-builder-bob": "^0.18.1",
|
|
55
|
-
"react-native-screens": "^3.
|
|
56
|
-
"typescript": "^4.
|
|
56
|
+
"react-native-screens": "^3.11.1",
|
|
57
|
+
"typescript": "^4.7.4"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
60
|
"@react-navigation/native": "^6.0.0",
|
|
@@ -76,5 +77,5 @@
|
|
|
76
77
|
]
|
|
77
78
|
]
|
|
78
79
|
},
|
|
79
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "83aa392f1e13796d609c9df0afa44699ce4bacae"
|
|
80
81
|
}
|
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
|
*
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ParamListBase,
|
|
3
|
+
StackNavigationState,
|
|
4
|
+
} from '@react-navigation/native';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
|
|
7
|
+
export default function useInvalidPreventRemoveError(
|
|
8
|
+
state: StackNavigationState<ParamListBase>
|
|
9
|
+
) {
|
|
10
|
+
const [nextDismissedKey, setNextDismissedKey] = React.useState<string | null>(
|
|
11
|
+
null
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const dismissedRouteName = nextDismissedKey
|
|
15
|
+
? state.routes.find((route) => route.key === nextDismissedKey)?.name
|
|
16
|
+
: null;
|
|
17
|
+
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
if (dismissedRouteName) {
|
|
20
|
+
const message =
|
|
21
|
+
`The screen '${dismissedRouteName}' was removed natively but didn't get removed from JS state. ` +
|
|
22
|
+
`This can happen if the action was prevented in a 'beforeRemove' listener, which is not fully supported in native-stack.\n\n` +
|
|
23
|
+
`Consider using a 'usePreventRemove' hook with 'headerBackButtonMenuEnabled: false' to prevent users from natively going back multiple screens.`;
|
|
24
|
+
|
|
25
|
+
console.error(message);
|
|
26
|
+
}
|
|
27
|
+
}, [dismissedRouteName]);
|
|
28
|
+
|
|
29
|
+
return { setNextDismissedKey };
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { usePreventRemoveContext } from '@react-navigation/native';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import type { NativeStackDescriptorMap } from '../types';
|
|
5
|
+
|
|
6
|
+
export default function useInvalidPreventRemoveError(
|
|
7
|
+
descriptors: NativeStackDescriptorMap
|
|
8
|
+
) {
|
|
9
|
+
const { preventedRoutes } = usePreventRemoveContext();
|
|
10
|
+
const preventedRouteKey = Object.keys(preventedRoutes)[0];
|
|
11
|
+
const preventedDescriptor = descriptors[preventedRouteKey];
|
|
12
|
+
const isHeaderBackButtonMenuEnabledOnPreventedScreen =
|
|
13
|
+
preventedDescriptor?.options?.headerBackButtonMenuEnabled;
|
|
14
|
+
const preventedRouteName = preventedDescriptor?.route?.name;
|
|
15
|
+
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
if (
|
|
18
|
+
preventedRouteKey != null &&
|
|
19
|
+
isHeaderBackButtonMenuEnabledOnPreventedScreen
|
|
20
|
+
) {
|
|
21
|
+
const message =
|
|
22
|
+
`The screen ${preventedRouteName} uses 'usePreventRemove' hook alongside 'headerBackButtonMenuEnabled: true', which is not supported. \n\n` +
|
|
23
|
+
`Consider removing 'headerBackButtonMenuEnabled: true' from ${preventedRouteName} screen to get rid of this error.`;
|
|
24
|
+
console.error(message);
|
|
25
|
+
}
|
|
26
|
+
}, [
|
|
27
|
+
preventedRouteKey,
|
|
28
|
+
isHeaderBackButtonMenuEnabledOnPreventedScreen,
|
|
29
|
+
preventedRouteName,
|
|
30
|
+
]);
|
|
31
|
+
}
|