@react-navigation/native-stack 7.1.3 → 7.1.5

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.
@@ -68,6 +68,8 @@ type SceneViewProps = {
68
68
  onSheetDetentChanged: ScreenProps['onSheetDetentChanged'];
69
69
  };
70
70
 
71
+ const useNativeDriver = Platform.OS !== 'web';
72
+
71
73
  const SceneView = ({
72
74
  index,
73
75
  focused,
@@ -273,123 +275,125 @@ const SceneView = ({
273
275
  });
274
276
 
275
277
  return (
276
- <ScreenStackItem
277
- key={route.key}
278
- screenId={route.key}
279
- activityState={isPreloaded ? 0 : 2}
280
- style={StyleSheet.absoluteFill}
281
- accessibilityElementsHidden={!focused}
282
- importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}
283
- customAnimationOnSwipe={animationMatchesGesture}
284
- fullScreenSwipeEnabled={fullScreenGestureEnabled}
285
- fullScreenSwipeShadowEnabled={fullScreenGestureShadowEnabled}
286
- freezeOnBlur={freezeOnBlur}
287
- gestureEnabled={
288
- Platform.OS === 'android'
289
- ? // This prop enables handling of system back gestures on Android
290
- // Since we handle them in JS side, we disable this
291
- false
292
- : gestureEnabled
293
- }
294
- homeIndicatorHidden={autoHideHomeIndicator}
295
- hideKeyboardOnSwipe={keyboardHandlingEnabled}
296
- navigationBarColor={navigationBarColor}
297
- navigationBarTranslucent={navigationBarTranslucent}
298
- navigationBarHidden={navigationBarHidden}
299
- replaceAnimation={animationTypeForReplace}
300
- stackPresentation={presentation === 'card' ? 'push' : presentation}
301
- stackAnimation={animation}
302
- screenOrientation={orientation}
303
- sheetAllowedDetents={sheetAllowedDetents}
304
- sheetLargestUndimmedDetentIndex={sheetLargestUndimmedDetentIndex}
305
- sheetGrabberVisible={sheetGrabberVisible}
306
- sheetInitialDetentIndex={sheetInitialDetentIndex}
307
- sheetCornerRadius={sheetCornerRadius}
308
- sheetElevation={sheetElevation}
309
- sheetExpandsWhenScrolledToEdge={sheetExpandsWhenScrolledToEdge}
310
- statusBarAnimation={statusBarAnimation}
311
- statusBarHidden={statusBarHidden}
312
- statusBarStyle={statusBarStyle}
313
- statusBarColor={statusBarBackgroundColor}
314
- statusBarTranslucent={statusBarTranslucent}
315
- swipeDirection={gestureDirectionOverride}
316
- transitionDuration={animationDuration}
317
- onWillAppear={onWillAppear}
318
- onWillDisappear={onWillDisappear}
319
- onAppear={onAppear}
320
- onDisappear={onDisappear}
321
- onDismissed={onDismissed}
322
- onGestureCancel={onGestureCancel}
323
- onSheetDetentChanged={onSheetDetentChanged}
324
- gestureResponseDistance={gestureResponseDistance}
325
- nativeBackButtonDismissalEnabled={false} // on Android
326
- onHeaderBackButtonClicked={onHeaderBackButtonClicked}
327
- preventNativeDismiss={isRemovePrevented} // on iOS
328
- onNativeDismissCancelled={onNativeDismissCancelled}
329
- // Unfortunately, because of the bug that exists on Fabric, where native event drivers
330
- // for Animated objects are being created after the first notifications about the header height
331
- // from the native side, `onHeaderHeightChange` event does not notify
332
- // `animatedHeaderHeight` about initial values on appearing screens at the moment.
333
- onHeaderHeightChange={Animated.event(
334
- [
335
- {
336
- nativeEvent: {
337
- headerHeight: rawAnimatedHeaderHeight,
338
- },
339
- },
340
- ],
341
- {
342
- useNativeDriver: true,
343
- listener: (e) => {
344
- if (
345
- Platform.OS === 'android' &&
346
- (options.headerBackground != null || options.headerTransparent)
347
- ) {
348
- // FIXME: On Android, we get 0 if the header is translucent
349
- // So we set a default height in that case
350
- setHeaderHeight(ANDROID_DEFAULT_HEADER_HEIGHT + topInset);
351
- return;
352
- }
353
-
354
- if (
355
- e.nativeEvent &&
356
- typeof e.nativeEvent === 'object' &&
357
- 'headerHeight' in e.nativeEvent &&
358
- typeof e.nativeEvent.headerHeight === 'number'
359
- ) {
360
- const headerHeight =
361
- e.nativeEvent.headerHeight + headerHeightCorrectionOffset;
362
-
363
- // Only debounce if header has large title or search bar
364
- // As it's the only case where the header height can change frequently
365
- const doesHeaderAnimate =
366
- Platform.OS === 'ios' &&
367
- (options.headerLargeTitle || options.headerSearchBarOptions);
368
-
369
- if (doesHeaderAnimate) {
370
- setHeaderHeightDebounced(headerHeight);
371
- } else {
372
- setHeaderHeight(headerHeight);
373
- }
278
+ <NavigationContext.Provider value={navigation}>
279
+ <NavigationRouteContext.Provider value={route}>
280
+ <ScreenStackItem
281
+ key={route.key}
282
+ screenId={route.key}
283
+ activityState={isPreloaded ? 0 : 2}
284
+ style={StyleSheet.absoluteFill}
285
+ accessibilityElementsHidden={!focused}
286
+ importantForAccessibility={focused ? 'auto' : 'no-hide-descendants'}
287
+ customAnimationOnSwipe={animationMatchesGesture}
288
+ fullScreenSwipeEnabled={fullScreenGestureEnabled}
289
+ fullScreenSwipeShadowEnabled={fullScreenGestureShadowEnabled}
290
+ freezeOnBlur={freezeOnBlur}
291
+ gestureEnabled={
292
+ Platform.OS === 'android'
293
+ ? // This prop enables handling of system back gestures on Android
294
+ // Since we handle them in JS side, we disable this
295
+ false
296
+ : gestureEnabled
297
+ }
298
+ homeIndicatorHidden={autoHideHomeIndicator}
299
+ hideKeyboardOnSwipe={keyboardHandlingEnabled}
300
+ navigationBarColor={navigationBarColor}
301
+ navigationBarTranslucent={navigationBarTranslucent}
302
+ navigationBarHidden={navigationBarHidden}
303
+ replaceAnimation={animationTypeForReplace}
304
+ stackPresentation={presentation === 'card' ? 'push' : presentation}
305
+ stackAnimation={animation}
306
+ screenOrientation={orientation}
307
+ sheetAllowedDetents={sheetAllowedDetents}
308
+ sheetLargestUndimmedDetentIndex={sheetLargestUndimmedDetentIndex}
309
+ sheetGrabberVisible={sheetGrabberVisible}
310
+ sheetInitialDetentIndex={sheetInitialDetentIndex}
311
+ sheetCornerRadius={sheetCornerRadius}
312
+ sheetElevation={sheetElevation}
313
+ sheetExpandsWhenScrolledToEdge={sheetExpandsWhenScrolledToEdge}
314
+ statusBarAnimation={statusBarAnimation}
315
+ statusBarHidden={statusBarHidden}
316
+ statusBarStyle={statusBarStyle}
317
+ statusBarColor={statusBarBackgroundColor}
318
+ statusBarTranslucent={statusBarTranslucent}
319
+ swipeDirection={gestureDirectionOverride}
320
+ transitionDuration={animationDuration}
321
+ onWillAppear={onWillAppear}
322
+ onWillDisappear={onWillDisappear}
323
+ onAppear={onAppear}
324
+ onDisappear={onDisappear}
325
+ onDismissed={onDismissed}
326
+ onGestureCancel={onGestureCancel}
327
+ onSheetDetentChanged={onSheetDetentChanged}
328
+ gestureResponseDistance={gestureResponseDistance}
329
+ nativeBackButtonDismissalEnabled={false} // on Android
330
+ onHeaderBackButtonClicked={onHeaderBackButtonClicked}
331
+ preventNativeDismiss={isRemovePrevented} // on iOS
332
+ onNativeDismissCancelled={onNativeDismissCancelled}
333
+ // Unfortunately, because of the bug that exists on Fabric, where native event drivers
334
+ // for Animated objects are being created after the first notifications about the header height
335
+ // from the native side, `onHeaderHeightChange` event does not notify
336
+ // `animatedHeaderHeight` about initial values on appearing screens at the moment.
337
+ onHeaderHeightChange={Animated.event(
338
+ [
339
+ {
340
+ nativeEvent: {
341
+ headerHeight: rawAnimatedHeaderHeight,
342
+ },
343
+ },
344
+ ],
345
+ {
346
+ useNativeDriver,
347
+ listener: (e) => {
348
+ if (
349
+ Platform.OS === 'android' &&
350
+ (options.headerBackground != null ||
351
+ options.headerTransparent)
352
+ ) {
353
+ // FIXME: On Android, we get 0 if the header is translucent
354
+ // So we set a default height in that case
355
+ setHeaderHeight(ANDROID_DEFAULT_HEADER_HEIGHT + topInset);
356
+ return;
357
+ }
358
+
359
+ if (
360
+ e.nativeEvent &&
361
+ typeof e.nativeEvent === 'object' &&
362
+ 'headerHeight' in e.nativeEvent &&
363
+ typeof e.nativeEvent.headerHeight === 'number'
364
+ ) {
365
+ const headerHeight =
366
+ e.nativeEvent.headerHeight + headerHeightCorrectionOffset;
367
+
368
+ // Only debounce if header has large title or search bar
369
+ // As it's the only case where the header height can change frequently
370
+ const doesHeaderAnimate =
371
+ Platform.OS === 'ios' &&
372
+ (options.headerLargeTitle ||
373
+ options.headerSearchBarOptions);
374
+
375
+ if (doesHeaderAnimate) {
376
+ setHeaderHeightDebounced(headerHeight);
377
+ } else {
378
+ setHeaderHeight(headerHeight);
379
+ }
380
+ }
381
+ },
374
382
  }
375
- },
376
- }
377
- )}
378
- contentStyle={[
379
- presentation !== 'transparentModal' &&
380
- presentation !== 'containedTransparentModal' && {
381
- backgroundColor: colors.background,
382
- },
383
- contentStyle,
384
- ]}
385
- headerConfig={headerConfig}
386
- unstable_sheetFooter={unstable_sheetFooter}
387
- // When ts-expect-error is added, it affects all the props below it
388
- // So we keep any props that need it at the end
389
- // Otherwise invalid props may not be caught by TypeScript
390
- >
391
- <NavigationContext.Provider value={navigation}>
392
- <NavigationRouteContext.Provider value={route}>
383
+ )}
384
+ contentStyle={[
385
+ presentation !== 'transparentModal' &&
386
+ presentation !== 'containedTransparentModal' && {
387
+ backgroundColor: colors.background,
388
+ },
389
+ contentStyle,
390
+ ]}
391
+ headerConfig={headerConfig}
392
+ unstable_sheetFooter={unstable_sheetFooter}
393
+ // When ts-expect-error is added, it affects all the props below it
394
+ // So we keep any props that need it at the end
395
+ // Otherwise invalid props may not be caught by TypeScript
396
+ >
393
397
  <AnimatedHeaderHeightContext.Provider value={animatedHeaderHeight}>
394
398
  <HeaderHeightContext.Provider
395
399
  value={
@@ -441,9 +445,9 @@ const SceneView = ({
441
445
  </HeaderShownContext.Provider>
442
446
  </HeaderHeightContext.Provider>
443
447
  </AnimatedHeaderHeightContext.Provider>
444
- </NavigationRouteContext.Provider>
445
- </NavigationContext.Provider>
446
- </ScreenStackItem>
448
+ </ScreenStackItem>
449
+ </NavigationRouteContext.Provider>
450
+ </NavigationContext.Provider>
447
451
  );
448
452
  };
449
453
 
@@ -135,10 +135,8 @@ export function NativeStackView({ state, descriptors, describe }: Props) {
135
135
  <Image
136
136
  source={headerBackImageSource}
137
137
  resizeMode="contain"
138
- style={[
139
- styles.backImage,
140
- { tintColor },
141
- ]}
138
+ tintColor={tintColor}
139
+ style={styles.backImage}
142
140
  />
143
141
  )
144
142
  : undefined