react-native-screens 3.31.1 → 3.33.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 (203) hide show
  1. package/README.md +21 -11
  2. package/RNScreens.podspec +11 -52
  3. package/android/CMakeLists.txt +48 -4
  4. package/android/build.gradle +16 -9
  5. package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +25 -16
  6. package/android/src/fabric/java/com/swmansion/rnscreens/NativeProxy.kt +53 -0
  7. package/android/src/main/cpp/NativeProxy.cpp +51 -0
  8. package/android/src/main/cpp/NativeProxy.h +35 -0
  9. package/android/src/main/cpp/OnLoad.cpp +8 -0
  10. package/android/src/main/cpp/jni-adapter.cpp +86 -93
  11. package/android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt +7 -2
  12. package/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +6 -1
  13. package/android/src/main/java/com/swmansion/rnscreens/FragmentBackPressOverrider.kt +2 -2
  14. package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +36 -17
  15. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +150 -40
  16. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +52 -30
  17. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainerViewManager.kt +27 -4
  18. package/android/src/main/java/com/swmansion/rnscreens/ScreenEventDispatcher.kt +10 -2
  19. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +56 -27
  20. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragmentWrapper.kt +8 -1
  21. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +50 -19
  22. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +63 -39
  23. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragmentWrapper.kt +4 -0
  24. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +88 -57
  25. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +131 -36
  26. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt +19 -4
  27. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt +16 -10
  28. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackViewManager.kt +28 -25
  29. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +177 -77
  30. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +77 -25
  31. package/android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt +31 -9
  32. package/android/src/main/java/com/swmansion/rnscreens/ScreensShadowNode.kt +3 -1
  33. package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +160 -54
  34. package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +29 -22
  35. package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +7 -2
  36. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderAttachedEvent.kt +4 -1
  37. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderBackButtonClickedEvent.kt +4 -1
  38. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderDetachedEvent.kt +4 -1
  39. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderHeightChangeEvent.kt +5 -6
  40. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenAppearEvent.kt +4 -1
  41. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDisappearEvent.kt +4 -1
  42. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDismissedEvent.kt +8 -4
  43. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenTransitionProgressEvent.kt +7 -6
  44. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillAppearEvent.kt +4 -1
  45. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillDisappearEvent.kt +4 -1
  46. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarBlurEvent.kt +5 -2
  47. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarChangeTextEvent.kt +4 -3
  48. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarCloseEvent.kt +4 -1
  49. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarFocusEvent.kt +5 -2
  50. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarOpenEvent.kt +4 -1
  51. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarSearchButtonPressEvent.kt +9 -4
  52. package/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt +4 -1
  53. package/android/src/main/java/com/swmansion/rnscreens/utils/DeviceUtils.kt +1 -5
  54. package/android/src/main/java/com/swmansion/rnscreens/utils/ScreenDummyLayoutHelper.kt +214 -0
  55. package/android/src/main/jni/CMakeLists.txt +5 -4
  56. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenContainerManagerDelegate.java +25 -0
  57. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenContainerManagerInterface.java +16 -0
  58. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerDelegate.java +6 -0
  59. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerInterface.java +2 -0
  60. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +3 -0
  61. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +1 -0
  62. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java +99 -0
  63. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerInterface.java +37 -0
  64. package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +10 -5
  65. package/android/src/paper/java/com/swmansion/rnscreens/NativeProxy.kt +19 -0
  66. package/android/src/paper/java/com/swmansion/rnscreens/NativeScreensModuleSpec.java +4 -0
  67. package/common/cpp/react/renderer/components/rnscreens/FrameCorrectionModes.h +51 -0
  68. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenComponentDescriptor.h +8 -9
  69. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.cpp +2 -1
  70. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.h +9 -8
  71. package/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h +147 -10
  72. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +51 -1
  73. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h +29 -7
  74. package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.cpp +22 -1
  75. package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h +30 -10
  76. package/common/cpp/react/renderer/components/rnscreens/utils/RectUtil.h +36 -0
  77. package/cpp/RNSScreenRemovalListener.cpp +25 -0
  78. package/cpp/RNSScreenRemovalListener.h +20 -0
  79. package/cpp/RNScreensTurboModule.cpp +31 -23
  80. package/cpp/RNScreensTurboModule.h +17 -20
  81. package/ios/RNSConvert.h +7 -0
  82. package/ios/RNSConvert.mm +24 -0
  83. package/ios/RNSModalScreen.mm +22 -0
  84. package/ios/RNSModule.mm +2 -3
  85. package/ios/RNSScreen.h +2 -1
  86. package/ios/RNSScreen.mm +35 -19
  87. package/ios/RNSScreenContainer.mm +1 -1
  88. package/ios/RNSScreenStack.mm +59 -54
  89. package/ios/RNSScreenStackAnimator.mm +43 -6
  90. package/ios/RNSScreenStackHeaderConfig.h +2 -0
  91. package/ios/RNSScreenStackHeaderConfig.mm +93 -28
  92. package/ios/RNSScreenStackHeaderSubview.mm +8 -0
  93. package/ios/RNSSearchBar.h +5 -5
  94. package/ios/RNSSearchBar.mm +11 -11
  95. package/ios/utils/RCTSurfaceTouchHandler+RNSUtility.h +15 -0
  96. package/ios/utils/RCTSurfaceTouchHandler+RNSUtility.mm +14 -0
  97. package/ios/utils/RCTTouchHandler+RNSUtility.h +15 -0
  98. package/ios/utils/RCTTouchHandler+RNSUtility.mm +15 -0
  99. package/ios/utils/UIView+RNSUtility.h +23 -0
  100. package/ios/utils/UIView+RNSUtility.mm +55 -0
  101. package/lib/commonjs/components/Screen.js +119 -127
  102. package/lib/commonjs/components/Screen.js.map +1 -1
  103. package/lib/commonjs/components/ScreenStack.js +8 -1
  104. package/lib/commonjs/components/ScreenStack.js.map +1 -1
  105. package/lib/commonjs/components/SearchBar.js +39 -36
  106. package/lib/commonjs/components/SearchBar.js.map +1 -1
  107. package/lib/commonjs/fabric/ModalScreenNativeComponent.js.map +1 -1
  108. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
  109. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  110. package/lib/commonjs/native-stack/views/HeaderConfig.js +2 -0
  111. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  112. package/lib/commonjs/native-stack/views/NativeStackView.js +4 -0
  113. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  114. package/lib/module/components/Screen.js +118 -126
  115. package/lib/module/components/Screen.js.map +1 -1
  116. package/lib/module/components/ScreenStack.js +8 -1
  117. package/lib/module/components/ScreenStack.js.map +1 -1
  118. package/lib/module/components/SearchBar.js +39 -36
  119. package/lib/module/components/SearchBar.js.map +1 -1
  120. package/lib/module/fabric/ModalScreenNativeComponent.js.map +1 -1
  121. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
  122. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  123. package/lib/module/native-stack/views/HeaderConfig.js +2 -0
  124. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  125. package/lib/module/native-stack/views/NativeStackView.js +4 -0
  126. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  127. package/lib/typescript/TransitionProgressContext.d.ts +1 -1
  128. package/lib/typescript/TransitionProgressContext.d.ts.map +1 -1
  129. package/lib/typescript/components/Screen.d.ts +3 -14
  130. package/lib/typescript/components/Screen.d.ts.map +1 -1
  131. package/lib/typescript/components/ScreenStack.d.ts.map +1 -1
  132. package/lib/typescript/components/SearchBar.d.ts +14 -21
  133. package/lib/typescript/components/SearchBar.d.ts.map +1 -1
  134. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts +12 -10
  135. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts.map +1 -1
  136. package/lib/typescript/fabric/ScreenNativeComponent.d.ts +12 -10
  137. package/lib/typescript/fabric/ScreenNativeComponent.d.ts.map +1 -1
  138. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +5 -3
  139. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -1
  140. package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts +1 -1
  141. package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts.map +1 -1
  142. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts +1 -1
  143. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts.map +1 -1
  144. package/lib/typescript/fabric/SearchBarNativeComponent.d.ts +9 -9
  145. package/lib/typescript/fabric/SearchBarNativeComponent.d.ts.map +1 -1
  146. package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts +1 -1
  147. package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts.map +1 -1
  148. package/lib/typescript/native-stack/types.d.ts +39 -14
  149. package/lib/typescript/native-stack/types.d.ts.map +1 -1
  150. package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts +1 -1
  151. package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts.map +1 -1
  152. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -1
  153. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts.map +1 -1
  154. package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts +1 -1
  155. package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts.map +1 -1
  156. package/lib/typescript/native-stack/views/HeaderConfig.d.ts +2 -2
  157. package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -1
  158. package/lib/typescript/native-stack/views/NativeStackView.d.ts +1 -1
  159. package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -1
  160. package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts +1 -1
  161. package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts.map +1 -1
  162. package/lib/typescript/types.d.ts +39 -13
  163. package/lib/typescript/types.d.ts.map +1 -1
  164. package/lib/typescript/useTransitionProgress.d.ts +3 -3
  165. package/native-stack/README.md +116 -98
  166. package/package.json +16 -7
  167. package/react-native.config.js +17 -15
  168. package/src/TransitionProgressContext.tsx +1 -1
  169. package/src/components/Screen.tsx +31 -37
  170. package/src/components/ScreenStack.tsx +11 -1
  171. package/src/components/ScreenStackHeaderConfig.tsx +5 -5
  172. package/src/components/ScreenStackHeaderConfig.web.tsx +6 -6
  173. package/src/components/SearchBar.tsx +77 -65
  174. package/src/core.ts +1 -1
  175. package/src/fabric/ModalScreenNativeComponent.ts +2 -0
  176. package/src/fabric/ScreenNativeComponent.ts +2 -0
  177. package/src/fabric/ScreenNavigationContainerNativeComponent.ts +1 -1
  178. package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +4 -1
  179. package/src/fabric/ScreenStackHeaderSubviewNativeComponent.ts +1 -1
  180. package/src/fabric/SearchBarNativeComponent.ts +7 -7
  181. package/src/gesture-handler/ScreenGestureDetector.tsx +5 -5
  182. package/src/gesture-handler/constraints.ts +5 -5
  183. package/src/gesture-handler/fabricUtils.ts +1 -1
  184. package/src/native-stack/contexts/GHContext.tsx +1 -1
  185. package/src/native-stack/navigators/createNativeStackNavigator.tsx +3 -3
  186. package/src/native-stack/types.tsx +29 -4
  187. package/src/native-stack/utils/getDefaultHeaderHeight.tsx +1 -1
  188. package/src/native-stack/utils/getStatusBarHeight.tsx +1 -1
  189. package/src/native-stack/utils/useAnimatedHeaderHeight.tsx +1 -1
  190. package/src/native-stack/utils/useBackPressSubscription.tsx +1 -1
  191. package/src/native-stack/utils/useHeaderHeight.tsx +1 -1
  192. package/src/native-stack/views/FontProcessor.tsx +1 -1
  193. package/src/native-stack/views/HeaderConfig.tsx +3 -1
  194. package/src/native-stack/views/NativeStackView.tsx +13 -9
  195. package/src/reanimated/ReanimatedHeaderHeightContext.tsx +1 -1
  196. package/src/reanimated/ReanimatedNativeStackScreen.tsx +5 -5
  197. package/src/reanimated/ReanimatedScreen.tsx +2 -2
  198. package/src/reanimated/ReanimatedScreenProvider.tsx +1 -1
  199. package/src/reanimated/useReanimatedHeaderHeight.tsx +1 -1
  200. package/src/reanimated/useReanimatedTransitionProgress.tsx +1 -1
  201. package/src/types.tsx +31 -5
  202. package/src/useTransitionProgress.tsx +1 -1
  203. package/windows/README.md +4 -1
@@ -1,6 +1,6 @@
1
1
  # Native Stack Navigator
2
2
 
3
- > **_NOTE:_** This README is dedicated for using `native-stack` with React Navigation **v5**. For using `native-stack` in React Navigation **v6** please refer to the [Native Stack Navigator part of React Navigation documentation](https://reactnavigation.org/docs/native-stack-navigator).
3
+ > **_NOTE:_** This README is dedicated for using `native-stack` with React Navigation **v5**. For using `native-stack` in React Navigation **v6** please refer to the [Native Stack Navigator part of React Navigation documentation](https://reactnavigation.org/docs/native-stack-navigator).
4
4
 
5
5
  Provides a way for your app to transition between screens where each new screen is placed on top of a stack.
6
6
 
@@ -79,17 +79,31 @@ String that applies `rtl` or `ltr` form to the stack. On Android, you have to ad
79
79
 
80
80
  Boolean indicating whether to show the menu on longPress of iOS >= 14 back button.
81
81
 
82
+ #### `backButtonDisplayMode` (iOS only)
83
+
84
+ Enum value indicating display mode of **default** back button. It works on iOS >= 14, and is used only when none of: `backTitleFontFamily`, `backTitleFontSize`, `disableBackButtonMenu` or `backTitle` is set. Otherwise, when the button is customized, under the hood we use iOS native `backButtonItem` which overrides `backButtonDisplayMode`. Read more [#2123](https://github.com/software-mansion/react-native-screens/pull/2123). Possible options:
85
+
86
+ - `default` – show given back button previous controller title, system generic or just icon based on available space
87
+ - `generic` – show given system generic or just icon based on available space
88
+ - `minimal` – show just an icon
89
+
82
90
  #### `fullScreenSwipeEnabled` (iOS only)
83
91
 
84
92
  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. 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. Defaults to `false`.
85
93
 
94
+ ### `fullScreenSwipeShadowEnabled` (iOS only)
95
+
96
+ Boolean indicating whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
97
+ doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
98
+ default iOS shadow. Defaults to `false`.
99
+
86
100
  #### `gestureEnabled` (iOS only)
87
101
 
88
102
  Whether you can use gestures to dismiss this screen. Defaults to `true`.
89
103
 
90
104
  #### `gestureResponseDistance` (iOS only)
91
105
 
92
- Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`. The responsive area is covered with 4 values: `start`, `end`, `top`, `bottom`. Example usage:
106
+ Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`. The responsive area is covered with 4 values: `start`, `end`, `top`, `bottom`. Example usage:
93
107
 
94
108
  ```tsx
95
109
  gestureResponseDistance: {
@@ -189,13 +203,13 @@ Style object for header title. Supported properties:
189
203
 
190
204
  #### `headerTopInsetEnabled` (Android only)
191
205
 
192
- A Boolean to that lets you opt out of insetting the header. You may want to * set this to `false` if you use an opaque status bar. Defaults to `true`. Insets are always applied on iOS because the header cannot be opaque.
206
+ A Boolean to that lets you opt out of insetting the header. You may want to \* set this to `false` if you use an opaque status bar. Defaults to `true`. Insets are always applied on iOS because the header cannot be opaque.
193
207
 
194
208
  #### `headerTranslucent`
195
209
 
196
210
  Boolean indicating whether the navigation bar is translucent.
197
211
 
198
- #### `hideKeyboardOnSwipe` (iOS only)
212
+ #### `hideKeyboardOnSwipe` (iOS only)
199
213
 
200
214
  Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.
201
215
 
@@ -222,14 +236,15 @@ Sets the visibility of the navigation bar. Defaults to `false`.
222
236
 
223
237
  How should the screen replacing another screen animate.
224
238
  The following values are currently supported:
225
- - `push` – the new screen will perform push animation.
226
- - `pop` – the new screen will perform pop animation.
239
+
240
+ - `push` – the new screen will perform push animation.
241
+ - `pop` – the new screen will perform pop animation.
227
242
 
228
243
  Defaults to `pop`.
229
244
 
230
245
  #### `sheetAllowedDetents` (iOS only)
231
246
 
232
- Describes heights where a sheet can rest.
247
+ Describes heights where a sheet can rest.
233
248
  Works only when `stackPresentation` is set to `formSheet`.
234
249
 
235
250
  Available values:
@@ -264,16 +279,16 @@ Defaults to `false`.
264
279
 
265
280
  #### `sheetLargestUndimmedDetent` (iOS only)
266
281
 
267
- The largest sheet detent for which a view underneath won't be dimmed.
268
- Works only when `stackPresentation` is set to `formSheet`.
282
+ The largest sheet detent for which a view underneath won't be dimmed.
283
+ Works only when `stackPresentation` is set to `formSheet`.
269
284
 
270
- If this prop is set to:
285
+ If this prop is set to:
271
286
 
272
- - `large` - the view underneath won't be dimmed at any detent level
273
- - `medium` - the view underneath will be dimmed only when detent level is `large`
274
- - `all` - the view underneath will be dimmed for any detent level
287
+ - `large` - the view underneath won't be dimmed at any detent level
288
+ - `medium` - the view underneath will be dimmed only when detent level is `large`
289
+ - `all` - the view underneath will be dimmed for any detent level
275
290
 
276
- Defaults to `all`.
291
+ Defaults to `all`.
277
292
 
278
293
  #### `stackAnimation`
279
294
 
@@ -311,6 +326,7 @@ Using `containedModal` and `containedTransparentModal` with other types of modal
311
326
  #### `swipeDirection` (iOS only)
312
327
 
313
328
  Sets the direction in which you should swipe to dismiss the screen. The following values are supported:
329
+
314
330
  - `vertical` – dismiss screen vertically
315
331
  - `horizontal` – dismiss screen horizontally (default)
316
332
 
@@ -335,25 +351,28 @@ Defaults to `false`. When `enableFreeze()` is run at the top of the application
335
351
  #### `useTransitionProgress`
336
352
 
337
353
  Hook providing context value of transition progress of the current screen to be used with `react-native` `Animated`. It consists of 2 values:
354
+
338
355
  - `progress` - `Animated.Value` between `0.0` and `1.0` with the progress of the current transition.
339
356
  - `closing` - `Animated.Value` of `1` or `0` indicating if the current screen is being navigated into or from.
340
357
  - `goingForward` - `Animated.Value` of `1` or `0` indicating if the current transition is pushing or removing screens.
341
358
 
342
359
  ```jsx
343
- import {Animated} from 'react-native';
344
- import {useTransitionProgress} from 'react-native-screens';
360
+ import { Animated } from 'react-native';
361
+ import { useTransitionProgress } from 'react-native-screens';
345
362
 
346
363
  function Home() {
347
- const {progress} = useTransitionProgress();
364
+ const { progress } = useTransitionProgress();
348
365
 
349
366
  const opacity = progress.interpolate({
350
367
  inputRange: [0, 0.5, 1],
351
- outputRange: [1.0, 0.0 ,1.0],
368
+ outputRange: [1.0, 0.0, 1.0],
352
369
  extrapolate: 'clamp',
353
370
  });
354
371
 
355
372
  return (
356
- <Animated.View style={{opacity, height: 50, width: '100%', backgroundColor: 'green'}} />
373
+ <Animated.View
374
+ style={{ opacity, height: 50, width: '100%', backgroundColor: 'green' }}
375
+ />
357
376
  );
358
377
  }
359
378
  ```
@@ -361,14 +380,15 @@ function Home() {
361
380
  #### `useReanimatedTransitionProgress`
362
381
 
363
382
  A callback called every frame during the transition of screens to be used with `react-native-reanimated` version `2.x`. It consists of 2 shared values:
383
+
364
384
  - `progress` - between `0.0` and `1.0` with the progress of the current transition.
365
- - `closing` - `1` or `0` indicating if the current screen is being navigated into or from.
385
+ - `closing` - `1` or `0` indicating if the current screen is being navigated into or from.
366
386
  - `goingForward` - `1` or `0` indicating if the current transition is pushing or removing screens.
367
387
 
368
388
  In order to use it, you need to have `react-native-reanimated` version `2.x` installed in your project and wrap your code with `ReanimatedScreenProvider`, like this:
369
389
 
370
390
  ```jsx
371
- import {ReanimatedScreenProvider} from 'react-native-screens/reanimated';
391
+ import { ReanimatedScreenProvider } from 'react-native-screens/reanimated';
372
392
 
373
393
  export default function App() {
374
394
  return (
@@ -382,12 +402,20 @@ export default function App() {
382
402
  Then you can use `useReanimatedTransitionProgress` to get the shared values:
383
403
 
384
404
  ```jsx
385
- import {useReanimatedTransitionProgress} from 'react-native-screens/reanimated';
386
- import Animated, {useAnimatedStyle, useDerivedValue} from 'react-native-reanimated';
405
+ import { useReanimatedTransitionProgress } from 'react-native-screens/reanimated';
406
+ import Animated, {
407
+ useAnimatedStyle,
408
+ useDerivedValue,
409
+ } from 'react-native-reanimated';
387
410
 
388
411
  function Home() {
389
412
  const reaProgress = useReanimatedTransitionProgress();
390
- const sv = useDerivedValue(() => (reaProgress.progress.value < 0.5 ? (reaProgress.progress.value * 50) : ((1 - reaProgress.progress.value) * 50)) + 50);
413
+ const sv = useDerivedValue(
414
+ () =>
415
+ (reaProgress.progress.value < 0.5
416
+ ? reaProgress.progress.value * 50
417
+ : (1 - reaProgress.progress.value) * 50) + 50,
418
+ );
391
419
  const reaStyle = useAnimatedStyle(() => {
392
420
  return {
393
421
  width: sv.value,
@@ -396,9 +424,7 @@ function Home() {
396
424
  };
397
425
  });
398
426
 
399
- return (
400
- <Animated.View style={reaStyle} />
401
- );
427
+ return <Animated.View style={reaStyle} />;
402
428
  }
403
429
  ```
404
430
 
@@ -406,10 +432,11 @@ function Home() {
406
432
 
407
433
  With `native-stack`, the status bar and screen orientation can be managed by `UIViewController` on iOS. On Android, the status bar and screen orientation can be managed by `FragmentActivity`. On iOS, it requires:
408
434
 
409
- 1. For status bar managment: enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file (it disables the option to use React Native's `StatusBar` component).
435
+ 1. For status bar managment: enabling (or deleting) `View controller-based status bar appearance` in your Info.plist file (it disables the option to use React Native's `StatusBar` component).
410
436
  2. For both status bar and orientation managment: adding `#import <RNScreens/UIViewController+RNScreens.h>` in your project's `AppDelegate.m` (you can see this change applied in the `AppDelegate.m` of `Example` project).
411
437
 
412
438
  On Android, no additional setup is required, although, you should keep in mind that once you set the orientation or status bar props, `react-native-screens` will manage them on every screen, so you shouldn't use other methods of manipulating them then.
439
+
413
440
  #### `screenOrientation`
414
441
 
415
442
  Sets the current screen's available orientations and forces rotation if current orientation is not included. On iOS, if you have supported orientations set in `info.plist`, they will take precedence over this prop. Possible values:
@@ -455,14 +482,14 @@ Sets the translucency of the status bar (similar to the `StatusBar` component).
455
482
 
456
483
  The search bar is just a `searchBar` property that can be specified in the navigator's `screenOptions` or an individual screen's `options`. Search bars are rarely static so normally it is controlled by passing an object to `searchBar` navigation option in the component's body.
457
484
 
458
- Example:
485
+ Example:
459
486
 
460
487
  ```js
461
488
  React.useLayoutEffect(() => {
462
489
  navigation.setOptions({
463
490
  searchBar: {
464
491
  // search bar options
465
- }
492
+ },
466
493
  });
467
494
  }, [navigation]);
468
495
  ```
@@ -503,7 +530,7 @@ The text to be used instead of default `Cancel` button text.
503
530
 
504
531
  #### `disableBackButtonOverride` (Android only)
505
532
 
506
- Default behavior is to prevent screen from going back when search bar is open (`disableBackButtonOverride: false`). If you don't want this to happen set `disableBackButtonOverride` to `true`
533
+ Default behavior is to prevent screen from going back when search bar is open (`disableBackButtonOverride: false`). If you don't want this to happen set `disableBackButtonOverride` to `true`
507
534
 
508
535
  #### `hideNavigationBar` (iOS only)
509
536
 
@@ -522,12 +549,13 @@ Defaults to `true`.
522
549
  This prop is used to change type of the input and keyboard. Default value is `'text'`.
523
550
 
524
551
  All values:
552
+
525
553
  - `'text'` - normal text input
526
554
  - `'number'` - number input
527
555
  - `'email'` - email input
528
556
  - `'phone'` - phone input
529
557
 
530
- #### `obscureBackground` (iOS only)
558
+ #### `obscureBackground` (iOS only)
531
559
 
532
560
  Boolean indicating whether to obscure the underlying content with semi-transparent overlay.
533
561
 
@@ -553,11 +581,12 @@ const [search, setSearch] = React.useState('');
553
581
  React.useLayoutEffect(() => {
554
582
  navigation.setOptions({
555
583
  searchBar: {
556
- onChangeText: (event) => setSearch(event.nativeEvent.text),
557
- }
584
+ onChangeText: event => setSearch(event.nativeEvent.text),
585
+ },
558
586
  });
559
587
  }, [navigation]);
560
588
  ```
589
+
561
590
  #### `onClose` (Android only)
562
591
 
563
592
  A callback that gets called when search bar is closing
@@ -583,15 +612,15 @@ Defaults to an empty string.
583
612
  #### `placement` (iOS only)
584
613
 
585
614
  Position of the search bar
586
-
615
+
587
616
  Supported values:
588
-
589
- * `automatic` - the search bar is placed according to current layout
590
- * `inline` - the search bar is placed on the trailing edge of navigation bar
591
- * `stacked` - the search bar is placed below the other content in navigation bar
617
+
618
+ - `automatic` - the search bar is placed according to current layout
619
+ - `inline` - the search bar is placed on the trailing edge of navigation bar
620
+ - `stacked` - the search bar is placed below the other content in navigation bar
592
621
 
593
622
  Defaults to `stacked`
594
-
623
+
595
624
  #### `textColor`
596
625
 
597
626
  The search field text color.
@@ -612,12 +641,12 @@ Show the search hint icon when search bar is focused. (Android only)
612
641
 
613
642
  A React ref to imperatively modify search bar. Supported actions:
614
643
 
615
- * `focus` - focus on search bar
616
- * `blur` - remove focus from search bar
617
- * `clearText` - clear text in search bar
618
- * `setText` - set search bar's content to given string
619
- * `cancelSearch` - cancel search in search bar.
620
- * `toggleCancelButton` (iOS only) - toggle cancel button display near search bar.
644
+ - `focus` - focus on search bar
645
+ - `blur` - remove focus from search bar
646
+ - `clearText` - clear text in search bar
647
+ - `setText` - set search bar's content to given string
648
+ - `cancelSearch` - cancel search in search bar.
649
+ - `toggleCancelButton` (iOS only) - toggle cancel button display near search bar.
621
650
 
622
651
  ### Events
623
652
 
@@ -632,16 +661,13 @@ Event which fires when the screen appears.
632
661
  Example:
633
662
 
634
663
  ```js
635
- React.useEffect(
636
- () => {
637
- const unsubscribe = navigation.addListener('appear', e => {
638
- // Do something
639
- });
640
-
641
- return unsubscribe;
642
- },
643
- [navigation]
644
- );
664
+ React.useEffect(() => {
665
+ const unsubscribe = navigation.addListener('appear', e => {
666
+ // Do something
667
+ });
668
+
669
+ return unsubscribe;
670
+ }, [navigation]);
645
671
  ```
646
672
 
647
673
  #### `dismiss`
@@ -651,16 +677,13 @@ Event which fires when the current screen is dismissed by hardware back (on Andr
651
677
  Example:
652
678
 
653
679
  ```js
654
- React.useEffect(
655
- () => {
656
- const unsubscribe = navigation.addListener('dismiss', e => {
657
- // Do something
658
- });
659
-
660
- return unsubscribe;
661
- },
662
- [navigation]
663
- );
680
+ React.useEffect(() => {
681
+ const unsubscribe = navigation.addListener('dismiss', e => {
682
+ // Do something
683
+ });
684
+
685
+ return unsubscribe;
686
+ }, [navigation]);
664
687
  ```
665
688
 
666
689
  #### `transitionStart`
@@ -674,20 +697,17 @@ Event data:
674
697
  Example:
675
698
 
676
699
  ```js
677
- React.useEffect(
678
- () => {
679
- const unsubscribe = navigation.addListener('transitionStart', e => {
680
- if (e.data.closing) {
681
- // Will be dismissed
682
- } else {
683
- // Will appear
684
- }
685
- });
686
-
687
- return unsubscribe;
688
- },
689
- [navigation]
690
- );
700
+ React.useEffect(() => {
701
+ const unsubscribe = navigation.addListener('transitionStart', e => {
702
+ if (e.data.closing) {
703
+ // Will be dismissed
704
+ } else {
705
+ // Will appear
706
+ }
707
+ });
708
+
709
+ return unsubscribe;
710
+ }, [navigation]);
691
711
  ```
692
712
 
693
713
  #### `transitionEnd`
@@ -701,20 +721,17 @@ Event data:
701
721
  Example:
702
722
 
703
723
  ```js
704
- React.useEffect(
705
- () => {
706
- const unsubscribe = navigation.addListener('transitionEnd', e => {
707
- if (e.data.closing) {
708
- // Was dismissed
709
- } else {
710
- // Did appear
711
- }
712
- });
713
-
714
- return unsubscribe;
715
- },
716
- [navigation]
717
- );
724
+ React.useEffect(() => {
725
+ const unsubscribe = navigation.addListener('transitionEnd', e => {
726
+ if (e.data.closing) {
727
+ // Was dismissed
728
+ } else {
729
+ // Did appear
730
+ }
731
+ });
732
+
733
+ return unsubscribe;
734
+ }, [navigation]);
718
735
  ```
719
736
 
720
737
  ### Helpers
@@ -753,9 +770,10 @@ navigation.popToTop();
753
770
  ### Measuring header's height
754
771
 
755
772
  To measure header's height, you can use the `useHeaderHeight`, `useAnimatedHeaderHeight` or `useReanimatedHeaderHeight` hook.
773
+
756
774
  - `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.
757
775
  Use this hook if you're sure your header height won't change dynamically, or when the screen is heavy.
758
- - `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.
776
+ - `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.
759
777
  Please beware of using this hook in heavy components, as it may result in performance issues.
760
778
  - `useReanimatedHeaderHeight` also dynamically calculates the header's height but uses React Native Reanimated under the hood. It returns an Animated.SharedValue.
761
779
  Make sure to wrap your Stack.Navigator with `ReanimatedScreenProvider` before using this hook.
@@ -764,13 +782,13 @@ We recommend using `useReanimatedHeaderHeight` rather than `useAnimatedHeaderHei
764
782
 
765
783
  ```tsx
766
784
  // for using useHeaderHeight
767
- import {useHeaderHeight} from 'react-native-screens/native-stack';
785
+ import { useHeaderHeight } from 'react-native-screens/native-stack';
768
786
 
769
787
  // for using useAnimatedHeaderHeight
770
- import {useAnimatedHeaderHeight} from 'react-native-screens/native-stack';
788
+ import { useAnimatedHeaderHeight } from 'react-native-screens/native-stack';
771
789
 
772
790
  // for using useReanimatedHeaderHeight
773
- import {useReanimatedHeaderHeight} from 'react-native-screens/reanimated';
791
+ import { useReanimatedHeaderHeight } from 'react-native-screens/reanimated';
774
792
  ```
775
793
 
776
794
  ## Example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-screens",
3
- "version": "3.31.1",
3
+ "version": "3.33.0",
4
4
  "description": "Native navigation primitives for your React Native app.",
5
5
  "scripts": {
6
6
  "submodules": "git submodule update --init --recursive && (cd react-navigation && yarn)",
@@ -10,12 +10,17 @@
10
10
  "format-js": "prettier --write --list-different './{src,Example}/**/*.{js,ts,tsx}'",
11
11
  "format-android": "node ./scripts/format-android.js",
12
12
  "format-ios": "find ios/ -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.cpp\" -o -iname \"*.mm\" | xargs clang-format -i",
13
- "format": "yarn format-js && yarn format-android && yarn format-ios",
13
+ "format-common": "find common/ -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
14
+ "format-cpp": "find cpp/ -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
15
+ "format-android-cpp": "find android/src/main/cpp -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i",
16
+ "format": "yarn format-js && yarn format-android && yarn format-ios && yarn format-common && yarn format-cpp && yarn format-android-cpp",
14
17
  "lint-js": "eslint --ext '.js,.ts,.tsx' --fix src",
15
18
  "lint-android": "./android/gradlew -p android spotlessCheck -q",
16
19
  "lint": "yarn lint-js && yarn lint-android",
17
20
  "release": "yarn prepare && npm login && release-it",
18
- "prepare": "bob build && husky install"
21
+ "prepare": "bob build && husky install",
22
+ "architectures-consistency-check": "node ./scripts/codegen-check-consistency.js",
23
+ "sync-architectures": "node ./scripts/codegen-sync-archs.js"
19
24
  },
20
25
  "main": "lib/commonjs/index",
21
26
  "module": "lib/module/index",
@@ -78,7 +83,7 @@
78
83
  "@react-navigation/native": "^5.8.0",
79
84
  "@react-navigation/stack": "^5.10.0",
80
85
  "@types/jest": "^29.3.1",
81
- "@types/react": "^18.2.21",
86
+ "@types/react": "^18.2.72",
82
87
  "@types/react-test-renderer": "^18.0.0",
83
88
  "@typescript-eslint/eslint-plugin": "^6.5.0",
84
89
  "@typescript-eslint/parser": "^6.5.0",
@@ -109,19 +114,23 @@
109
114
  "react-native-windows": "^0.64.8",
110
115
  "react-test-renderer": "^18.2.0",
111
116
  "release-it": "^15.6.0",
112
- "typescript": "4.8.4"
117
+ "typescript": "5.4.3"
113
118
  },
114
119
  "resolutions": {
115
120
  "@react-native-community/cli-platform-android": "^11.3.6",
116
121
  "@react-native-community/cli": "^11.3.6",
117
122
  "@react-native-community/cli-platform-ios": "^11.3.6",
118
- "@types/react": "^18.2.21"
123
+ "@types/react": "^18.2.72"
119
124
  },
120
125
  "lint-staged": {
121
126
  "{src,Example}/**/*.{js,ts,tsx}": "yarn format-js",
122
127
  "src/**/*.{js,ts,tsx}": "yarn lint-js",
128
+ "common/**/*.{h,cpp}": "yarn format-common",
129
+ "cpp/**/*.{h,cpp}": "yarn format-cpp",
130
+ "android/src/main/cpp/.{cpp, h}": "yarn format-android-cpp",
123
131
  "android/**/*.kt": "yarn format-android",
124
- "ios/**/*.{h,m,mm,cpp}": "yarn format-ios"
132
+ "ios/**/*.{h,m,mm,cpp}": "yarn format-ios",
133
+ "src/fabric/*.ts": "yarn sync-architectures"
125
134
  },
126
135
  "react-native-builder-bob": {
127
136
  "source": "src",
@@ -11,20 +11,22 @@ try {
11
11
  module.exports = {
12
12
  dependency: {
13
13
  platforms: {
14
- android: supportsCodegenConfig ? {
15
- componentDescriptors: [
16
- "RNSFullWindowOverlayComponentDescriptor",
17
- "RNSScreenContainerComponentDescriptor",
18
- "RNSScreenNavigationContainerComponentDescriptor",
19
- "RNSScreenStackHeaderConfigComponentDescriptor",
20
- "RNSScreenStackHeaderSubviewComponentDescriptor",
21
- "RNSScreenStackComponentDescriptor",
22
- "RNSSearchBarComponentDescriptor",
23
- 'RNSScreenComponentDescriptor',
24
- 'RNSModalScreenComponentDescriptor'
25
- ],
26
- cmakeListsPath: "../android/src/main/jni/CMakeLists.txt"
27
- } : {},
14
+ android: supportsCodegenConfig
15
+ ? {
16
+ componentDescriptors: [
17
+ 'RNSFullWindowOverlayComponentDescriptor',
18
+ 'RNSScreenContainerComponentDescriptor',
19
+ 'RNSScreenNavigationContainerComponentDescriptor',
20
+ 'RNSScreenStackHeaderConfigComponentDescriptor',
21
+ 'RNSScreenStackHeaderSubviewComponentDescriptor',
22
+ 'RNSScreenStackComponentDescriptor',
23
+ 'RNSSearchBarComponentDescriptor',
24
+ 'RNSScreenComponentDescriptor',
25
+ 'RNSModalScreenComponentDescriptor',
26
+ ],
27
+ cmakeListsPath: '../android/src/main/jni/CMakeLists.txt',
28
+ }
29
+ : {},
28
30
  },
29
31
  },
30
- }
32
+ };
@@ -8,5 +8,5 @@ type TransitionProgressContextBody = {
8
8
  };
9
9
 
10
10
  export default React.createContext<TransitionProgressContextBody | undefined>(
11
- undefined
11
+ undefined,
12
12
  );