@react-navigation/stack 8.0.0-alpha.3 → 8.0.0-alpha.31

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.
Files changed (67) hide show
  1. package/lib/module/index.js.map +1 -1
  2. package/lib/module/navigators/createStackNavigator.js +3 -7
  3. package/lib/module/navigators/createStackNavigator.js.map +1 -1
  4. package/lib/module/utils/useCardAnimation.js +1 -1
  5. package/lib/module/utils/useCardAnimation.js.map +1 -1
  6. package/lib/module/utils/useGestureHandlerRef.js +1 -1
  7. package/lib/module/utils/useGestureHandlerRef.js.map +1 -1
  8. package/lib/module/utils/useKeyboardManager.js +50 -26
  9. package/lib/module/utils/useKeyboardManager.js.map +1 -1
  10. package/lib/module/views/Header/Header.js +2 -2
  11. package/lib/module/views/Header/Header.js.map +1 -1
  12. package/lib/module/views/Header/HeaderContainer.js +51 -17
  13. package/lib/module/views/Header/HeaderContainer.js.map +1 -1
  14. package/lib/module/views/Header/HeaderSegment.js +2 -2
  15. package/lib/module/views/Header/HeaderSegment.js.map +1 -1
  16. package/lib/module/views/Stack/Card.js +25 -20
  17. package/lib/module/views/Stack/Card.js.map +1 -1
  18. package/lib/module/views/Stack/CardContainer.js +69 -98
  19. package/lib/module/views/Stack/CardContainer.js.map +1 -1
  20. package/lib/module/views/Stack/CardStack.js +134 -116
  21. package/lib/module/views/Stack/CardStack.js.map +1 -1
  22. package/lib/module/views/Stack/StackView.js +82 -49
  23. package/lib/module/views/Stack/StackView.js.map +1 -1
  24. package/lib/typescript/src/index.d.ts +1 -1
  25. package/lib/typescript/src/index.d.ts.map +1 -1
  26. package/lib/typescript/src/navigators/createStackNavigator.d.ts +8 -14
  27. package/lib/typescript/src/navigators/createStackNavigator.d.ts.map +1 -1
  28. package/lib/typescript/src/types.d.ts +46 -53
  29. package/lib/typescript/src/types.d.ts.map +1 -1
  30. package/lib/typescript/src/utils/gestureActivationCriteria.d.ts +1 -1
  31. package/lib/typescript/src/utils/gestureActivationCriteria.d.ts.map +1 -1
  32. package/lib/typescript/src/utils/useKeyboardManager.d.ts +9 -2
  33. package/lib/typescript/src/utils/useKeyboardManager.d.ts.map +1 -1
  34. package/lib/typescript/src/views/Header/Header.d.ts +1 -1
  35. package/lib/typescript/src/views/Header/Header.d.ts.map +1 -1
  36. package/lib/typescript/src/views/Header/HeaderContainer.d.ts +7 -2
  37. package/lib/typescript/src/views/Header/HeaderContainer.d.ts.map +1 -1
  38. package/lib/typescript/src/views/Header/HeaderSegment.d.ts +2 -2
  39. package/lib/typescript/src/views/Header/HeaderSegment.d.ts.map +1 -1
  40. package/lib/typescript/src/views/Stack/Card.d.ts +3 -3
  41. package/lib/typescript/src/views/Stack/Card.d.ts.map +1 -1
  42. package/lib/typescript/src/views/Stack/CardContainer.d.ts +4 -6
  43. package/lib/typescript/src/views/Stack/CardContainer.d.ts.map +1 -1
  44. package/lib/typescript/src/views/Stack/CardStack.d.ts +4 -3
  45. package/lib/typescript/src/views/Stack/CardStack.d.ts.map +1 -1
  46. package/lib/typescript/src/views/Stack/StackView.d.ts +6 -9
  47. package/lib/typescript/src/views/Stack/StackView.d.ts.map +1 -1
  48. package/package.json +20 -22
  49. package/src/index.tsx +1 -0
  50. package/src/navigators/createStackNavigator.tsx +9 -40
  51. package/src/types.tsx +73 -73
  52. package/src/utils/gestureActivationCriteria.tsx +1 -1
  53. package/src/utils/useCardAnimation.tsx +1 -1
  54. package/src/utils/useGestureHandlerRef.tsx +1 -1
  55. package/src/utils/useKeyboardManager.tsx +67 -33
  56. package/src/views/Header/Header.tsx +2 -2
  57. package/src/views/Header/HeaderContainer.tsx +66 -20
  58. package/src/views/Header/HeaderSegment.tsx +4 -4
  59. package/src/views/Stack/Card.tsx +32 -23
  60. package/src/views/Stack/CardContainer.tsx +81 -127
  61. package/src/views/Stack/CardStack.tsx +334 -318
  62. package/src/views/Stack/StackView.tsx +138 -66
  63. package/lib/module/views/Stack/CardA11yWrapper.js +0 -43
  64. package/lib/module/views/Stack/CardA11yWrapper.js.map +0 -1
  65. package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts +0 -15
  66. package/lib/typescript/src/views/Stack/CardA11yWrapper.d.ts.map +0 -1
  67. package/src/views/Stack/CardA11yWrapper.tsx +0 -67
package/src/types.tsx CHANGED
@@ -1,9 +1,9 @@
1
1
  import type {
2
- HeaderBackButton,
3
2
  HeaderBackButtonDisplayMode,
4
3
  HeaderBackButtonProps,
5
4
  HeaderOptions,
6
5
  HeaderTitleProps,
6
+ Icon,
7
7
  } from '@react-navigation/elements';
8
8
  import type {
9
9
  DefaultNavigatorOptions,
@@ -138,12 +138,12 @@ export type SceneProgress = {
138
138
  * Progress value for the screen after this one in the stack.
139
139
  * This can be `undefined` in case the screen animating is the last one.
140
140
  */
141
- next?: Animated.AnimatedInterpolation<number>;
141
+ next?: Animated.AnimatedInterpolation<number> | undefined;
142
142
  /**
143
143
  * Progress value for the screen before this one in the stack.
144
144
  * This can be `undefined` in case the screen animating is the first one.
145
145
  */
146
- previous?: Animated.AnimatedInterpolation<number>;
146
+ previous?: Animated.AnimatedInterpolation<number> | undefined;
147
147
  };
148
148
 
149
149
  export type StackHeaderMode = 'float' | 'screen';
@@ -187,14 +187,14 @@ export type StackHeaderOptions = Omit<
187
187
  * Defaults to the previous screen's title, or "Back" if there's not enough space.
188
188
  * Use `headerBackButtonDisplayMode` to customize the behavior.
189
189
  */
190
- headerBackTitle?: string;
190
+ headerBackTitle?: string | undefined;
191
191
  /**
192
192
  * Title string used by the back button when `headerBackTitle` doesn't fit on the screen.
193
193
  * Use `headerBackButtonDisplayMode` to customize the behavior.
194
194
  *
195
195
  * Defaults to "Back".
196
196
  */
197
- headerBackTruncatedTitle?: string;
197
+ headerBackTruncatedTitle?: string | undefined;
198
198
  /**
199
199
  * How the back button displays icon and title.
200
200
  *
@@ -211,27 +211,47 @@ export type StackHeaderOptions = Omit<
211
211
  */
212
212
  headerBackTitleStyle?: StyleProp<TextStyle>;
213
213
  /**
214
- * Function which returns a React Element to display custom image in header's back button.
215
- * It receives the `tintColor` in in the options object as an argument. object.
216
- * Defaults to Image component with a the default back icon image for the platform (a chevron on iOS and an arrow on Android).
217
- */
218
- headerBackImage?: React.ComponentProps<typeof HeaderBackButton>['backImage'];
214
+ * Icon to display in the header in the back button.
215
+ *
216
+ * Supported types:
217
+ * - image: custom image source
218
+ * - sfSymbol: SF Symbol icon (iOS only)
219
+ * - materialSymbol: material symbol icon (Android only)
220
+ * - React Node: function that returns a React Element
221
+ *
222
+ * Defaults to back icon image for the platform
223
+ * - A chevron on iOS
224
+ * - An arrow on Android
225
+ *
226
+ * @example
227
+ * ```js
228
+ * headerBackIcon: {
229
+ * type: 'image',
230
+ * source: require('./back-icon.png'),
231
+ * }
232
+ * ```
233
+ */
234
+ headerBackIcon?:
235
+ | Icon
236
+ | ((props: { tintColor: ColorValue | undefined }) => React.ReactNode);
219
237
  };
220
238
 
221
239
  export type StackHeaderProps = {
222
240
  /**
223
241
  * Options for the back button.
224
242
  */
225
- back?: {
226
- /**
227
- * Title of the previous screen.
228
- */
229
- title: string | undefined;
230
- /**
231
- * The `href` to use for the anchor tag on web
232
- */
233
- href: string | undefined;
234
- };
243
+ back?:
244
+ | {
245
+ /**
246
+ * Title of the previous screen.
247
+ */
248
+ title: string | undefined;
249
+ /**
250
+ * The `href` to use for the anchor tag on web
251
+ */
252
+ href: string | undefined;
253
+ }
254
+ | undefined;
235
255
  /**
236
256
  * Animated nodes representing the progress of the animation.
237
257
  */
@@ -258,26 +278,26 @@ export type StackHeaderRightProps = {
258
278
  /**
259
279
  * Tint color for the header button.
260
280
  */
261
- tintColor?: ColorValue;
281
+ tintColor?: ColorValue | undefined;
262
282
  /**
263
283
  * Color for material ripple (Android >= 5.0 only).
264
284
  */
265
- pressColor?: ColorValue;
285
+ pressColor?: ColorValue | undefined;
266
286
  /**
267
287
  * Opacity when the button is pressed, used when ripple is not supported.
268
288
  */
269
- pressOpacity?: number;
289
+ pressOpacity?: number | undefined;
270
290
  /**
271
291
  * Whether it's possible to navigate back in stack.
272
292
  */
273
- canGoBack?: boolean;
293
+ canGoBack?: boolean | undefined;
274
294
  };
275
295
 
276
296
  export type StackHeaderLeftProps = HeaderBackButtonProps & {
277
297
  /**
278
298
  * Whether it's possible to navigate back in stack.
279
299
  */
280
- canGoBack?: boolean;
300
+ canGoBack?: boolean | undefined;
281
301
  };
282
302
 
283
303
  export type StackDescriptor = Descriptor<
@@ -326,15 +346,6 @@ export type StackNavigationOptions = StackHeaderOptions &
326
346
  /**
327
347
  * Style object for the card in stack.
328
348
  * You can provide a custom background color to use instead of the default background here.
329
- *
330
- * You can also specify `{ backgroundColor: 'transparent' }` to make the previous screen visible underneath.
331
- * This is useful to implement things like modal dialogs.
332
- *
333
- * You should also specify `detachPreviousScreen: false` in options when using a transparent background
334
- * so that the previous screen isn't detached and stays below the current screen.
335
- *
336
- * You might also need to change the animation of the screen using `cardStyleInterpolator`
337
- * so that the previous screen isn't transformed or invisible.
338
349
  */
339
350
  cardStyle?: StyleProp<ViewStyle>;
340
351
  /**
@@ -348,7 +359,6 @@ export type StackNavigationOptions = StackHeaderOptions &
348
359
  * - `transparentModal`: Similar to `modal`. This changes following things:
349
360
  * - Sets `headerMode` to `screen` for the screen unless specified otherwise.
350
361
  * - Sets background color of the screen to transparent, so previous screen is visible
351
- * - Adjusts the `detachPreviousScreen` option so that the previous screen stays rendered.
352
362
  * - Prevents the previous screen from animating from its last position.
353
363
  * - Changes the screen animation to a vertical slide animation.
354
364
  *
@@ -390,43 +400,29 @@ export type StackNavigationOptions = StackHeaderOptions &
390
400
  * Not supported on Web.
391
401
  */
392
402
  gestureVelocityImpact?: number;
393
- /**
394
- * Whether to detach the previous screen from the view hierarchy to save memory.
395
- * Set it to `false` if you need the previous screen to be seen through the active screen.
396
- * Only applicable if `detachInactiveScreens` isn't set to `false`.
397
- * Defaults to `false` for the last screen for modals, otherwise `true`.
398
- */
399
- detachPreviousScreen?: boolean;
400
403
  /**
401
404
  * If `false`, the keyboard will NOT automatically dismiss when navigating to a new screen from this screen.
402
405
  * Defaults to `true`.
403
406
  */
404
407
  keyboardHandlingEnabled?: boolean;
408
+
405
409
  /**
406
- * Whether inactive screens should be suspended from re-rendering. Defaults to `false`.
407
- * Defaults to `true` when `enableFreeze()` is run at the top of the application.
408
- * Requires `react-native-screens` version >=3.16.0.
410
+ * What should happen when screens become inactive.
411
+ * - `pause`: Effects are cleaned up
412
+ * - `unmount`: Screen is unmounted
413
+ * - `none`: Screen renders normally
409
414
  *
410
- * Only supported on iOS and Android.
411
- */
412
- freezeOnBlur?: boolean;
413
- /**
414
- * Whether the home indicator should prefer to stay hidden on this screen. Defaults to `false`.
415
+ * Defaults to `pause`.
415
416
  *
416
- * @platform ios
417
+ * Preloaded screens won't be paused until after navigated to.
418
+ * This makes sure that effects are run to initialize the screen.
419
+ *
420
+ * Screens with nested navigators and last 2 screens won't be unmounted.
417
421
  */
418
- autoHideHomeIndicator?: boolean;
422
+ inactiveBehavior?: 'pause' | 'unmount' | 'none' | undefined;
419
423
  };
420
424
 
421
- export type StackNavigationConfig = {
422
- /**
423
- * Whether inactive screens should be detached from the view hierarchy to save memory.
424
- * This will have no effect if you disable `react-native-screens`.
425
- *
426
- * Defaults to `true`.
427
- */
428
- detachInactiveScreens?: boolean;
429
- };
425
+ export type StackNavigationConfig = {};
430
426
 
431
427
  export type TransitionSpec =
432
428
  | {
@@ -458,12 +454,14 @@ export type StackCardInterpolationProps = {
458
454
  * Values for the screen after this one in the stack.
459
455
  * This can be `undefined` in case the screen animating is the last one.
460
456
  */
461
- next?: {
462
- /**
463
- * Animated node representing the progress value of the next screen.
464
- */
465
- progress: Animated.AnimatedInterpolation<number>;
466
- };
457
+ next?:
458
+ | {
459
+ /**
460
+ * Animated node representing the progress value of the next screen.
461
+ */
462
+ progress: Animated.AnimatedInterpolation<number>;
463
+ }
464
+ | undefined;
467
465
  /**
468
466
  * The index of the card with this interpolation in the stack.
469
467
  */
@@ -537,12 +535,14 @@ export type StackHeaderInterpolationProps = {
537
535
  * Values for the screen after this one in the stack.
538
536
  * This can be `undefined` in case the screen animating is the last one.
539
537
  */
540
- next?: {
541
- /**
542
- * Animated node representing the progress value of the next screen.
543
- */
544
- progress: Animated.AnimatedInterpolation<number>;
545
- };
538
+ next?:
539
+ | {
540
+ /**
541
+ * Animated node representing the progress value of the next screen.
542
+ */
543
+ progress: Animated.AnimatedInterpolation<number>;
544
+ }
545
+ | undefined;
546
546
  /**
547
547
  * Writing direction of the layout.
548
548
  */
@@ -17,7 +17,7 @@ export const gestureActivationCriteria = ({
17
17
  }: {
18
18
  direction: LocaleDirection;
19
19
  gestureDirection: GestureDirection;
20
- gestureResponseDistance?: number;
20
+ gestureResponseDistance?: number | undefined;
21
21
  layout: Layout;
22
22
  }) => {
23
23
  const enableTrackpadTwoFingerGesture = true;
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { CardAnimationContext } from './CardAnimationContext';
4
4
 
5
5
  export function useCardAnimation() {
6
- const animation = React.useContext(CardAnimationContext);
6
+ const animation = React.use(CardAnimationContext);
7
7
 
8
8
  if (animation === undefined) {
9
9
  throw new Error(
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { GestureHandlerRefContext } from './GestureHandlerRefContext';
4
4
 
5
5
  export function useGestureHandlerRef() {
6
- const ref = React.useContext(GestureHandlerRefContext);
6
+ const ref = React.use(GestureHandlerRefContext);
7
7
 
8
8
  if (ref === undefined) {
9
9
  throw new Error(
@@ -1,12 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import { type HostInstance, Keyboard, TextInput } from 'react-native';
3
3
 
4
- export function useKeyboardManager(isEnabled: () => boolean) {
4
+ export function useKeyboardManager({
5
+ enabled,
6
+ focused,
7
+ }: {
8
+ enabled: boolean;
9
+ focused: boolean;
10
+ }) {
5
11
  // Numeric id of the previously focused text input
6
12
  // When a gesture didn't change the tab, we can restore the focused input with this
7
13
  const previouslyFocusedTextInputRef = React.useRef<HostInstance>(undefined);
8
14
  const startTimestampRef = React.useRef<number>(0);
9
- const keyboardTimeoutRef = React.useRef<NodeJS.Timeout>(undefined);
15
+ const keyboardTimeoutRef =
16
+ React.useRef<ReturnType<typeof setTimeout>>(undefined);
17
+ const enabledRef = React.useRef(enabled);
10
18
 
11
19
  const clearKeyboardTimeout = React.useCallback(() => {
12
20
  if (keyboardTimeoutRef.current !== undefined) {
@@ -16,7 +24,7 @@ export function useKeyboardManager(isEnabled: () => boolean) {
16
24
  }, []);
17
25
 
18
26
  const onPageChangeStart = React.useCallback(() => {
19
- if (!isEnabled()) {
27
+ if (!enabledRef.current) {
20
28
  return;
21
29
  }
22
30
 
@@ -32,37 +40,10 @@ export function useKeyboardManager(isEnabled: () => boolean) {
32
40
 
33
41
  // Store timestamp for touch start
34
42
  startTimestampRef.current = Date.now();
35
- }, [clearKeyboardTimeout, isEnabled]);
36
-
37
- const onPageChangeConfirm = React.useCallback(
38
- (force: boolean) => {
39
- if (!isEnabled()) {
40
- return;
41
- }
42
-
43
- clearKeyboardTimeout();
44
-
45
- if (force) {
46
- // Always dismiss input, even if we don't have a ref to it
47
- // We might not have the ref if onPageChangeStart was never called
48
- // This can happen if page change was not from a gesture
49
- Keyboard.dismiss();
50
- } else {
51
- const input = previouslyFocusedTextInputRef.current;
52
-
53
- // Dismiss the keyboard only if an input was a focused before
54
- // This makes sure we don't dismiss input on going back and focusing an input
55
- input?.blur();
56
- }
57
-
58
- // Cleanup the ID on successful page change
59
- previouslyFocusedTextInputRef.current = undefined;
60
- },
61
- [clearKeyboardTimeout, isEnabled]
62
- );
43
+ }, [clearKeyboardTimeout]);
63
44
 
64
45
  const onPageChangeCancel = React.useCallback(() => {
65
- if (!isEnabled()) {
46
+ if (!enabledRef.current) {
66
47
  return;
67
48
  }
68
49
 
@@ -89,7 +70,60 @@ export function useKeyboardManager(isEnabled: () => boolean) {
89
70
  previouslyFocusedTextInputRef.current = undefined;
90
71
  }
91
72
  }
92
- }, [clearKeyboardTimeout, isEnabled]);
73
+ }, [clearKeyboardTimeout]);
74
+
75
+ const onPageChangeConfirm = React.useCallback(
76
+ ({
77
+ gesture,
78
+ active,
79
+ closing,
80
+ }: {
81
+ gesture: boolean;
82
+ active: boolean;
83
+ closing: boolean;
84
+ }) => {
85
+ if (!enabledRef.current) {
86
+ return;
87
+ }
88
+
89
+ if (!closing) {
90
+ onPageChangeCancel();
91
+ return;
92
+ }
93
+
94
+ clearKeyboardTimeout();
95
+
96
+ if (!gesture) {
97
+ // Always dismiss input, even if we don't have a ref to it
98
+ // We might not have the ref if onPageChangeStart was never called
99
+ // This can happen if page change was not from a gesture
100
+ Keyboard.dismiss();
101
+ } else if (active) {
102
+ const input = previouslyFocusedTextInputRef.current;
103
+
104
+ // Dismiss the keyboard only if an input was a focused before
105
+ // This makes sure we don't dismiss input on going back and focusing an input
106
+ input?.blur();
107
+ }
108
+
109
+ // Cleanup the ID on successful page change
110
+ previouslyFocusedTextInputRef.current = undefined;
111
+ },
112
+ [clearKeyboardTimeout, onPageChangeCancel]
113
+ );
114
+
115
+ // Dismiss keyboard when screen loses focus (e.g. when pushing a new screen).
116
+ // This handles the "navigate forward" case so we don't dismiss the new screen's
117
+ // auto-focused input from handleTransition.
118
+ React.useLayoutEffect(() => {
119
+ if (enabledRef.current && !focused) {
120
+ Keyboard.dismiss();
121
+ }
122
+ }, [focused]);
123
+
124
+ React.useLayoutEffect(() => {
125
+ enabledRef.current = enabled;
126
+ });
93
127
 
94
128
  React.useEffect(() => {
95
129
  return () => clearKeyboardTimeout();
@@ -41,8 +41,8 @@ export const Header = React.memo(function Header({
41
41
  [navigation, route.key]
42
42
  );
43
43
 
44
- const isModal = React.useContext(ModalPresentationContext);
45
- const isParentHeaderShown = React.useContext(HeaderShownContext);
44
+ const isModal = React.use(ModalPresentationContext);
45
+ const isParentHeaderShown = React.use(HeaderShownContext);
46
46
 
47
47
  const statusBarHeight =
48
48
  options.headerStatusBarHeight !== undefined
@@ -1,4 +1,5 @@
1
1
  import { getHeaderTitle, HeaderBackContext } from '@react-navigation/elements';
2
+ import { ActivityView } from '@react-navigation/elements/internal';
2
3
  import {
3
4
  NavigationProvider,
4
5
  type ParamListBase,
@@ -6,7 +7,13 @@ import {
6
7
  useLinkBuilder,
7
8
  } from '@react-navigation/native';
8
9
  import * as React from 'react';
9
- import { type StyleProp, StyleSheet, View, type ViewStyle } from 'react-native';
10
+ import {
11
+ type LayoutChangeEvent,
12
+ type StyleProp,
13
+ StyleSheet,
14
+ View,
15
+ type ViewStyle,
16
+ } from 'react-native';
10
17
 
11
18
  import {
12
19
  forNoAnimation,
@@ -22,12 +29,18 @@ import type {
22
29
  } from '../../types';
23
30
  import { Header } from './Header';
24
31
 
32
+ export type HeaderHeight = {
33
+ measured: boolean;
34
+ value: number;
35
+ };
36
+
25
37
  export type Props = {
26
38
  mode: StackHeaderMode;
27
39
  scenes: (Scene | undefined)[];
28
40
  getPreviousScene: (props: { route: Route<string> }) => Scene | undefined;
29
41
  getFocusedRoute: () => Route<string>;
30
- onContentHeightChange?: (props: {
42
+ contentHeight: HeaderHeight | undefined;
43
+ onContentHeightChange: (props: {
31
44
  route: Route<string>;
32
45
  height: number;
33
46
  }) => void;
@@ -39,11 +52,12 @@ export function HeaderContainer({
39
52
  scenes,
40
53
  getPreviousScene,
41
54
  getFocusedRoute,
55
+ contentHeight,
42
56
  onContentHeightChange,
43
57
  style,
44
58
  }: Props) {
45
59
  const focusedRoute = getFocusedRoute();
46
- const parentHeaderBack = React.useContext(HeaderBackContext);
60
+ const parentHeaderBack = React.use(HeaderBackContext);
47
61
  const { buildHref } = useLinkBuilder();
48
62
 
49
63
  return (
@@ -96,6 +110,9 @@ export function HeaderContainer({
96
110
  headerMode: previousHeaderMode,
97
111
  } = previousDescriptor?.options || {};
98
112
 
113
+ const { headerTransparent: nextHeaderTransparent } =
114
+ nextDescriptor?.options || {};
115
+
99
116
  // If any of the next screens don't have a header or header is part of the screen
100
117
  // Then we need to move this header offscreen so that it doesn't cover it
101
118
  const nextHeaderlessScene = self.slice(i + 1).find((scene) => {
@@ -115,6 +132,9 @@ export function HeaderContainer({
115
132
  // We still need to animate when coming back from next scene
116
133
  // A hacky way to check this is if the next scene exists
117
134
  !nextDescriptor) ||
135
+ // If next header is tranparent, we want to treat this header as static
136
+ // Otherwise it may show through the next header
137
+ nextHeaderTransparent ||
118
138
  nextHeaderlessScene;
119
139
 
120
140
  const props: StackHeaderProps = {
@@ -137,6 +157,26 @@ export function HeaderContainer({
137
157
  : forNoAnimation,
138
158
  };
139
159
 
160
+ const onRef = (node: View | null) => {
161
+ node?.measure((_x, _y, _width, height) => {
162
+ if (height && !contentHeight?.measured) {
163
+ onContentHeightChange({
164
+ route: scene.descriptor.route,
165
+ height,
166
+ });
167
+ }
168
+ });
169
+ };
170
+
171
+ const onLayout = (e: LayoutChangeEvent) => {
172
+ const { height } = e.nativeEvent.layout;
173
+
174
+ onContentHeightChange({
175
+ route: scene.descriptor.route,
176
+ height,
177
+ });
178
+ };
179
+
140
180
  return (
141
181
  <NavigationProvider
142
182
  key={scene.descriptor.route.key}
@@ -144,31 +184,37 @@ export function HeaderContainer({
144
184
  route={scene.descriptor.route}
145
185
  >
146
186
  <View
147
- onLayout={
148
- onContentHeightChange
149
- ? (e) => {
150
- const { height } = e.nativeEvent.layout;
151
-
152
- onContentHeightChange({
153
- route: scene.descriptor.route,
154
- height,
155
- });
156
- }
157
- : undefined
158
- }
159
- aria-hidden={!isFocused}
160
187
  style={[
161
- // Avoid positioning the focused header absolutely
188
+ // Avoid absolutely positioning the focused header unnecessarily
162
189
  // Otherwise accessibility tools don't seem to be able to find it
163
190
  (mode === 'float' && !isFocused) || headerTransparent
164
- ? styles.header
191
+ ? [
192
+ styles.absolute,
193
+ mode === 'screen'
194
+ ? // For transparent headers, specify a min height
195
+ // This is needed for screen readers, and testing tools on Android
196
+ // For float header, it's handled in CardStack
197
+ { minHeight: contentHeight?.value }
198
+ : null,
199
+ ]
165
200
  : null,
166
201
  {
167
202
  pointerEvents: isFocused ? 'box-none' : 'none',
168
203
  },
169
204
  ]}
170
205
  >
171
- {header !== undefined ? header(props) : <Header {...props} />}
206
+ <View
207
+ ref={onRef}
208
+ onLayout={onLayout}
209
+ style={{ pointerEvents: 'box-none' }}
210
+ >
211
+ <ActivityView
212
+ mode={isFocused ? 'normal' : 'inert'}
213
+ visible={true}
214
+ >
215
+ {header !== undefined ? header(props) : <Header {...props} />}
216
+ </ActivityView>
217
+ </View>
172
218
  </View>
173
219
  </NavigationProvider>
174
220
  );
@@ -181,7 +227,7 @@ const styles = StyleSheet.create({
181
227
  container: {
182
228
  pointerEvents: 'box-none',
183
229
  },
184
- header: {
230
+ absolute: {
185
231
  position: 'absolute',
186
232
  top: 0,
187
233
  start: 0,
@@ -20,8 +20,8 @@ type Props = Omit<StackHeaderOptions, 'headerStatusBarHeight'> & {
20
20
  headerStatusBarHeight: number;
21
21
  title: string;
22
22
  modal: boolean;
23
- onGoBack?: () => void;
24
- backHref?: string;
23
+ onGoBack?: (() => void) | undefined;
24
+ backHref?: string | undefined;
25
25
  progress: SceneProgress;
26
26
  styleInterpolator: StackHeaderStyleInterpolator;
27
27
  };
@@ -40,7 +40,7 @@ export function HeaderSegment(props: Props) {
40
40
  ? (props: HeaderBackButtonProps) => <HeaderBackButton {...props} />
41
41
  : undefined,
42
42
  headerRight: right,
43
- headerBackImage,
43
+ headerBackIcon,
44
44
  headerBackTitle,
45
45
  headerBackButtonDisplayMode,
46
46
  headerBackTruncatedTitle,
@@ -93,7 +93,7 @@ export function HeaderSegment(props: Props) {
93
93
  left({
94
94
  ...props,
95
95
  href: backHref,
96
- backImage: headerBackImage,
96
+ icon: headerBackIcon,
97
97
  accessibilityLabel: headerBackAccessibilityLabel,
98
98
  testID: headerBackTestID,
99
99
  allowFontScaling: headerBackAllowFontScaling,