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.
- package/README.md +21 -11
- package/RNScreens.podspec +11 -52
- package/android/CMakeLists.txt +48 -4
- package/android/build.gradle +16 -9
- package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +25 -16
- package/android/src/fabric/java/com/swmansion/rnscreens/NativeProxy.kt +53 -0
- package/android/src/main/cpp/NativeProxy.cpp +51 -0
- package/android/src/main/cpp/NativeProxy.h +35 -0
- package/android/src/main/cpp/OnLoad.cpp +8 -0
- package/android/src/main/cpp/jni-adapter.cpp +86 -93
- package/android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt +7 -2
- package/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +6 -1
- package/android/src/main/java/com/swmansion/rnscreens/FragmentBackPressOverrider.kt +2 -2
- package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +36 -17
- package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +150 -40
- package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +52 -30
- package/android/src/main/java/com/swmansion/rnscreens/ScreenContainerViewManager.kt +27 -4
- package/android/src/main/java/com/swmansion/rnscreens/ScreenEventDispatcher.kt +10 -2
- package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +56 -27
- package/android/src/main/java/com/swmansion/rnscreens/ScreenFragmentWrapper.kt +8 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +50 -19
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +63 -39
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragmentWrapper.kt +4 -0
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +88 -57
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +131 -36
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt +19 -4
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt +16 -10
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackViewManager.kt +28 -25
- package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +177 -77
- package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +77 -25
- package/android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt +31 -9
- package/android/src/main/java/com/swmansion/rnscreens/ScreensShadowNode.kt +3 -1
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +160 -54
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +29 -22
- package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +7 -2
- package/android/src/main/java/com/swmansion/rnscreens/events/HeaderAttachedEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/HeaderBackButtonClickedEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/HeaderDetachedEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/HeaderHeightChangeEvent.kt +5 -6
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenAppearEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDisappearEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDismissedEvent.kt +8 -4
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenTransitionProgressEvent.kt +7 -6
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillAppearEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillDisappearEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarBlurEvent.kt +5 -2
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarChangeTextEvent.kt +4 -3
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarCloseEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarFocusEvent.kt +5 -2
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarOpenEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarSearchButtonPressEvent.kt +9 -4
- package/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt +4 -1
- package/android/src/main/java/com/swmansion/rnscreens/utils/DeviceUtils.kt +1 -5
- package/android/src/main/java/com/swmansion/rnscreens/utils/ScreenDummyLayoutHelper.kt +214 -0
- package/android/src/main/jni/CMakeLists.txt +5 -4
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenContainerManagerDelegate.java +25 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenContainerManagerInterface.java +16 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerDelegate.java +6 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerInterface.java +2 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +3 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +1 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java +99 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerInterface.java +37 -0
- package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +10 -5
- package/android/src/paper/java/com/swmansion/rnscreens/NativeProxy.kt +19 -0
- package/android/src/paper/java/com/swmansion/rnscreens/NativeScreensModuleSpec.java +4 -0
- package/common/cpp/react/renderer/components/rnscreens/FrameCorrectionModes.h +51 -0
- package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenComponentDescriptor.h +8 -9
- package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.cpp +2 -1
- package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.h +9 -8
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h +147 -10
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +51 -1
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h +29 -7
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.cpp +22 -1
- package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h +30 -10
- package/common/cpp/react/renderer/components/rnscreens/utils/RectUtil.h +36 -0
- package/cpp/RNSScreenRemovalListener.cpp +25 -0
- package/cpp/RNSScreenRemovalListener.h +20 -0
- package/cpp/RNScreensTurboModule.cpp +31 -23
- package/cpp/RNScreensTurboModule.h +17 -20
- package/ios/RNSConvert.h +7 -0
- package/ios/RNSConvert.mm +24 -0
- package/ios/RNSModalScreen.mm +22 -0
- package/ios/RNSModule.mm +2 -3
- package/ios/RNSScreen.h +2 -1
- package/ios/RNSScreen.mm +35 -19
- package/ios/RNSScreenContainer.mm +1 -1
- package/ios/RNSScreenStack.mm +59 -54
- package/ios/RNSScreenStackAnimator.mm +43 -6
- package/ios/RNSScreenStackHeaderConfig.h +2 -0
- package/ios/RNSScreenStackHeaderConfig.mm +93 -28
- package/ios/RNSScreenStackHeaderSubview.mm +8 -0
- package/ios/RNSSearchBar.h +5 -5
- package/ios/RNSSearchBar.mm +11 -11
- package/ios/utils/RCTSurfaceTouchHandler+RNSUtility.h +15 -0
- package/ios/utils/RCTSurfaceTouchHandler+RNSUtility.mm +14 -0
- package/ios/utils/RCTTouchHandler+RNSUtility.h +15 -0
- package/ios/utils/RCTTouchHandler+RNSUtility.mm +15 -0
- package/ios/utils/UIView+RNSUtility.h +23 -0
- package/ios/utils/UIView+RNSUtility.mm +55 -0
- package/lib/commonjs/components/Screen.js +119 -127
- package/lib/commonjs/components/Screen.js.map +1 -1
- package/lib/commonjs/components/ScreenStack.js +8 -1
- package/lib/commonjs/components/ScreenStack.js.map +1 -1
- package/lib/commonjs/components/SearchBar.js +39 -36
- package/lib/commonjs/components/SearchBar.js.map +1 -1
- package/lib/commonjs/fabric/ModalScreenNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/commonjs/native-stack/views/HeaderConfig.js +2 -0
- package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.js +4 -0
- package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/components/Screen.js +118 -126
- package/lib/module/components/Screen.js.map +1 -1
- package/lib/module/components/ScreenStack.js +8 -1
- package/lib/module/components/ScreenStack.js.map +1 -1
- package/lib/module/components/SearchBar.js +39 -36
- package/lib/module/components/SearchBar.js.map +1 -1
- package/lib/module/fabric/ModalScreenNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/module/native-stack/views/HeaderConfig.js +2 -0
- package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.js +4 -0
- package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/typescript/TransitionProgressContext.d.ts +1 -1
- package/lib/typescript/TransitionProgressContext.d.ts.map +1 -1
- package/lib/typescript/components/Screen.d.ts +3 -14
- package/lib/typescript/components/Screen.d.ts.map +1 -1
- package/lib/typescript/components/ScreenStack.d.ts.map +1 -1
- package/lib/typescript/components/SearchBar.d.ts +14 -21
- package/lib/typescript/components/SearchBar.d.ts.map +1 -1
- package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts +12 -10
- package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts.map +1 -1
- package/lib/typescript/fabric/ScreenNativeComponent.d.ts +12 -10
- package/lib/typescript/fabric/ScreenNativeComponent.d.ts.map +1 -1
- package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +5 -3
- package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -1
- package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts +1 -1
- package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts +1 -1
- package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts.map +1 -1
- package/lib/typescript/fabric/SearchBarNativeComponent.d.ts +9 -9
- package/lib/typescript/fabric/SearchBarNativeComponent.d.ts.map +1 -1
- package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts +1 -1
- package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts.map +1 -1
- package/lib/typescript/native-stack/types.d.ts +39 -14
- package/lib/typescript/native-stack/types.d.ts.map +1 -1
- package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts +1 -1
- package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts.map +1 -1
- package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -1
- package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts.map +1 -1
- package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts +1 -1
- package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts.map +1 -1
- package/lib/typescript/native-stack/views/HeaderConfig.d.ts +2 -2
- package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.d.ts +1 -1
- package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -1
- package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts +1 -1
- package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +39 -13
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/useTransitionProgress.d.ts +3 -3
- package/native-stack/README.md +116 -98
- package/package.json +16 -7
- package/react-native.config.js +17 -15
- package/src/TransitionProgressContext.tsx +1 -1
- package/src/components/Screen.tsx +31 -37
- package/src/components/ScreenStack.tsx +11 -1
- package/src/components/ScreenStackHeaderConfig.tsx +5 -5
- package/src/components/ScreenStackHeaderConfig.web.tsx +6 -6
- package/src/components/SearchBar.tsx +77 -65
- package/src/core.ts +1 -1
- package/src/fabric/ModalScreenNativeComponent.ts +2 -0
- package/src/fabric/ScreenNativeComponent.ts +2 -0
- package/src/fabric/ScreenNavigationContainerNativeComponent.ts +1 -1
- package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +4 -1
- package/src/fabric/ScreenStackHeaderSubviewNativeComponent.ts +1 -1
- package/src/fabric/SearchBarNativeComponent.ts +7 -7
- package/src/gesture-handler/ScreenGestureDetector.tsx +5 -5
- package/src/gesture-handler/constraints.ts +5 -5
- package/src/gesture-handler/fabricUtils.ts +1 -1
- package/src/native-stack/contexts/GHContext.tsx +1 -1
- package/src/native-stack/navigators/createNativeStackNavigator.tsx +3 -3
- package/src/native-stack/types.tsx +29 -4
- package/src/native-stack/utils/getDefaultHeaderHeight.tsx +1 -1
- package/src/native-stack/utils/getStatusBarHeight.tsx +1 -1
- package/src/native-stack/utils/useAnimatedHeaderHeight.tsx +1 -1
- package/src/native-stack/utils/useBackPressSubscription.tsx +1 -1
- package/src/native-stack/utils/useHeaderHeight.tsx +1 -1
- package/src/native-stack/views/FontProcessor.tsx +1 -1
- package/src/native-stack/views/HeaderConfig.tsx +3 -1
- package/src/native-stack/views/NativeStackView.tsx +13 -9
- package/src/reanimated/ReanimatedHeaderHeightContext.tsx +1 -1
- package/src/reanimated/ReanimatedNativeStackScreen.tsx +5 -5
- package/src/reanimated/ReanimatedScreen.tsx +2 -2
- package/src/reanimated/ReanimatedScreenProvider.tsx +1 -1
- package/src/reanimated/useReanimatedHeaderHeight.tsx +1 -1
- package/src/reanimated/useReanimatedTransitionProgress.tsx +1 -1
- package/src/types.tsx +31 -5
- package/src/useTransitionProgress.tsx +1 -1
- package/windows/README.md +4 -1
package/native-stack/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Native Stack Navigator
|
|
2
2
|
|
|
3
|
-
> **_NOTE:_**
|
|
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
|
|
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
|
-
####
|
|
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
|
-
|
|
226
|
-
|
|
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
|
-
|
|
268
|
-
|
|
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
|
-
|
|
285
|
+
If this prop is set to:
|
|
271
286
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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
|
-
|
|
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
|
|
368
|
+
outputRange: [1.0, 0.0, 1.0],
|
|
352
369
|
extrapolate: 'clamp',
|
|
353
370
|
});
|
|
354
371
|
|
|
355
372
|
return (
|
|
356
|
-
<Animated.View
|
|
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` -
|
|
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, {
|
|
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(
|
|
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
|
-
####
|
|
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:
|
|
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
|
-
|
|
590
|
-
|
|
591
|
-
|
|
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
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
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
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
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
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
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
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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.
|
|
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": "
|
|
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.
|
|
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.
|
|
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.
|
|
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",
|
package/react-native.config.js
CHANGED
|
@@ -11,20 +11,22 @@ try {
|
|
|
11
11
|
module.exports = {
|
|
12
12
|
dependency: {
|
|
13
13
|
platforms: {
|
|
14
|
-
android: supportsCodegenConfig
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
};
|