@react-navigation/native-stack 6.9.0 → 6.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/navigators/createNativeStackNavigator.js +1 -1
- package/lib/commonjs/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/useDismissedRouteError.js.map +1 -1
- package/lib/commonjs/utils/useInvalidPreventRemoveError.js.map +1 -1
- package/lib/commonjs/views/DebugContainer.js.map +1 -1
- package/lib/commonjs/views/DebugContainer.native.js.map +1 -1
- package/lib/commonjs/views/FontProcessor.js.map +1 -1
- package/lib/commonjs/views/FontProcessor.native.js.map +1 -1
- package/lib/commonjs/views/HeaderConfig.js +1 -1
- package/lib/commonjs/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/views/NativeStackView.native.js +35 -16
- package/lib/commonjs/views/NativeStackView.native.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/navigators/createNativeStackNavigator.js +1 -1
- package/lib/module/navigators/createNativeStackNavigator.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/useDismissedRouteError.js.map +1 -1
- package/lib/module/utils/useInvalidPreventRemoveError.js.map +1 -1
- package/lib/module/views/DebugContainer.js.map +1 -1
- package/lib/module/views/DebugContainer.native.js.map +1 -1
- package/lib/module/views/FontProcessor.js.map +1 -1
- package/lib/module/views/FontProcessor.native.js.map +1 -1
- package/lib/module/views/HeaderConfig.js +1 -1
- package/lib/module/views/HeaderConfig.js.map +1 -1
- package/lib/module/views/NativeStackView.js.map +1 -1
- package/lib/module/views/NativeStackView.native.js +35 -16
- package/lib/module/views/NativeStackView.native.js.map +1 -1
- package/package.json +5 -5
- package/src/views/HeaderConfig.tsx +1 -1
- package/src/views/NativeStackView.native.tsx +72 -43
|
@@ -116,6 +116,7 @@ const MaybeNestedStack = ({
|
|
|
116
116
|
|
|
117
117
|
type SceneViewProps = {
|
|
118
118
|
index: number;
|
|
119
|
+
focused: boolean;
|
|
119
120
|
descriptor: NativeStackDescriptor;
|
|
120
121
|
previousDescriptor?: NativeStackDescriptor;
|
|
121
122
|
nextDescriptor?: NativeStackDescriptor;
|
|
@@ -128,10 +129,11 @@ type SceneViewProps = {
|
|
|
128
129
|
};
|
|
129
130
|
|
|
130
131
|
const SceneView = ({
|
|
132
|
+
index,
|
|
133
|
+
focused,
|
|
131
134
|
descriptor,
|
|
132
135
|
previousDescriptor,
|
|
133
136
|
nextDescriptor,
|
|
134
|
-
index,
|
|
135
137
|
onWillDisappear,
|
|
136
138
|
onAppear,
|
|
137
139
|
onDisappear,
|
|
@@ -147,6 +149,7 @@ const SceneView = ({
|
|
|
147
149
|
header,
|
|
148
150
|
headerBackButtonMenuEnabled,
|
|
149
151
|
headerShown,
|
|
152
|
+
headerTransparent,
|
|
150
153
|
autoHideHomeIndicator,
|
|
151
154
|
navigationBarColor,
|
|
152
155
|
navigationBarHidden,
|
|
@@ -203,8 +206,7 @@ const SceneView = ({
|
|
|
203
206
|
const isModal = presentation === 'modal' || presentation === 'formSheet';
|
|
204
207
|
|
|
205
208
|
// Modals are fullscreen in landscape only on iPhone
|
|
206
|
-
const isIPhone =
|
|
207
|
-
Platform.OS === 'ios' && !(Platform.isPad || Platform.isTVOS);
|
|
209
|
+
const isIPhone = Platform.OS === 'ios' && !(Platform.isPad || Platform.isTV);
|
|
208
210
|
const isLandscape = frame.width > frame.height;
|
|
209
211
|
|
|
210
212
|
const isParentHeaderShown = React.useContext(HeaderShownContext);
|
|
@@ -289,50 +291,65 @@ const SceneView = ({
|
|
|
289
291
|
headerShown !== false ? headerHeight : parentHeaderHeight ?? 0
|
|
290
292
|
}
|
|
291
293
|
>
|
|
292
|
-
{
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
route,
|
|
302
|
-
navigation,
|
|
303
|
-
})}
|
|
304
|
-
</View>
|
|
305
|
-
) : (
|
|
306
|
-
<HeaderConfig
|
|
307
|
-
{...options}
|
|
308
|
-
route={route}
|
|
309
|
-
headerBackButtonMenuEnabled={
|
|
310
|
-
isRemovePrevented !== undefined
|
|
311
|
-
? !isRemovePrevented
|
|
312
|
-
: headerBackButtonMenuEnabled
|
|
313
|
-
}
|
|
314
|
-
headerShown={headerShown}
|
|
315
|
-
headerHeight={headerHeight}
|
|
316
|
-
headerBackTitle={
|
|
317
|
-
options.headerBackTitle !== undefined
|
|
318
|
-
? options.headerBackTitle
|
|
319
|
-
: undefined
|
|
320
|
-
}
|
|
321
|
-
headerTopInsetEnabled={headerTopInsetEnabled}
|
|
322
|
-
canGoBack={headerBack !== undefined}
|
|
323
|
-
/>
|
|
324
|
-
)}
|
|
325
|
-
<MaybeNestedStack
|
|
326
|
-
options={options}
|
|
294
|
+
{/**
|
|
295
|
+
* `HeaderConfig` needs to be the direct child of `Screen` without any intermediate `View`
|
|
296
|
+
* We don't render it conditionally to make it possible to dynamically render a custom `header`
|
|
297
|
+
* Otherwise dynamically rendering a custom `header` leaves the native header visible
|
|
298
|
+
*
|
|
299
|
+
* https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md#screenstackheaderconfig
|
|
300
|
+
*/}
|
|
301
|
+
<HeaderConfig
|
|
302
|
+
{...options}
|
|
327
303
|
route={route}
|
|
328
|
-
|
|
304
|
+
headerBackButtonMenuEnabled={
|
|
305
|
+
isRemovePrevented !== undefined
|
|
306
|
+
? !isRemovePrevented
|
|
307
|
+
: headerBackButtonMenuEnabled
|
|
308
|
+
}
|
|
309
|
+
headerShown={header !== undefined ? false : headerShown}
|
|
329
310
|
headerHeight={headerHeight}
|
|
311
|
+
headerBackTitle={
|
|
312
|
+
options.headerBackTitle !== undefined
|
|
313
|
+
? options.headerBackTitle
|
|
314
|
+
: undefined
|
|
315
|
+
}
|
|
330
316
|
headerTopInsetEnabled={headerTopInsetEnabled}
|
|
317
|
+
canGoBack={headerBack !== undefined}
|
|
318
|
+
/>
|
|
319
|
+
<View
|
|
320
|
+
accessibilityElementsHidden={!focused}
|
|
321
|
+
importantForAccessibility={
|
|
322
|
+
focused ? 'auto' : 'no-hide-descendants'
|
|
323
|
+
}
|
|
324
|
+
style={styles.scene}
|
|
331
325
|
>
|
|
332
|
-
<
|
|
333
|
-
{
|
|
334
|
-
|
|
335
|
-
|
|
326
|
+
<MaybeNestedStack
|
|
327
|
+
options={options}
|
|
328
|
+
route={route}
|
|
329
|
+
presentation={presentation}
|
|
330
|
+
headerHeight={headerHeight}
|
|
331
|
+
headerTopInsetEnabled={headerTopInsetEnabled}
|
|
332
|
+
>
|
|
333
|
+
<HeaderBackContext.Provider value={headerBack}>
|
|
334
|
+
{render()}
|
|
335
|
+
</HeaderBackContext.Provider>
|
|
336
|
+
</MaybeNestedStack>
|
|
337
|
+
{header !== undefined && headerShown !== false ? (
|
|
338
|
+
<View
|
|
339
|
+
onLayout={(e) => {
|
|
340
|
+
setCustomHeaderHeight(e.nativeEvent.layout.height);
|
|
341
|
+
}}
|
|
342
|
+
style={headerTransparent ? styles.absolute : null}
|
|
343
|
+
>
|
|
344
|
+
{header({
|
|
345
|
+
back: headerBack,
|
|
346
|
+
options,
|
|
347
|
+
route,
|
|
348
|
+
navigation,
|
|
349
|
+
})}
|
|
350
|
+
</View>
|
|
351
|
+
) : null}
|
|
352
|
+
</View>
|
|
336
353
|
</HeaderHeightContext.Provider>
|
|
337
354
|
</HeaderShownContext.Provider>
|
|
338
355
|
</NavigationRouteContext.Provider>
|
|
@@ -356,6 +373,7 @@ function NativeStackViewInner({ state, navigation, descriptors }: Props) {
|
|
|
356
373
|
<ScreenStack style={styles.container}>
|
|
357
374
|
{state.routes.map((route, index) => {
|
|
358
375
|
const descriptor = descriptors[route.key];
|
|
376
|
+
const isFocused = state.index === index;
|
|
359
377
|
const previousKey = state.routes[index - 1]?.key;
|
|
360
378
|
const nextKey = state.routes[index + 1]?.key;
|
|
361
379
|
const previousDescriptor = previousKey
|
|
@@ -367,6 +385,7 @@ function NativeStackViewInner({ state, navigation, descriptors }: Props) {
|
|
|
367
385
|
<SceneView
|
|
368
386
|
key={route.key}
|
|
369
387
|
index={index}
|
|
388
|
+
focused={isFocused}
|
|
370
389
|
descriptor={descriptor}
|
|
371
390
|
previousDescriptor={previousDescriptor}
|
|
372
391
|
nextDescriptor={nextDescriptor}
|
|
@@ -433,4 +452,14 @@ const styles = StyleSheet.create({
|
|
|
433
452
|
container: {
|
|
434
453
|
flex: 1,
|
|
435
454
|
},
|
|
455
|
+
scene: {
|
|
456
|
+
flex: 1,
|
|
457
|
+
flexDirection: 'column-reverse',
|
|
458
|
+
},
|
|
459
|
+
absolute: {
|
|
460
|
+
position: 'absolute',
|
|
461
|
+
top: 0,
|
|
462
|
+
left: 0,
|
|
463
|
+
right: 0,
|
|
464
|
+
},
|
|
436
465
|
});
|