react-native-screens 3.25.0 → 3.27.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.
Files changed (138) hide show
  1. package/README.md +1 -1
  2. package/RNScreens.podspec +53 -32
  3. package/android/build.gradle +13 -11
  4. package/android/src/main/java/com/swmansion/rnscreens/FragmentHolder.kt +7 -0
  5. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +41 -10
  6. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +35 -36
  7. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainerViewManager.kt +7 -7
  8. package/android/src/main/java/com/swmansion/rnscreens/ScreenEventDispatcher.kt +21 -0
  9. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +46 -38
  10. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragmentWrapper.kt +22 -0
  11. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +40 -39
  12. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +35 -10
  13. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragmentWrapper.kt +15 -0
  14. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +7 -5
  15. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +11 -18
  16. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +1 -1
  17. package/android/src/main/java/com/swmansion/rnscreens/ScreensShadowNode.kt +1 -1
  18. package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +23 -7
  19. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderAttachedEvent.kt +3 -5
  20. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderBackButtonClickedEvent.kt +3 -5
  21. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderDetachedEvent.kt +3 -5
  22. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderHeightChangeEvent.kt +26 -0
  23. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenAppearEvent.kt +3 -5
  24. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDisappearEvent.kt +3 -5
  25. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDismissedEvent.kt +4 -7
  26. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenTransitionProgressEvent.kt +7 -8
  27. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillAppearEvent.kt +3 -5
  28. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillDisappearEvent.kt +3 -5
  29. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarBlurEvent.kt +3 -5
  30. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarChangeTextEvent.kt +5 -6
  31. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarCloseEvent.kt +3 -5
  32. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarFocusEvent.kt +3 -5
  33. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarOpenEvent.kt +3 -5
  34. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarSearchButtonPressEvent.kt +4 -6
  35. package/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt +3 -5
  36. package/android/src/main/java/com/swmansion/rnscreens/utils/DeviceUtils.kt +12 -0
  37. package/ios/RNSScreen.h +5 -0
  38. package/ios/RNSScreen.mm +163 -7
  39. package/ios/RNSScreenStack.mm +18 -0
  40. package/ios/RNSScreenStackHeaderConfig.mm +17 -0
  41. package/ios/events/RNSHeaderHeightChangeEvent.h +8 -0
  42. package/ios/events/RNSHeaderHeightChangeEvent.mm +59 -0
  43. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
  44. package/lib/commonjs/index.native.js +11 -11
  45. package/lib/commonjs/index.native.js.map +1 -1
  46. package/lib/commonjs/native-stack/index.js +14 -0
  47. package/lib/commonjs/native-stack/index.js.map +1 -1
  48. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +1 -1
  49. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  50. package/lib/commonjs/native-stack/types.js.map +1 -1
  51. package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js +13 -0
  52. package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -0
  53. package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  54. package/lib/commonjs/native-stack/utils/getStatusBarHeight.js +22 -0
  55. package/lib/commonjs/native-stack/utils/getStatusBarHeight.js.map +1 -0
  56. package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js +19 -0
  57. package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -0
  58. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js +2 -2
  59. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -1
  60. package/lib/commonjs/native-stack/views/HeaderConfig.js +2 -2
  61. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  62. package/lib/commonjs/native-stack/views/NativeStackView.js +39 -21
  63. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  64. package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js +13 -0
  65. package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js.map +1 -0
  66. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +37 -6
  67. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  68. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +2 -2
  69. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
  70. package/lib/commonjs/reanimated/index.js +7 -0
  71. package/lib/commonjs/reanimated/index.js.map +1 -1
  72. package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js +19 -0
  73. package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js.map +1 -0
  74. package/lib/commonjs/types.js.map +1 -1
  75. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
  76. package/lib/module/index.native.js +12 -12
  77. package/lib/module/index.native.js.map +1 -1
  78. package/lib/module/native-stack/index.js +2 -0
  79. package/lib/module/native-stack/index.js.map +1 -1
  80. package/lib/module/native-stack/navigators/createNativeStackNavigator.js +1 -1
  81. package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  82. package/lib/module/native-stack/types.js.map +1 -1
  83. package/lib/module/native-stack/utils/AnimatedHeaderHeightContext.js +4 -0
  84. package/lib/module/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -0
  85. package/lib/module/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  86. package/lib/module/native-stack/utils/getStatusBarHeight.js +16 -0
  87. package/lib/module/native-stack/utils/getStatusBarHeight.js.map +1 -0
  88. package/lib/module/native-stack/utils/useAnimatedHeaderHeight.js +10 -0
  89. package/lib/module/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -0
  90. package/lib/module/native-stack/utils/useBackPressSubscription.js +2 -2
  91. package/lib/module/native-stack/utils/useBackPressSubscription.js.map +1 -1
  92. package/lib/module/native-stack/views/HeaderConfig.js +2 -2
  93. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  94. package/lib/module/native-stack/views/NativeStackView.js +40 -22
  95. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  96. package/lib/module/reanimated/ReanimatedHeaderHeightContext.js +5 -0
  97. package/lib/module/reanimated/ReanimatedHeaderHeightContext.js.map +1 -0
  98. package/lib/module/reanimated/ReanimatedNativeStackScreen.js +37 -6
  99. package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  100. package/lib/module/reanimated/ReanimatedScreenProvider.js +2 -2
  101. package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
  102. package/lib/module/reanimated/index.js +1 -0
  103. package/lib/module/reanimated/index.js.map +1 -1
  104. package/lib/module/reanimated/useReanimatedHeaderHeight.js +10 -0
  105. package/lib/module/reanimated/useReanimatedHeaderHeight.js.map +1 -0
  106. package/lib/module/types.js.map +1 -1
  107. package/lib/typescript/fabric/ScreenNativeComponent.d.ts +4 -0
  108. package/lib/typescript/native-stack/index.d.ts +2 -0
  109. package/lib/typescript/native-stack/types.d.ts +8 -0
  110. package/lib/typescript/native-stack/utils/AnimatedHeaderHeightContext.d.ts +4 -0
  111. package/lib/typescript/native-stack/utils/getStatusBarHeight.d.ts +2 -0
  112. package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts +1 -0
  113. package/lib/typescript/reanimated/ReanimatedHeaderHeightContext.d.ts +4 -0
  114. package/lib/typescript/reanimated/index.d.ts +1 -0
  115. package/lib/typescript/reanimated/useReanimatedHeaderHeight.d.ts +3 -0
  116. package/lib/typescript/types.d.ts +11 -0
  117. package/native-stack/README.md +16 -1
  118. package/package.json +36 -38
  119. package/src/fabric/ScreenNativeComponent.ts +5 -0
  120. package/src/index.native.tsx +17 -19
  121. package/src/native-stack/index.tsx +3 -0
  122. package/src/native-stack/types.tsx +10 -1
  123. package/src/native-stack/utils/AnimatedHeaderHeightContext.tsx +8 -0
  124. package/src/native-stack/utils/SafeAreaProviderCompat.tsx +1 -1
  125. package/src/native-stack/utils/getStatusBarHeight.tsx +22 -0
  126. package/src/native-stack/utils/useAnimatedHeaderHeight.tsx +15 -0
  127. package/src/native-stack/views/HeaderConfig.tsx +1 -2
  128. package/src/native-stack/views/NativeStackView.tsx +78 -44
  129. package/src/reanimated/ReanimatedHeaderHeightContext.tsx +7 -0
  130. package/src/reanimated/ReanimatedNativeStackScreen.tsx +58 -11
  131. package/src/reanimated/index.tsx +1 -0
  132. package/src/reanimated/useReanimatedHeaderHeight.tsx +14 -0
  133. package/src/types.tsx +14 -0
  134. package/windows/RNScreens/RNScreens.vcxproj +6 -3
  135. package/windows/RNScreens/ScreenStack.cpp +16 -0
  136. package/windows/RNScreens/ScreenStack.h +1 -0
  137. /package/ios/{RNSScreenViewEvent.h → events/RNSScreenViewEvent.h} +0 -0
  138. /package/ios/{RNSScreenViewEvent.mm → events/RNSScreenViewEvent.mm} +0 -0
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.tsx"],"sourcesContent":["import {\n Animated,\n NativeSyntheticEvent,\n ViewProps,\n View,\n TargetedEvent,\n TextInputFocusEventData,\n ColorValue,\n} from 'react-native';\n\nexport type SearchBarCommands = {\n focus: () => void;\n blur: () => void;\n clearText: () => void;\n toggleCancelButton: (show: boolean) => void;\n setText: (text: string) => void;\n};\n\nexport type StackPresentationTypes =\n | 'push'\n | 'modal'\n | 'transparentModal'\n | 'containedModal'\n | 'containedTransparentModal'\n | 'fullScreenModal'\n | 'formSheet';\nexport type StackAnimationTypes =\n | 'default'\n | 'fade'\n | 'fade_from_bottom'\n | 'flip'\n | 'none'\n | 'simple_push'\n | 'slide_from_bottom'\n | 'slide_from_right'\n | 'slide_from_left';\nexport type BlurEffectTypes =\n | 'extraLight'\n | 'light'\n | 'dark'\n | 'regular'\n | 'prominent'\n | 'systemUltraThinMaterial'\n | 'systemThinMaterial'\n | 'systemMaterial'\n | 'systemThickMaterial'\n | 'systemChromeMaterial'\n | 'systemUltraThinMaterialLight'\n | 'systemThinMaterialLight'\n | 'systemMaterialLight'\n | 'systemThickMaterialLight'\n | 'systemChromeMaterialLight'\n | 'systemUltraThinMaterialDark'\n | 'systemThinMaterialDark'\n | 'systemMaterialDark'\n | 'systemThickMaterialDark'\n | 'systemChromeMaterialDark';\nexport type ScreenReplaceTypes = 'push' | 'pop';\nexport type SwipeDirectionTypes = 'vertical' | 'horizontal';\nexport type ScreenOrientationTypes =\n | 'default'\n | 'all'\n | 'portrait'\n | 'portrait_up'\n | 'portrait_down'\n | 'landscape'\n | 'landscape_left'\n | 'landscape_right';\nexport type HeaderSubviewTypes =\n | 'back'\n | 'right'\n | 'left'\n | 'center'\n | 'searchBar';\n\nexport type TransitionProgressEventType = {\n progress: number;\n closing: number;\n goingForward: number;\n};\n\nexport type GestureResponseDistanceType = {\n start?: number;\n end?: number;\n top?: number;\n bottom?: number;\n};\n\nexport type SheetDetentTypes = 'medium' | 'large' | 'all';\nexport type SearchBarPlacement = 'automatic' | 'inline' | 'stacked';\n\nexport interface ScreenProps extends ViewProps {\n active?: 0 | 1 | Animated.AnimatedInterpolation<number>;\n activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation<number>;\n children?: React.ReactNode;\n /**\n * Boolean indicating that swipe dismissal should trigger animation provided by `stackAnimation`. Defaults to `false`.\n *\n * @platform ios\n */\n customAnimationOnSwipe?: boolean;\n /**\n * All children screens should have the same value of their \"enabled\" prop as their container.\n */\n enabled?: boolean;\n /**\n * Internal boolean used to not attach events used only by native-stack. It prevents non native-stack navigators from sending transition progress from their Screen components.\n */\n isNativeStack?: boolean;\n /**\n * Whether inactive screens should be suspended from re-rendering. Defaults to `false`.\n * When `enableFreeze()` is run at the top of the application defaults to `true`.\n */\n freezeOnBlur?: boolean;\n /**\n * Boolean indicating whether the swipe gesture should work on whole screen. Swiping with this option results in the same transition animation as `simple_push` by default.\n * It can be changed to other custom animations with `customAnimationOnSwipe` prop, but default iOS swipe animation is not achievable due to usage of custom recognizer.\n * Defaults to `false`.\n *\n * @platform ios\n */\n fullScreenSwipeEnabled?: boolean;\n /**\n * Whether you can use gestures to dismiss this screen. Defaults to `true`.\n *\n * @platform ios\n */\n gestureEnabled?: boolean;\n /**\n * Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`.\n *\n * @platform ios\n */\n gestureResponseDistance?: GestureResponseDistanceType;\n /**\n * Whether the home indicator should be hidden on this screen. Defaults to `false`.\n *\n * @platform ios\n */\n homeIndicatorHidden?: boolean;\n /**\n * Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.\n *\n * @platform ios\n */\n hideKeyboardOnSwipe?: boolean;\n /**\n * Boolean indicating whether, when the Android default back button is clicked, the `pop` action should be performed on the native side or on the JS side to be able to prevent it.\n * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.\n * Defaults to `false`.\n *\n * @platform android\n */\n nativeBackButtonDismissalEnabled?: boolean;\n /**\n * Sets the navigation bar color. Defaults to initial status bar color.\n *\n * @platform android\n */\n navigationBarColor?: ColorValue;\n /**\n * Sets the visibility of the navigation bar. Defaults to `false`.\n *\n * @platform android\n */\n navigationBarHidden?: boolean;\n /**\n * A callback that gets called when the current screen appears.\n */\n onAppear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n onComponentRef?: (view: unknown) => void;\n /**\n * A callback that gets called when the current screen disappears.\n */\n onDisappear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * A callback that gets called when the current screen is dismissed by hardware back (on Android) or dismiss gesture (swipe back or down).\n * The callback takes the number of dismissed screens as an argument since iOS 14 native header back button can pop more than 1 screen at a time.\n */\n onDismissed?: (e: NativeSyntheticEvent<{ dismissCount: number }>) => void;\n /**\n * A callback that gets called after swipe back is canceled.\n */\n onGestureCancel?: (e: NativeSyntheticEvent<null>) => void;\n /**\n * An internal callback that gets called when the native header back button is clicked on Android and `enableNativeBackButtonDismissal` is set to `false`. It dismises the screen using `navigation.pop()`.\n *\n * @platform android\n */\n onHeaderBackButtonClicked?: () => void;\n /**\n * An internal callback called when screen is dismissed by gesture or by native header back button and `preventNativeDismiss` is set to `true`.\n *\n * @platform ios\n */\n onNativeDismissCancelled?: (\n e: NativeSyntheticEvent<{ dismissCount: number }>\n ) => void;\n /**\n * An internal callback called every frame during the transition of screens of `native-stack`, used to feed transition context.\n */\n onTransitionProgress?: (\n e: NativeSyntheticEvent<TransitionProgressEventType>\n ) => void;\n /**\n * A callback that gets called when the current screen will appear. This is called as soon as the transition begins.\n */\n onWillAppear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * A callback that gets called when the current screen will disappear. This is called as soon as the transition begins.\n */\n onWillDisappear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * Boolean indicating whether to prevent current screen from being dismissed.\n * Defaults to `false`.\n *\n * @platform ios\n */\n preventNativeDismiss?: boolean;\n ref?: React.Ref<View>;\n /**\n * How should the screen replacing another screen animate. Defaults to `pop`.\n * The following values are currently supported:\n * - \"push\" – the new screen will perform push animation.\n * - \"pop\" – the new screen will perform pop animation.\n */\n replaceAnimation?: ScreenReplaceTypes;\n /**\n * In which orientation should the screen appear.\n * The following values are currently supported:\n * - \"default\" - resolves to \"all\" without \"portrait_down\" on iOS. On Android, this lets the system decide the best orientation.\n * - \"all\" – all orientations are permitted\n * - \"portrait\" – portrait orientations are permitted\n * - \"portrait_up\" – right-side portrait orientation is permitted\n * - \"portrait_down\" – upside-down portrait orientation is permitted\n * - \"landscape\" – landscape orientations are permitted\n * - \"landscape_left\" – landscape-left orientation is permitted\n * - \"landscape_right\" – landscape-right orientation is permitted\n */\n screenOrientation?: ScreenOrientationTypes;\n /**\n * Describes heights where a sheet can rest.\n * Works only when `stackPresentation` is set to `formSheet`.\n * Defaults to `large`.\n *\n * Available values:\n *\n * - `large` - only large detent level will be allowed\n * - `medium` - only medium detent level will be allowed\n * - `all` - all detent levels will be allowed\n *\n * @platform ios\n */\n sheetAllowedDetents?: SheetDetentTypes;\n /**\n * Whether the sheet should expand to larger detent when scrolling.\n * Works only when `stackPresentation` is set to `formSheet`.\n * Defaults to `true`.\n *\n * @platform ios\n */\n sheetExpandsWhenScrolledToEdge?: boolean;\n /**\n * The corner radius that the sheet will try to render with.\n * Works only when `stackPresentation` is set to `formSheet`.\n *\n * If set to non-negative value it will try to render sheet with provided radius, else it will apply system default.\n *\n * If left unset system default is used.\n *\n * @platform ios\n */\n sheetCornerRadius?: number;\n /**\n * Boolean indicating whether the sheet shows a grabber at the top.\n * Works only when `stackPresentation` is set to `formSheet`.\n * Defaults to `false`.\n *\n * @platform ios\n */\n sheetGrabberVisible?: boolean;\n /**\n * The largest sheet detent for which a view underneath won't be dimmed.\n * Works only when `stackPresentation` is set to `formSheet`.\n *\n * If this prop is set to:\n *\n * - `large` - the view underneath won't be dimmed at any detent level\n * - `medium` - the view underneath will be dimmed only when detent level is `large`\n * - `all` - the view underneath will be dimmed for any detent level\n *\n * Defaults to `all`.\n *\n * @platform ios\n */\n sheetLargestUndimmedDetent?: SheetDetentTypes;\n /**\n * How the screen should appear/disappear when pushed or popped at the top of the stack.\n * The following values are currently supported:\n * - \"default\" – uses a platform default animation\n * - \"fade\" – fades screen in or out\n * - \"fade_from_bottom\" – performs a fade from bottom animation\n * - \"flip\" – flips the screen, requires stackPresentation: \"modal\" (iOS only)\n * - \"simple_push\" – performs a default animation, but without shadow and native header transition (iOS only)\n * - `slide_from_bottom` – performs a slide from bottom animation\n * - \"slide_from_right\" - slide in the new screen from right to left (Android only, resolves to default transition on iOS)\n * - \"slide_from_left\" - slide in the new screen from left to right (Android only, resolves to default transition on iOS)\n * - \"none\" – the screen appears/dissapears without an animation\n */\n stackAnimation?: StackAnimationTypes;\n /**\n * How should the screen be presented.\n * The following values are currently supported:\n * - \"push\" – the new screen will be pushed onto a stack which on iOS means that the default animation will be slide from the side, the animation on Android may vary depending on the OS version and theme.\n * - \"modal\" – the new screen will be presented modally. In addition this allow for a nested stack to be rendered inside such screens.\n * - \"transparentModal\" – the new screen will be presented modally but in addition the second to last screen will remain attached to the stack container such that if the top screen is non opaque the content below can still be seen. If \"modal\" is used instead the below screen will get unmounted as soon as the transition ends.\n * - \"containedModal\" – will use \"UIModalPresentationCurrentContext\" modal style on iOS and will fallback to \"modal\" on Android.\n * - \"containedTransparentModal\" – will use \"UIModalPresentationOverCurrentContext\" modal style on iOS and will fallback to \"transparentModal\" on Android.\n * - \"fullScreenModal\" – will use \"UIModalPresentationFullScreen\" modal style on iOS and will fallback to \"modal\" on Android.\n * - \"formSheet\" – will use \"UIModalPresentationFormSheet\" modal style on iOS and will fallback to \"modal\" on Android.\n */\n stackPresentation?: StackPresentationTypes;\n /**\n * Sets the status bar animation (similar to the `StatusBar` component). Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS.\n */\n statusBarAnimation?: 'none' | 'fade' | 'slide';\n /**\n * Sets the status bar color (similar to the `StatusBar` component). Defaults to initial status bar color.\n *\n * @platform android\n */\n statusBarColor?: ColorValue;\n /**\n * Whether the status bar should be hidden on this screen. Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS. Defaults to `false`.\n */\n statusBarHidden?: boolean;\n /**\n * Sets the status bar color (similar to the `StatusBar` component). Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS. Defaults to `auto`.\n */\n statusBarStyle?: 'inverted' | 'auto' | 'light' | 'dark';\n /**\n * Sets the translucency of the status bar. Defaults to `false`.\n *\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Sets the direction in which you should swipe to dismiss the screen.\n * When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.\n * The following values are supported:\n * - `vertical` – dismiss screen vertically\n * - `horizontal` – dismiss screen horizontally (default)\n *\n * @platform ios\n */\n swipeDirection?: SwipeDirectionTypes;\n /**\n * Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.\n * The duration of `default` and `flip` transitions isn't customizable.\n *\n * @platform ios\n */\n transitionDuration?: number;\n}\n\nexport interface ScreenContainerProps extends ViewProps {\n children?: React.ReactNode;\n /**\n * A prop that gives users an option to switch between using Screens for the navigator (container). All children screens should have the same value of their \"enabled\" prop as their container.\n */\n enabled?: boolean;\n /**\n * A prop to be used in navigators always showing only one screen (providing only `0` or `2` `activityState` values) for better implementation of `ScreenContainer` on iOS.\n */\n hasTwoStates?: boolean;\n}\n\nexport interface ScreenStackProps extends ViewProps {\n children?: React.ReactNode;\n /**\n * A callback that gets called when the current screen finishes its transition.\n */\n onFinishTransitioning?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n}\n\nexport interface ScreenStackHeaderConfigProps extends ViewProps {\n /**\n * Whether to show the back button with custom left side of the header.\n */\n backButtonInCustomView?: boolean;\n /**\n * Controls the color of the navigation header.\n */\n backgroundColor?: ColorValue;\n /**\n * Title to display in the back button.\n * @platform ios.\n */\n backTitle?: string;\n /**\n * Allows for customizing font family to be used for back button title on iOS.\n * @platform ios\n */\n backTitleFontFamily?: string;\n /**\n * Allows for customizing font size to be used for back button title on iOS.\n * @platform ios\n */\n backTitleFontSize?: number;\n /**\n * Whether the back button title should be visible or not. Defaults to `true`.\n * @platform ios\n */\n backTitleVisible?: boolean;\n /**\n * Blur effect to be applied to the header. Works with backgroundColor's alpha < 1.\n * @platform ios\n */\n blurEffect?: BlurEffectTypes;\n /**\n * Pass HeaderLeft, HeaderRight and HeaderTitle\n */\n children?: React.ReactNode;\n /**\n * Controls the color of items rendered on the header. This includes back icon, back text (iOS only) and title text. If you want the title to have different color use titleColor property.\n */\n color?: ColorValue;\n /**\n * Whether the stack should be in rtl or ltr form.\n */\n direction?: 'rtl' | 'ltr';\n /**\n * Boolean indicating whether to show the menu on longPress of iOS >= 14 back button.\n * @platform ios\n */\n disableBackButtonMenu?: boolean;\n /**\n * When set to true the header will be hidden while the parent Screen is on the top of the stack. The default value is false.\n */\n hidden?: boolean;\n /**\n * Boolean indicating whether to hide the back button in header.\n */\n hideBackButton?: boolean;\n /**\n * Boolean indicating whether to hide the elevation shadow or the bottom border on the header.\n */\n hideShadow?: boolean;\n /**\n * Boolean to set native property to prefer large title header (like in iOS setting).\n * For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as `ScrollView` or `FlatList`.\n * If the scrollable area doesn't fill the screen, the large title won't collapse on scroll.\n * Only supported on iOS.\n *\n * @platform ios\n */\n largeTitle?: boolean;\n /**\n * Controls the color of the navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.\n */\n largeTitleBackgroundColor?: ColorValue;\n /**\n * Customize the color to be used for the large title. By default uses the titleColor property.\n * @platform ios\n */\n largeTitleColor?: ColorValue;\n /**\n * Customize font family to be used for the large title.\n * @platform ios\n */\n largeTitleFontFamily?: string;\n /**\n * Customize the size of the font to be used for the large title.\n * @platform ios\n */\n largeTitleFontSize?: number;\n /**\n * Customize the weight of the font to be used for the large title.\n * @platform ios\n */\n largeTitleFontWeight?: string;\n /**\n * Boolean that allows for disabling drop shadow under navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.\n */\n largeTitleHideShadow?: boolean;\n /**\n * Callback which is executed when screen header is attached\n */\n onAttached?: () => void;\n /**\n * Callback which is executed when screen header is detached\n */\n onDetached?: () => void;\n /**\n * String that can be displayed in the header as a fallback for `headerTitle`.\n */\n title?: string;\n /**\n * Allows for setting text color of the title.\n */\n titleColor?: ColorValue;\n /**\n * Customize font family to be used for the title.\n */\n titleFontFamily?: string;\n /**\n * Customize the size of the font to be used for the title.\n */\n titleFontSize?: number;\n /**\n * Customize the weight of the font to be used for the title.\n */\n titleFontWeight?: string;\n /**\n * A flag to that lets you opt out of insetting the header. You may want to\n * set this to `false` if you use an opaque status bar. Defaults to `true`.\n * Only supported on Android. Insets are always applied on iOS because the\n * header cannot be opaque.\n *\n * @platform android\n */\n topInsetEnabled?: boolean;\n /**\n * Boolean indicating whether the navigation bar is translucent.\n */\n translucent?: boolean;\n}\n\nexport interface SearchBarProps {\n /**\n * Reference to imperatively modify search bar.\n *\n * Currently supported operations are:\n *\n * * `focus` - focuses the search bar\n * * `blur` - removes focus from the search bar\n * * `clearText` - removes any text present in the search bar input field\n * * `setText` - sets the search bar's content to given value\n * * `toggleCancelButton` - depending on passed boolean value, hides or shows cancel button (iOS only)\n */\n ref?: React.RefObject<SearchBarCommands>;\n\n /**\n * The auto-capitalization behavior\n */\n autoCapitalize?: 'none' | 'words' | 'sentences' | 'characters';\n /**\n * Automatically focuses search bar on mount\n *\n * @platform android\n */\n autoFocus?: boolean;\n /**\n * The search field background color\n */\n barTintColor?: ColorValue;\n /**\n * The color for the cursor caret and cancel button text.\n *\n * @platform ios\n */\n tintColor?: ColorValue;\n /**\n * The text to be used instead of default `Cancel` button text\n *\n * @platform ios\n */\n cancelButtonText?: string;\n /**\n * Specifies whether the back button should close search bar's text input or not.\n *\n * @platform android\n */\n disableBackButtonOverride?: boolean;\n /**\n * Indicates whether to hide the navigation bar\n *\n * @platform ios\n */\n hideNavigationBar?: boolean;\n /**\n * Indicates whether to hide the search bar when scrolling\n *\n * @platform ios\n */\n hideWhenScrolling?: boolean;\n\n /**\n * Sets type of the input. Defaults to `text`.\n *\n * @platform android\n */\n inputType?: 'text' | 'phone' | 'number' | 'email';\n /**\n * Indicates whether to obscure the underlying content\n */\n obscureBackground?: boolean;\n /**\n * A callback that gets called when search bar has lost focus\n */\n onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * A callback that gets called when the cancel button is pressed\n *\n * @platform ios\n */\n onCancelButtonPress?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n\n /**\n * A callback that gets called when the text changes. It receives the current text value of the search bar.\n */\n onChangeText?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;\n\n /**\n * A callback that gets called when search bar is closed\n *\n * @platform android\n */\n onClose?: () => void;\n /**\n * A callback that gets called when search bar has received focus\n */\n onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * A callback that gets called when search bar is opened\n *\n * @platform android\n */\n onOpen?: () => void;\n /**\n * A callback that gets called when the search button is pressed. It receives the current text value of the search bar.\n */\n onSearchButtonPress?: (\n e: NativeSyntheticEvent<TextInputFocusEventData>\n ) => void;\n /**\n * Text displayed when search field is empty\n */\n placeholder?: string;\n /**\n * Position of the search bar\n *\n * Supported values:\n *\n * * `automatic` - the search bar is placed according to current layout\n * * `inline` - the search bar is placed on the trailing edge of navigation bar\n * * `stacked` - the search bar is placed below the other content in navigation bar\n *\n * Defaults to `stacked`\n *\n * @platform iOS (>= 16.0)\n */\n placement?: SearchBarPlacement;\n /**\n * The search field text color\n */\n textColor?: ColorValue;\n /**\n * The search hint text color\n *\n * @plaform android\n */\n hintTextColor?: ColorValue;\n /**\n * The search and close icon color shown in the header\n *\n * @plaform android\n */\n headerIconColor?: ColorValue;\n /**\n * Show the search hint icon when search bar is focused\n *\n * @plaform android\n * @default true\n */\n shouldShowHintSearchIcon?: boolean;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.tsx"],"sourcesContent":["import {\n Animated,\n NativeSyntheticEvent,\n ViewProps,\n View,\n TargetedEvent,\n TextInputFocusEventData,\n ColorValue,\n} from 'react-native';\n\nexport type SearchBarCommands = {\n focus: () => void;\n blur: () => void;\n clearText: () => void;\n toggleCancelButton: (show: boolean) => void;\n setText: (text: string) => void;\n};\n\nexport type StackPresentationTypes =\n | 'push'\n | 'modal'\n | 'transparentModal'\n | 'containedModal'\n | 'containedTransparentModal'\n | 'fullScreenModal'\n | 'formSheet';\nexport type StackAnimationTypes =\n | 'default'\n | 'fade'\n | 'fade_from_bottom'\n | 'flip'\n | 'none'\n | 'simple_push'\n | 'slide_from_bottom'\n | 'slide_from_right'\n | 'slide_from_left';\nexport type BlurEffectTypes =\n | 'extraLight'\n | 'light'\n | 'dark'\n | 'regular'\n | 'prominent'\n | 'systemUltraThinMaterial'\n | 'systemThinMaterial'\n | 'systemMaterial'\n | 'systemThickMaterial'\n | 'systemChromeMaterial'\n | 'systemUltraThinMaterialLight'\n | 'systemThinMaterialLight'\n | 'systemMaterialLight'\n | 'systemThickMaterialLight'\n | 'systemChromeMaterialLight'\n | 'systemUltraThinMaterialDark'\n | 'systemThinMaterialDark'\n | 'systemMaterialDark'\n | 'systemThickMaterialDark'\n | 'systemChromeMaterialDark';\nexport type ScreenReplaceTypes = 'push' | 'pop';\nexport type SwipeDirectionTypes = 'vertical' | 'horizontal';\nexport type ScreenOrientationTypes =\n | 'default'\n | 'all'\n | 'portrait'\n | 'portrait_up'\n | 'portrait_down'\n | 'landscape'\n | 'landscape_left'\n | 'landscape_right';\nexport type HeaderSubviewTypes =\n | 'back'\n | 'right'\n | 'left'\n | 'center'\n | 'searchBar';\n\nexport type HeaderHeightChangeEventType = {\n headerHeight: number;\n};\n\nexport type TransitionProgressEventType = {\n progress: number;\n closing: number;\n goingForward: number;\n};\n\nexport type GestureResponseDistanceType = {\n start?: number;\n end?: number;\n top?: number;\n bottom?: number;\n};\n\nexport type SheetDetentTypes = 'medium' | 'large' | 'all';\nexport type SearchBarPlacement = 'automatic' | 'inline' | 'stacked';\n\nexport interface ScreenProps extends ViewProps {\n active?: 0 | 1 | Animated.AnimatedInterpolation<number>;\n activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation<number>;\n children?: React.ReactNode;\n /**\n * Boolean indicating that swipe dismissal should trigger animation provided by `stackAnimation`. Defaults to `false`.\n *\n * @platform ios\n */\n customAnimationOnSwipe?: boolean;\n /**\n * All children screens should have the same value of their \"enabled\" prop as their container.\n */\n enabled?: boolean;\n /**\n * Internal boolean used to not attach events used only by native-stack. It prevents non native-stack navigators from sending transition progress from their Screen components.\n */\n isNativeStack?: boolean;\n /**\n * Internal boolean used to detect if current header has large title on iOS.\n */\n hasLargeHeader?: boolean;\n /**\n * Whether inactive screens should be suspended from re-rendering. Defaults to `false`.\n * When `enableFreeze()` is run at the top of the application defaults to `true`.\n */\n freezeOnBlur?: boolean;\n /**\n * Boolean indicating whether the swipe gesture should work on whole screen. Swiping with this option results in the same transition animation as `simple_push` by default.\n * It can be changed to other custom animations with `customAnimationOnSwipe` prop, but default iOS swipe animation is not achievable due to usage of custom recognizer.\n * Defaults to `false`.\n *\n * @platform ios\n */\n fullScreenSwipeEnabled?: boolean;\n /**\n * Whether you can use gestures to dismiss this screen. Defaults to `true`.\n *\n * @platform ios\n */\n gestureEnabled?: boolean;\n /**\n * Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`.\n *\n * @platform ios\n */\n gestureResponseDistance?: GestureResponseDistanceType;\n /**\n * Whether the home indicator should be hidden on this screen. Defaults to `false`.\n *\n * @platform ios\n */\n homeIndicatorHidden?: boolean;\n /**\n * Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.\n *\n * @platform ios\n */\n hideKeyboardOnSwipe?: boolean;\n /**\n * Boolean indicating whether, when the Android default back button is clicked, the `pop` action should be performed on the native side or on the JS side to be able to prevent it.\n * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.\n * Defaults to `false`.\n *\n * @platform android\n */\n nativeBackButtonDismissalEnabled?: boolean;\n /**\n * Sets the navigation bar color. Defaults to initial status bar color.\n *\n * @platform android\n */\n navigationBarColor?: ColorValue;\n /**\n * Sets the visibility of the navigation bar. Defaults to `false`.\n *\n * @platform android\n */\n navigationBarHidden?: boolean;\n /**\n * A callback that gets called when the current screen appears.\n */\n onAppear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n onComponentRef?: (view: unknown) => void;\n /**\n * A callback that gets called when the current screen disappears.\n */\n onDisappear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * A callback that gets called when the current screen is dismissed by hardware back (on Android) or dismiss gesture (swipe back or down).\n * The callback takes the number of dismissed screens as an argument since iOS 14 native header back button can pop more than 1 screen at a time.\n */\n onDismissed?: (e: NativeSyntheticEvent<{ dismissCount: number }>) => void;\n /**\n * A callback that gets called when the header height has changed.\n */\n onHeaderHeightChange?: (\n e: NativeSyntheticEvent<HeaderHeightChangeEventType>\n ) => void;\n /**\n * A callback that gets called after swipe back is canceled.\n */\n onGestureCancel?: (e: NativeSyntheticEvent<null>) => void;\n /**\n * An internal callback that gets called when the native header back button is clicked on Android and `enableNativeBackButtonDismissal` is set to `false`. It dismises the screen using `navigation.pop()`.\n *\n * @platform android\n */\n onHeaderBackButtonClicked?: () => void;\n /**\n * An internal callback called when screen is dismissed by gesture or by native header back button and `preventNativeDismiss` is set to `true`.\n *\n * @platform ios\n */\n onNativeDismissCancelled?: (\n e: NativeSyntheticEvent<{ dismissCount: number }>\n ) => void;\n /**\n * An internal callback called every frame during the transition of screens of `native-stack`, used to feed transition context.\n */\n onTransitionProgress?: (\n e: NativeSyntheticEvent<TransitionProgressEventType>\n ) => void;\n /**\n * A callback that gets called when the current screen will appear. This is called as soon as the transition begins.\n */\n onWillAppear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * A callback that gets called when the current screen will disappear. This is called as soon as the transition begins.\n */\n onWillDisappear?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * Boolean indicating whether to prevent current screen from being dismissed.\n * Defaults to `false`.\n *\n * @platform ios\n */\n preventNativeDismiss?: boolean;\n ref?: React.Ref<View>;\n /**\n * How should the screen replacing another screen animate. Defaults to `pop`.\n * The following values are currently supported:\n * - \"push\" – the new screen will perform push animation.\n * - \"pop\" – the new screen will perform pop animation.\n */\n replaceAnimation?: ScreenReplaceTypes;\n /**\n * In which orientation should the screen appear.\n * The following values are currently supported:\n * - \"default\" - resolves to \"all\" without \"portrait_down\" on iOS. On Android, this lets the system decide the best orientation.\n * - \"all\" – all orientations are permitted\n * - \"portrait\" – portrait orientations are permitted\n * - \"portrait_up\" – right-side portrait orientation is permitted\n * - \"portrait_down\" – upside-down portrait orientation is permitted\n * - \"landscape\" – landscape orientations are permitted\n * - \"landscape_left\" – landscape-left orientation is permitted\n * - \"landscape_right\" – landscape-right orientation is permitted\n */\n screenOrientation?: ScreenOrientationTypes;\n /**\n * Describes heights where a sheet can rest.\n * Works only when `stackPresentation` is set to `formSheet`.\n * Defaults to `large`.\n *\n * Available values:\n *\n * - `large` - only large detent level will be allowed\n * - `medium` - only medium detent level will be allowed\n * - `all` - all detent levels will be allowed\n *\n * @platform ios\n */\n sheetAllowedDetents?: SheetDetentTypes;\n /**\n * Whether the sheet should expand to larger detent when scrolling.\n * Works only when `stackPresentation` is set to `formSheet`.\n * Defaults to `true`.\n *\n * @platform ios\n */\n sheetExpandsWhenScrolledToEdge?: boolean;\n /**\n * The corner radius that the sheet will try to render with.\n * Works only when `stackPresentation` is set to `formSheet`.\n *\n * If set to non-negative value it will try to render sheet with provided radius, else it will apply system default.\n *\n * If left unset system default is used.\n *\n * @platform ios\n */\n sheetCornerRadius?: number;\n /**\n * Boolean indicating whether the sheet shows a grabber at the top.\n * Works only when `stackPresentation` is set to `formSheet`.\n * Defaults to `false`.\n *\n * @platform ios\n */\n sheetGrabberVisible?: boolean;\n /**\n * The largest sheet detent for which a view underneath won't be dimmed.\n * Works only when `stackPresentation` is set to `formSheet`.\n *\n * If this prop is set to:\n *\n * - `large` - the view underneath won't be dimmed at any detent level\n * - `medium` - the view underneath will be dimmed only when detent level is `large`\n * - `all` - the view underneath will be dimmed for any detent level\n *\n * Defaults to `all`.\n *\n * @platform ios\n */\n sheetLargestUndimmedDetent?: SheetDetentTypes;\n /**\n * How the screen should appear/disappear when pushed or popped at the top of the stack.\n * The following values are currently supported:\n * - \"default\" – uses a platform default animation\n * - \"fade\" – fades screen in or out\n * - \"fade_from_bottom\" – performs a fade from bottom animation\n * - \"flip\" – flips the screen, requires stackPresentation: \"modal\" (iOS only)\n * - \"simple_push\" – performs a default animation, but without shadow and native header transition (iOS only)\n * - `slide_from_bottom` – performs a slide from bottom animation\n * - \"slide_from_right\" - slide in the new screen from right to left (Android only, resolves to default transition on iOS)\n * - \"slide_from_left\" - slide in the new screen from left to right (Android only, resolves to default transition on iOS)\n * - \"none\" – the screen appears/dissapears without an animation\n */\n stackAnimation?: StackAnimationTypes;\n /**\n * How should the screen be presented.\n * The following values are currently supported:\n * - \"push\" – the new screen will be pushed onto a stack which on iOS means that the default animation will be slide from the side, the animation on Android may vary depending on the OS version and theme.\n * - \"modal\" – the new screen will be presented modally. In addition this allow for a nested stack to be rendered inside such screens.\n * - \"transparentModal\" – the new screen will be presented modally but in addition the second to last screen will remain attached to the stack container such that if the top screen is non opaque the content below can still be seen. If \"modal\" is used instead the below screen will get unmounted as soon as the transition ends.\n * - \"containedModal\" – will use \"UIModalPresentationCurrentContext\" modal style on iOS and will fallback to \"modal\" on Android.\n * - \"containedTransparentModal\" – will use \"UIModalPresentationOverCurrentContext\" modal style on iOS and will fallback to \"transparentModal\" on Android.\n * - \"fullScreenModal\" – will use \"UIModalPresentationFullScreen\" modal style on iOS and will fallback to \"modal\" on Android.\n * - \"formSheet\" – will use \"UIModalPresentationFormSheet\" modal style on iOS and will fallback to \"modal\" on Android.\n */\n stackPresentation?: StackPresentationTypes;\n /**\n * Sets the status bar animation (similar to the `StatusBar` component). Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS.\n */\n statusBarAnimation?: 'none' | 'fade' | 'slide';\n /**\n * Sets the status bar color (similar to the `StatusBar` component). Defaults to initial status bar color.\n *\n * @platform android\n */\n statusBarColor?: ColorValue;\n /**\n * Whether the status bar should be hidden on this screen. Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS. Defaults to `false`.\n */\n statusBarHidden?: boolean;\n /**\n * Sets the status bar color (similar to the `StatusBar` component). Requires enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file on iOS. Defaults to `auto`.\n */\n statusBarStyle?: 'inverted' | 'auto' | 'light' | 'dark';\n /**\n * Sets the translucency of the status bar. Defaults to `false`.\n *\n * @platform android\n */\n statusBarTranslucent?: boolean;\n /**\n * Sets the direction in which you should swipe to dismiss the screen.\n * When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.\n * The following values are supported:\n * - `vertical` – dismiss screen vertically\n * - `horizontal` – dismiss screen horizontally (default)\n *\n * @platform ios\n */\n swipeDirection?: SwipeDirectionTypes;\n /**\n * Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.\n * The duration of `default` and `flip` transitions isn't customizable.\n *\n * @platform ios\n */\n transitionDuration?: number;\n}\n\nexport interface ScreenContainerProps extends ViewProps {\n children?: React.ReactNode;\n /**\n * A prop that gives users an option to switch between using Screens for the navigator (container). All children screens should have the same value of their \"enabled\" prop as their container.\n */\n enabled?: boolean;\n /**\n * A prop to be used in navigators always showing only one screen (providing only `0` or `2` `activityState` values) for better implementation of `ScreenContainer` on iOS.\n */\n hasTwoStates?: boolean;\n}\n\nexport interface ScreenStackProps extends ViewProps {\n children?: React.ReactNode;\n /**\n * A callback that gets called when the current screen finishes its transition.\n */\n onFinishTransitioning?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n}\n\nexport interface ScreenStackHeaderConfigProps extends ViewProps {\n /**\n * Whether to show the back button with custom left side of the header.\n */\n backButtonInCustomView?: boolean;\n /**\n * Controls the color of the navigation header.\n */\n backgroundColor?: ColorValue;\n /**\n * Title to display in the back button.\n * @platform ios.\n */\n backTitle?: string;\n /**\n * Allows for customizing font family to be used for back button title on iOS.\n * @platform ios\n */\n backTitleFontFamily?: string;\n /**\n * Allows for customizing font size to be used for back button title on iOS.\n * @platform ios\n */\n backTitleFontSize?: number;\n /**\n * Whether the back button title should be visible or not. Defaults to `true`.\n * @platform ios\n */\n backTitleVisible?: boolean;\n /**\n * Blur effect to be applied to the header. Works with backgroundColor's alpha < 1.\n * @platform ios\n */\n blurEffect?: BlurEffectTypes;\n /**\n * Pass HeaderLeft, HeaderRight and HeaderTitle\n */\n children?: React.ReactNode;\n /**\n * Controls the color of items rendered on the header. This includes back icon, back text (iOS only) and title text. If you want the title to have different color use titleColor property.\n */\n color?: ColorValue;\n /**\n * Whether the stack should be in rtl or ltr form.\n */\n direction?: 'rtl' | 'ltr';\n /**\n * Boolean indicating whether to show the menu on longPress of iOS >= 14 back button.\n * @platform ios\n */\n disableBackButtonMenu?: boolean;\n /**\n * When set to true the header will be hidden while the parent Screen is on the top of the stack. The default value is false.\n */\n hidden?: boolean;\n /**\n * Boolean indicating whether to hide the back button in header.\n */\n hideBackButton?: boolean;\n /**\n * Boolean indicating whether to hide the elevation shadow or the bottom border on the header.\n */\n hideShadow?: boolean;\n /**\n * Boolean to set native property to prefer large title header (like in iOS setting).\n * For large title to collapse on scroll, the content of the screen should be wrapped in a scrollable view such as `ScrollView` or `FlatList`.\n * If the scrollable area doesn't fill the screen, the large title won't collapse on scroll.\n * Only supported on iOS.\n *\n * @platform ios\n */\n largeTitle?: boolean;\n /**\n * Controls the color of the navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.\n */\n largeTitleBackgroundColor?: ColorValue;\n /**\n * Customize the color to be used for the large title. By default uses the titleColor property.\n * @platform ios\n */\n largeTitleColor?: ColorValue;\n /**\n * Customize font family to be used for the large title.\n * @platform ios\n */\n largeTitleFontFamily?: string;\n /**\n * Customize the size of the font to be used for the large title.\n * @platform ios\n */\n largeTitleFontSize?: number;\n /**\n * Customize the weight of the font to be used for the large title.\n * @platform ios\n */\n largeTitleFontWeight?: string;\n /**\n * Boolean that allows for disabling drop shadow under navigation header when the edge of any scrollable content reaches the matching edge of the navigation bar.\n */\n largeTitleHideShadow?: boolean;\n /**\n * Callback which is executed when screen header is attached\n */\n onAttached?: () => void;\n /**\n * Callback which is executed when screen header is detached\n */\n onDetached?: () => void;\n /**\n * String that can be displayed in the header as a fallback for `headerTitle`.\n */\n title?: string;\n /**\n * Allows for setting text color of the title.\n */\n titleColor?: ColorValue;\n /**\n * Customize font family to be used for the title.\n */\n titleFontFamily?: string;\n /**\n * Customize the size of the font to be used for the title.\n */\n titleFontSize?: number;\n /**\n * Customize the weight of the font to be used for the title.\n */\n titleFontWeight?: string;\n /**\n * A flag to that lets you opt out of insetting the header. You may want to\n * set this to `false` if you use an opaque status bar. Defaults to `true`.\n * Only supported on Android. Insets are always applied on iOS because the\n * header cannot be opaque.\n *\n * @platform android\n */\n topInsetEnabled?: boolean;\n /**\n * Boolean indicating whether the navigation bar is translucent.\n */\n translucent?: boolean;\n}\n\nexport interface SearchBarProps {\n /**\n * Reference to imperatively modify search bar.\n *\n * Currently supported operations are:\n *\n * * `focus` - focuses the search bar\n * * `blur` - removes focus from the search bar\n * * `clearText` - removes any text present in the search bar input field\n * * `setText` - sets the search bar's content to given value\n * * `toggleCancelButton` - depending on passed boolean value, hides or shows cancel button (iOS only)\n */\n ref?: React.RefObject<SearchBarCommands>;\n\n /**\n * The auto-capitalization behavior\n */\n autoCapitalize?: 'none' | 'words' | 'sentences' | 'characters';\n /**\n * Automatically focuses search bar on mount\n *\n * @platform android\n */\n autoFocus?: boolean;\n /**\n * The search field background color\n */\n barTintColor?: ColorValue;\n /**\n * The color for the cursor caret and cancel button text.\n *\n * @platform ios\n */\n tintColor?: ColorValue;\n /**\n * The text to be used instead of default `Cancel` button text\n *\n * @platform ios\n */\n cancelButtonText?: string;\n /**\n * Specifies whether the back button should close search bar's text input or not.\n *\n * @platform android\n */\n disableBackButtonOverride?: boolean;\n /**\n * Indicates whether to hide the navigation bar\n *\n * @platform ios\n */\n hideNavigationBar?: boolean;\n /**\n * Indicates whether to hide the search bar when scrolling\n *\n * @platform ios\n */\n hideWhenScrolling?: boolean;\n\n /**\n * Sets type of the input. Defaults to `text`.\n *\n * @platform android\n */\n inputType?: 'text' | 'phone' | 'number' | 'email';\n /**\n * Indicates whether to obscure the underlying content\n */\n obscureBackground?: boolean;\n /**\n * A callback that gets called when search bar has lost focus\n */\n onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * A callback that gets called when the cancel button is pressed\n *\n * @platform ios\n */\n onCancelButtonPress?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n\n /**\n * A callback that gets called when the text changes. It receives the current text value of the search bar.\n */\n onChangeText?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;\n\n /**\n * A callback that gets called when search bar is closed\n *\n * @platform android\n */\n onClose?: () => void;\n /**\n * A callback that gets called when search bar has received focus\n */\n onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;\n /**\n * A callback that gets called when search bar is opened\n *\n * @platform android\n */\n onOpen?: () => void;\n /**\n * A callback that gets called when the search button is pressed. It receives the current text value of the search bar.\n */\n onSearchButtonPress?: (\n e: NativeSyntheticEvent<TextInputFocusEventData>\n ) => void;\n /**\n * Text displayed when search field is empty\n */\n placeholder?: string;\n /**\n * Position of the search bar\n *\n * Supported values:\n *\n * * `automatic` - the search bar is placed according to current layout\n * * `inline` - the search bar is placed on the trailing edge of navigation bar\n * * `stacked` - the search bar is placed below the other content in navigation bar\n *\n * Defaults to `stacked`\n *\n * @platform iOS (>= 16.0)\n */\n placement?: SearchBarPlacement;\n /**\n * The search field text color\n */\n textColor?: ColorValue;\n /**\n * The search hint text color\n *\n * @plaform android\n */\n hintTextColor?: ColorValue;\n /**\n * The search and close icon color shown in the header\n *\n * @plaform android\n */\n headerIconColor?: ColorValue;\n /**\n * Show the search hint icon when search bar is focused\n *\n * @plaform android\n * @default true\n */\n shouldShowHintSearchIcon?: boolean;\n}\n"],"mappings":""}
@@ -10,6 +10,9 @@ declare type TransitionProgressEvent = Readonly<{
10
10
  closing: Int32;
11
11
  goingForward: Int32;
12
12
  }>;
13
+ declare type HeaderHeightChangeEvent = Readonly<{
14
+ headerHeight: Double;
15
+ }>;
13
16
  declare type GestureResponseDistanceType = Readonly<{
14
17
  start: Float;
15
18
  end: Float;
@@ -28,6 +31,7 @@ export interface NativeProps extends ViewProps {
28
31
  onNativeDismissCancelled?: BubblingEventHandler<ScreenDismissedEvent>;
29
32
  onWillAppear?: BubblingEventHandler<ScreenEvent>;
30
33
  onWillDisappear?: BubblingEventHandler<ScreenEvent>;
34
+ onHeaderHeightChange?: BubblingEventHandler<HeaderHeightChangeEvent>;
31
35
  onTransitionProgress?: BubblingEventHandler<TransitionProgressEvent>;
32
36
  onGestureCancel?: BubblingEventHandler<ScreenEvent>;
33
37
  sheetAllowedDetents?: WithDefault<SheetDetentTypes, 'large'>;
@@ -11,6 +11,8 @@ export { default as NativeStackView } from './views/NativeStackView';
11
11
  */
12
12
  export { default as useHeaderHeight } from './utils/useHeaderHeight';
13
13
  export { default as HeaderHeightContext } from './utils/HeaderHeightContext';
14
+ export { default as useAnimatedHeaderHeight } from './utils/useAnimatedHeaderHeight';
15
+ export { default as AnimatedHeaderHeightContext } from './utils/AnimatedHeaderHeightContext';
14
16
  /**
15
17
  * Types
16
18
  */
@@ -39,6 +39,14 @@ export declare type NativeStackNavigationEventMap = {
39
39
  gestureCancel: {
40
40
  data: undefined;
41
41
  };
42
+ /**
43
+ * Event which fires when a header height gets changed.
44
+ */
45
+ headerHeightChange: {
46
+ data: {
47
+ headerHeight: number;
48
+ };
49
+ };
42
50
  };
43
51
  export declare type NativeStackNavigationProp<ParamList extends ParamListBase, RouteName extends keyof ParamList = string> = NavigationProp<ParamList, RouteName, StackNavigationState<ParamList>, NativeStackNavigationOptions, NativeStackNavigationEventMap> & StackActionHelpers<ParamList>;
44
52
  export declare type NativeStackScreenProps<ParamList extends ParamListBase, RouteName extends keyof ParamList = string> = {
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { Animated } from 'react-native';
3
+ declare const AnimatedHeaderHeightContext: React.Context<Animated.Value | undefined>;
4
+ export default AnimatedHeaderHeightContext;
@@ -0,0 +1,2 @@
1
+ import { Rect } from 'react-native-safe-area-context';
2
+ export default function getStatusBarHeight(topInset: number, dimensions: Rect, isStatusBarTranslucent: boolean): number;
@@ -0,0 +1 @@
1
+ export default function useAnimatedHeaderHeight(): import("react-native/types").Animated.Value;
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import Animated from 'react-native-reanimated';
3
+ declare const _default: React.Context<Animated.SharedValue<number> | undefined>;
4
+ export default _default;
@@ -1,2 +1,3 @@
1
1
  export { default as ReanimatedScreenProvider } from './ReanimatedScreenProvider';
2
2
  export { default as useReanimatedTransitionProgress } from './useReanimatedTransitionProgress';
3
+ export { default as useReanimatedHeaderHeight } from './useReanimatedHeaderHeight';
@@ -0,0 +1,3 @@
1
+ export default function useReanimatedHeaderHeight(): {
2
+ value: number;
3
+ };
@@ -14,6 +14,9 @@ export declare type ScreenReplaceTypes = 'push' | 'pop';
14
14
  export declare type SwipeDirectionTypes = 'vertical' | 'horizontal';
15
15
  export declare type ScreenOrientationTypes = 'default' | 'all' | 'portrait' | 'portrait_up' | 'portrait_down' | 'landscape' | 'landscape_left' | 'landscape_right';
16
16
  export declare type HeaderSubviewTypes = 'back' | 'right' | 'left' | 'center' | 'searchBar';
17
+ export declare type HeaderHeightChangeEventType = {
18
+ headerHeight: number;
19
+ };
17
20
  export declare type TransitionProgressEventType = {
18
21
  progress: number;
19
22
  closing: number;
@@ -45,6 +48,10 @@ export interface ScreenProps extends ViewProps {
45
48
  * Internal boolean used to not attach events used only by native-stack. It prevents non native-stack navigators from sending transition progress from their Screen components.
46
49
  */
47
50
  isNativeStack?: boolean;
51
+ /**
52
+ * Internal boolean used to detect if current header has large title on iOS.
53
+ */
54
+ hasLargeHeader?: boolean;
48
55
  /**
49
56
  * Whether inactive screens should be suspended from re-rendering. Defaults to `false`.
50
57
  * When `enableFreeze()` is run at the top of the application defaults to `true`.
@@ -118,6 +125,10 @@ export interface ScreenProps extends ViewProps {
118
125
  onDismissed?: (e: NativeSyntheticEvent<{
119
126
  dismissCount: number;
120
127
  }>) => void;
128
+ /**
129
+ * A callback that gets called when the header height has changed.
130
+ */
131
+ onHeaderHeightChange?: (e: NativeSyntheticEvent<HeaderHeightChangeEventType>) => void;
121
132
  /**
122
133
  * A callback that gets called after swipe back is canceled.
123
134
  */
@@ -750,10 +750,25 @@ navigation.popToTop();
750
750
 
751
751
  ### Measuring header's height
752
752
 
753
- To measure header's height, you can use `useHeaderHeight` hook.
753
+ To measure header's height, you can use the `useHeaderHeight`, `useAnimatedHeaderHeight` or `useReanimatedHeaderHeight` hook.
754
+ - `useHeaderHeight` returns the static header's height. The value provided by this hook changes when screen appears, when there's a change in header options or screen orientation.
755
+ Use this hook if you're sure your header height won't change dynamically, or when the screen is heavy.
756
+ - `useAnimatedHeaderHeight` dynamically calculates the header's height. The value provided by this hook changes with every view layout (such as shrinking a large header into small one with a ScrollView). It returns an Animated.Value.
757
+ Please beware of using this hook in heavy components, as it may result in performance issues.
758
+ - `useReanimatedHeaderHeight` also dynamically calculates the header's height but uses React Native Reanimated under the hood. It returns an Animated.SharedValue.
759
+ Make sure to wrap your Stack.Navigator with `ReanimatedScreenProvider` before using this hook.
760
+
761
+ We recommend using `useReanimatedHeaderHeight` rather than `useAnimatedHeaderHeight`. See [Shared Values vs Animated.Value](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/shared-values/#shared-values-vs-animatedvalue) section in React Native Reanimated's documentation for full comparison.
754
762
 
755
763
  ```tsx
764
+ // for using useHeaderHeight
756
765
  import {useHeaderHeight} from 'react-native-screens/native-stack';
766
+
767
+ // for using useAnimatedHeaderHeight
768
+ import {useAnimatedHeaderHeight} from 'react-native-screens/native-stack';
769
+
770
+ // for using useReanimatedHeaderHeight
771
+ import {useReanimatedHeaderHeight} from 'react-native-screens/reanimated';
757
772
  ```
758
773
 
759
774
  ## Example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-screens",
3
- "version": "3.25.0",
3
+ "version": "3.27.0",
4
4
  "description": "Native navigation primitives for your React Native app.",
5
5
  "scripts": {
6
6
  "check-types": "tsc --noEmit",
@@ -65,53 +65,51 @@
65
65
  "react-native": "*"
66
66
  },
67
67
  "devDependencies": {
68
- "@babel/core": "^7.11.0",
68
+ "@babel/core": "^7.20.0",
69
+ "@babel/eslint-parser": "7.22.15",
69
70
  "@react-native-community/bob": "^0.17.1",
70
71
  "@react-navigation/native": "^5.8.0",
71
72
  "@react-navigation/stack": "^5.10.0",
72
- "@types/jest": "^26.0.8",
73
- "@types/react": "^18.0.24",
74
- "@types/react-test-renderer": "^16.9.2",
75
- "@typescript-eslint/eslint-plugin": "^5.48.2",
76
- "@typescript-eslint/parser": "^5.48.2",
77
- "@react-native-community/cli": "^9.0.0",
78
- "@react-native-community/cli-platform-android": "^9.0.0",
79
- "@react-native-community/cli-platform-ios": "^9.0.0",
80
- "babel-eslint": "^10.1.0",
81
- "babel-jest": "^26.2.2",
82
- "clang-format": "^1.5.0",
83
- "eslint": "^7.6.0",
84
- "eslint-config-prettier": "^6.11.0",
85
- "eslint-config-standard": "^14.1.1",
86
- "eslint-plugin-import": "^2.22.0",
87
- "eslint-plugin-jest": "^23.20.0",
88
- "eslint-plugin-node": "^11.1.0",
89
- "eslint-plugin-promise": "^4.2.1",
90
- "eslint-plugin-react": "^7.20.5",
91
- "eslint-plugin-react-hooks": "^4.2.0",
92
- "eslint-plugin-react-native": "^3.2.1",
93
- "eslint-plugin-standard": "^4.0.1",
94
- "husky": "^7.0.1",
95
- "jest": "^26.2.2",
96
- "jest-react-native": "18.0.0",
97
- "lint-staged": "^11.1.2",
98
- "metro-react-native-babel-preset": "^0.61.0",
99
- "prettier": "^2.0.4",
73
+ "@types/jest": "^29.3.1",
74
+ "@types/react": "^18.2.21",
75
+ "@types/react-test-renderer": "^18.0.0",
76
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
77
+ "@typescript-eslint/parser": "^6.5.0",
78
+ "@react-native-community/cli": "^11.3.6",
79
+ "@react-native-community/cli-platform-android": "^11.3.6",
80
+ "@react-native-community/cli-platform-ios": "^11.3.6",
81
+ "babel-jest": "^29.6.4",
82
+ "clang-format": "^1.8.0",
83
+ "eslint": "^8.19.0",
84
+ "eslint-config-prettier": "^8.10.0",
85
+ "eslint-config-standard": "^17.1.0",
86
+ "eslint-plugin-import": "^2.28.1",
87
+ "eslint-plugin-jest": "^27.2.3",
88
+ "eslint-plugin-n": "^16.0.2",
89
+ "eslint-plugin-promise": "^6.1.1",
90
+ "eslint-plugin-react": "^7.33.2",
91
+ "eslint-plugin-react-hooks": "^4.6.0",
92
+ "eslint-plugin-react-native": "^4.0.0",
93
+ "husky": "^8.0.3",
94
+ "jest": "^29.3.1",
95
+ "lint-staged": "^14.0.1",
96
+ "metro-react-native-babel-preset": "^0.76.8",
97
+ "prettier": "^2.8.8",
100
98
  "react": "18.2.0",
101
- "react-dom": "^16.13.1",
102
- "react-native": "0.71.0",
99
+ "react-dom": "^18.2.0",
100
+ "react-native": "0.72.4",
103
101
  "react-native-reanimated": "^2.2.0",
104
- "react-native-safe-area-context": "^4.4.1",
102
+ "react-native-safe-area-context": "^4.7.2",
105
103
  "react-native-windows": "^0.64.8",
106
- "react-test-renderer": "^16.13.1",
104
+ "react-test-renderer": "^18.2.0",
107
105
  "release-it": "^15.6.0",
108
106
  "typescript": "4.8.4"
109
107
  },
110
108
  "resolutions": {
111
- "@react-native-community/cli-platform-android": "^9.0.0",
112
- "@react-native-community/cli": "^9.0.0",
113
- "@react-native-community/cli-platform-ios": "^9.0.0",
114
- "@types/react": "^18.0.24"
109
+ "@react-native-community/cli-platform-android": "^11.3.6",
110
+ "@react-native-community/cli": "^11.3.6",
111
+ "@react-native-community/cli-platform-ios": "^11.3.6",
112
+ "@types/react": "^18.2.21"
115
113
  },
116
114
  "lint-staged": {
117
115
  "{src,Example}/**/*.{js,ts,tsx}": "yarn format-js",
@@ -21,6 +21,10 @@ type TransitionProgressEvent = Readonly<{
21
21
  goingForward: Int32;
22
22
  }>;
23
23
 
24
+ type HeaderHeightChangeEvent = Readonly<{
25
+ headerHeight: Double;
26
+ }>;
27
+
24
28
  type GestureResponseDistanceType = Readonly<{
25
29
  start: Float;
26
30
  end: Float;
@@ -61,6 +65,7 @@ export interface NativeProps extends ViewProps {
61
65
  onNativeDismissCancelled?: BubblingEventHandler<ScreenDismissedEvent>;
62
66
  onWillAppear?: BubblingEventHandler<ScreenEvent>;
63
67
  onWillDisappear?: BubblingEventHandler<ScreenEvent>;
68
+ onHeaderHeightChange?: BubblingEventHandler<HeaderHeightChangeEvent>;
64
69
  onTransitionProgress?: BubblingEventHandler<TransitionProgressEvent>;
65
70
  onGestureCancel?: BubblingEventHandler<ScreenEvent>;
66
71
  sheetAllowedDetents?: WithDefault<SheetDetentTypes, 'large'>;
@@ -5,7 +5,6 @@ import {
5
5
  Image,
6
6
  ImageProps,
7
7
  Platform,
8
- requireNativeComponent,
9
8
  StyleProp,
10
9
  StyleSheet,
11
10
  UIManager,
@@ -137,28 +136,29 @@ const ScreensNativeModules = {
137
136
  NativeScreenNavigationContainerValue =
138
137
  NativeScreenNavigationContainerValue ||
139
138
  (Platform.OS === 'ios'
140
- ? requireNativeComponent('RNSScreenNavigationContainer')
139
+ ? require('./fabric/ScreenNavigationContainerNativeComponent').default
141
140
  : this.NativeScreenContainer);
142
141
  return NativeScreenNavigationContainerValue;
143
142
  },
144
143
 
145
144
  get NativeScreenStack() {
146
145
  NativeScreenStack =
147
- NativeScreenStack || requireNativeComponent('RNSScreenStack');
146
+ NativeScreenStack ||
147
+ require('./fabric/ScreenStackNativeComponent').default;
148
148
  return NativeScreenStack;
149
149
  },
150
150
 
151
151
  get NativeScreenStackHeaderConfig() {
152
152
  NativeScreenStackHeaderConfig =
153
153
  NativeScreenStackHeaderConfig ||
154
- requireNativeComponent('RNSScreenStackHeaderConfig');
154
+ require('./fabric/ScreenStackHeaderConfigNativeComponent').default;
155
155
  return NativeScreenStackHeaderConfig;
156
156
  },
157
157
 
158
158
  get NativeScreenStackHeaderSubview() {
159
159
  NativeScreenStackHeaderSubview =
160
160
  NativeScreenStackHeaderSubview ||
161
- requireNativeComponent('RNSScreenStackHeaderSubview');
161
+ require('./fabric/ScreenStackHeaderSubviewNativeComponent').default;
162
162
  return NativeScreenStackHeaderSubview;
163
163
  },
164
164
 
@@ -167,6 +167,7 @@ const ScreensNativeModules = {
167
167
  NativeSearchBar || require('./fabric/SearchBarNativeComponent').default;
168
168
  return NativeSearchBar;
169
169
  },
170
+
170
171
  get NativeSearchBarCommands() {
171
172
  NativeSearchBarCommands =
172
173
  NativeSearchBarCommands ||
@@ -176,7 +177,8 @@ const ScreensNativeModules = {
176
177
 
177
178
  get NativeFullWindowOverlay() {
178
179
  NativeFullWindowOverlay =
179
- NativeFullWindowOverlay || requireNativeComponent('RNSFullWindowOverlay');
180
+ NativeFullWindowOverlay ||
181
+ require('./fabric/FullWindowOverlayNativeComponent').default;
180
182
  return NativeFullWindowOverlay;
181
183
  },
182
184
  };
@@ -346,8 +348,7 @@ class InnerScreen extends React.Component<ScreenProps> {
346
348
  (() => {
347
349
  // for internal use
348
350
  })
349
- }
350
- >
351
+ }>
351
352
  {!isNativeStack ? ( // see comment of this prop in types.tsx for information why it is needed
352
353
  children
353
354
  ) : (
@@ -356,8 +357,7 @@ class InnerScreen extends React.Component<ScreenProps> {
356
357
  progress: this.progress,
357
358
  closing: this.closing,
358
359
  goingForward: this.goingForward,
359
- }}
360
- >
360
+ }}>
361
361
  {children}
362
362
  </TransitionProgressContext.Provider>
363
363
  )}
@@ -408,8 +408,7 @@ function FullWindowOverlay(props: { children: ReactNode }) {
408
408
  }
409
409
  return (
410
410
  <ScreensNativeModules.NativeFullWindowOverlay
411
- style={{ position: 'absolute', width: '100%', height: '100%' }}
412
- >
411
+ style={{ position: 'absolute', width: '100%', height: '100%' }}>
413
412
  {props.children}
414
413
  </ScreensNativeModules.NativeFullWindowOverlay>
415
414
  );
@@ -429,8 +428,7 @@ const styles = StyleSheet.create({
429
428
  const ScreenStackHeaderBackButtonImage = (props: ImageProps): JSX.Element => (
430
429
  <ScreensNativeModules.NativeScreenStackHeaderSubview
431
430
  type="back"
432
- style={styles.headerSubview}
433
- >
431
+ style={styles.headerSubview}>
434
432
  <Image resizeMode="center" fadeDuration={0} {...props} />
435
433
  </ScreensNativeModules.NativeScreenStackHeaderSubview>
436
434
  );
@@ -455,31 +453,31 @@ class SearchBar extends React.Component<SearchBarProps> {
455
453
  }
456
454
 
457
455
  blur() {
458
- this._callMethodWithRef((ref) =>
456
+ this._callMethodWithRef(ref =>
459
457
  ScreensNativeModules.NativeSearchBarCommands.blur(ref)
460
458
  );
461
459
  }
462
460
 
463
461
  focus() {
464
- this._callMethodWithRef((ref) =>
462
+ this._callMethodWithRef(ref =>
465
463
  ScreensNativeModules.NativeSearchBarCommands.focus(ref)
466
464
  );
467
465
  }
468
466
 
469
467
  toggleCancelButton(flag: boolean) {
470
- this._callMethodWithRef((ref) =>
468
+ this._callMethodWithRef(ref =>
471
469
  ScreensNativeModules.NativeSearchBarCommands.toggleCancelButton(ref, flag)
472
470
  );
473
471
  }
474
472
 
475
473
  clearText() {
476
- this._callMethodWithRef((ref) =>
474
+ this._callMethodWithRef(ref =>
477
475
  ScreensNativeModules.NativeSearchBarCommands.clearText(ref)
478
476
  );
479
477
  }
480
478
 
481
479
  setText(text: string) {
482
- this._callMethodWithRef((ref) =>
480
+ this._callMethodWithRef(ref =>
483
481
  ScreensNativeModules.NativeSearchBarCommands.setText(ref, text)
484
482
  );
485
483
  }
@@ -14,6 +14,9 @@ export { default as NativeStackView } from './views/NativeStackView';
14
14
  export { default as useHeaderHeight } from './utils/useHeaderHeight';
15
15
  export { default as HeaderHeightContext } from './utils/HeaderHeightContext';
16
16
 
17
+ export { default as useAnimatedHeaderHeight } from './utils/useAnimatedHeaderHeight';
18
+ export { default as AnimatedHeaderHeightContext } from './utils/AnimatedHeaderHeightContext';
19
+
17
20
  /**
18
21
  * Types
19
22
  */
@@ -10,7 +10,12 @@ import {
10
10
  RouteProp,
11
11
  } from '@react-navigation/native';
12
12
  import * as React from 'react';
13
- import { ImageSourcePropType, StyleProp, ViewStyle, ColorValue } from 'react-native';
13
+ import {
14
+ ImageSourcePropType,
15
+ StyleProp,
16
+ ViewStyle,
17
+ ColorValue,
18
+ } from 'react-native';
14
19
  import {
15
20
  ScreenProps,
16
21
  ScreenStackHeaderConfigProps,
@@ -41,6 +46,10 @@ export type NativeStackNavigationEventMap = {
41
46
  * Event which fires when a swipe back is canceled on iOS.
42
47
  */
43
48
  gestureCancel: { data: undefined };
49
+ /**
50
+ * Event which fires when a header height gets changed.
51
+ */
52
+ headerHeightChange: { data: { headerHeight: number } };
44
53
  };
45
54
 
46
55
  export type NativeStackNavigationProp<
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { Animated } from 'react-native';
3
+
4
+ const AnimatedHeaderHeightContext = React.createContext<
5
+ Animated.Value | undefined
6
+ >(undefined);
7
+
8
+ export default AnimatedHeaderHeightContext;
@@ -36,7 +36,7 @@ const initialMetrics =
36
36
  export default function SafeAreaProviderCompat({ children, style }: Props) {
37
37
  return (
38
38
  <SafeAreaInsetsContext.Consumer>
39
- {(insets) => {
39
+ {insets => {
40
40
  if (insets) {
41
41
  // If we already have insets, don't wrap the stack in another safe area provider
42
42
  // This avoids an issue with updates at the cost of potentially incorrect values
@@ -0,0 +1,22 @@
1
+ import { Rect } from 'react-native-safe-area-context';
2
+ import { Platform } from 'react-native';
3
+
4
+ export default function getStatusBarHeight(
5
+ topInset: number,
6
+ dimensions: Rect,
7
+ isStatusBarTranslucent: boolean
8
+ ) {
9
+ if (Platform.OS === 'ios') {
10
+ // It looks like some iOS devices don't have strictly set status bar height to 44.
11
+ // Thus, if the top inset is higher than 50, then the device should have a dynamic island.
12
+ // On models with Dynamic Island the status bar height is smaller than the safe area top inset by 5 pixels.
13
+ // See https://developer.apple.com/forums/thread/662466 for more details about status bar height.
14
+ const hasDynamicIsland = topInset > 50;
15
+ return hasDynamicIsland ? topInset - 5 : topInset;
16
+ } else if (Platform.OS === 'android') {
17
+ // On Android we should also rely on frame's y-axis position, as topInset is 0 on visible status bar.
18
+ return isStatusBarTranslucent ? topInset : dimensions.y;
19
+ }
20
+
21
+ return topInset;
22
+ }
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+
3
+ import AnimatedHeaderHeightContext from './AnimatedHeaderHeightContext';
4
+
5
+ export default function useAnimatedHeaderHeight() {
6
+ const animatedValue = React.useContext(AnimatedHeaderHeightContext);
7
+
8
+ if (animatedValue === undefined) {
9
+ throw new Error(
10
+ "Couldn't find the header height. Are you inside a screen in a navigator with a header?"
11
+ );
12
+ }
13
+
14
+ return animatedValue;
15
+ }
@@ -140,8 +140,7 @@ export default function HeaderConfig({
140
140
  topInsetEnabled={headerTopInsetEnabled}
141
141
  translucent={headerTranslucent === true}
142
142
  onAttached={handleAttached}
143
- onDetached={handleDetached}
144
- >
143
+ onDetached={handleDetached}>
145
144
  {headerRight !== undefined ? (
146
145
  <ScreenStackHeaderRightView>
147
146
  {headerRight({ tintColor })}