react-native-screens 3.10.0 → 3.11.1

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 (46) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -7
  3. package/android/build.gradle +1 -2
  4. package/android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt +1 -1
  5. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +28 -11
  6. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +1 -1
  7. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +64 -33
  8. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +9 -31
  9. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +3 -32
  10. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +12 -5
  11. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +10 -0
  12. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +72 -11
  13. package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +18 -1
  14. package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +7 -2
  15. package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +29 -2
  16. package/android/src/main/res/anim/rns_default_enter_in.xml +18 -0
  17. package/android/src/main/res/anim/rns_default_enter_out.xml +19 -0
  18. package/android/src/main/res/anim/rns_default_exit_in.xml +17 -0
  19. package/android/src/main/res/anim/rns_default_exit_out.xml +18 -0
  20. package/android/src/main/res/anim/rns_fade_in.xml +7 -0
  21. package/android/src/main/res/anim/rns_fade_out.xml +7 -0
  22. package/android/src/main/res/anim/rns_no_animation_20.xml +6 -0
  23. package/createNativeStackNavigator/README.md +21 -33
  24. package/ios/RNSScreen.h +10 -0
  25. package/ios/RNSScreen.m +34 -0
  26. package/ios/RNSScreenContainer.m +5 -0
  27. package/ios/RNSScreenStack.m +22 -7
  28. package/ios/RNSScreenStackAnimator.m +45 -14
  29. package/ios/RNSScreenStackHeaderConfig.m +4 -1
  30. package/ios/RNSScreenWindowTraits.h +1 -0
  31. package/ios/RNSScreenWindowTraits.m +20 -0
  32. package/ios/UIViewController+RNScreens.m +10 -0
  33. package/lib/commonjs/native-stack/views/NativeStackView.js +33 -4
  34. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  35. package/lib/module/native-stack/views/NativeStackView.js +33 -4
  36. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  37. package/lib/typescript/native-stack/types.d.ts +34 -0
  38. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
  39. package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
  40. package/lib/typescript/types.d.ts +60 -5
  41. package/native-stack/README.md +39 -3
  42. package/package.json +1 -1
  43. package/reanimated/package.json +6 -0
  44. package/src/native-stack/types.tsx +34 -0
  45. package/src/native-stack/views/NativeStackView.tsx +33 -4
  46. package/src/types.tsx +60 -5
@@ -3,6 +3,7 @@ export declare type StackPresentationTypes = 'push' | 'modal' | 'transparentModa
3
3
  export declare type StackAnimationTypes = 'default' | 'fade' | 'fade_from_bottom' | 'flip' | 'none' | 'simple_push' | 'slide_from_bottom' | 'slide_from_right' | 'slide_from_left';
4
4
  export declare type BlurEffectTypes = 'extraLight' | 'light' | 'dark' | 'regular' | 'prominent' | 'systemUltraThinMaterial' | 'systemThinMaterial' | 'systemMaterial' | 'systemThickMaterial' | 'systemChromeMaterial' | 'systemUltraThinMaterialLight' | 'systemThinMaterialLight' | 'systemMaterialLight' | 'systemThickMaterialLight' | 'systemChromeMaterialLight' | 'systemUltraThinMaterialDark' | 'systemThinMaterialDark' | 'systemMaterialDark' | 'systemThickMaterialDark' | 'systemChromeMaterialDark';
5
5
  export declare type ScreenReplaceTypes = 'push' | 'pop';
6
+ export declare type SwipeDirectionTypes = 'vertical' | 'horizontal';
6
7
  export declare type ScreenOrientationTypes = 'default' | 'all' | 'portrait' | 'portrait_up' | 'portrait_down' | 'landscape' | 'landscape_left' | 'landscape_right';
7
8
  export declare type HeaderSubviewTypes = 'back' | 'right' | 'left' | 'center' | 'searchBar';
8
9
  export declare type TransitionProgressEventType = {
@@ -42,6 +43,12 @@ export interface ScreenProps extends ViewProps {
42
43
  * @platform ios
43
44
  */
44
45
  gestureEnabled?: boolean;
46
+ /**
47
+ * Whether the home indicator should be hidden on this screen. Defaults to `false`.
48
+ *
49
+ * @platform ios
50
+ */
51
+ homeIndicatorHidden?: boolean;
45
52
  /**
46
53
  * 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.
47
54
  * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
@@ -50,6 +57,18 @@ export interface ScreenProps extends ViewProps {
50
57
  * @platform android
51
58
  */
52
59
  nativeBackButtonDismissalEnabled?: boolean;
60
+ /**
61
+ * Sets the navigation bar color. Defaults to initial status bar color.
62
+ *
63
+ * @platform android
64
+ */
65
+ navigationBarColor?: string;
66
+ /**
67
+ * Sets the visibility of the navigation bar. Defaults to `false`.
68
+ *
69
+ * @platform android
70
+ */
71
+ navigationBarHidden?: boolean;
53
72
  /**
54
73
  * A callback that gets called when the current screen appears.
55
74
  */
@@ -155,6 +174,23 @@ export interface ScreenProps extends ViewProps {
155
174
  * @platform android
156
175
  */
157
176
  statusBarTranslucent?: boolean;
177
+ /**
178
+ * Sets the direction in which you should swipe to dismiss the screen.
179
+ * When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.
180
+ * The following values are supported:
181
+ * - `vertical` – dismiss screen vertically
182
+ * - `horizontal` – dismiss screen horizontally (default)
183
+ *
184
+ * @platform ios
185
+ */
186
+ swipeDirection?: SwipeDirectionTypes;
187
+ /**
188
+ * Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
189
+ * The duration of `default` and `flip` transitions isn't customizable.
190
+ *
191
+ * @platform ios
192
+ */
193
+ transitionDuration?: number;
158
194
  }
159
195
  export interface ScreenContainerProps extends ViewProps {
160
196
  children?: React.ReactNode;
@@ -375,17 +411,17 @@ export interface SearchBarProps {
375
411
  */
376
412
  onChangeText?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
377
413
  /**
378
- * A callback that gets called when search bar has received focus
414
+ * A callback that gets called when search bar is closed
415
+ *
416
+ * @platform android
379
417
  */
380
418
  onClose?: () => void;
381
419
  /**
382
- * A callback that gets called when search bar is opened
383
- *
384
- * @platform android
420
+ * A callback that gets called when search bar has received focus
385
421
  */
386
422
  onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
387
423
  /**
388
- * A callback that gets called when search bar is closed
424
+ * A callback that gets called when search bar is opened
389
425
  *
390
426
  * @platform android
391
427
  */
@@ -402,4 +438,23 @@ export interface SearchBarProps {
402
438
  * The search field text color
403
439
  */
404
440
  textColor?: string;
441
+ /**
442
+ * The search hint text color
443
+ *
444
+ * @plaform android
445
+ */
446
+ hintTextColor?: string;
447
+ /**
448
+ * The search and close icon color shown in the header
449
+ *
450
+ * @plaform android
451
+ */
452
+ headerIconColor?: string;
453
+ /**
454
+ * Show the search hint icon when search bar is focused
455
+ *
456
+ * @plaform android
457
+ * @default true
458
+ */
459
+ shouldShowHintSearchIcon?: boolean;
405
460
  }
@@ -182,6 +182,10 @@ A Boolean to that lets you opt out of insetting the header. You may want to * se
182
182
 
183
183
  Boolean indicating whether the navigation bar is translucent.
184
184
 
185
+ #### `homeIndicatorHidden` (iOS only)
186
+
187
+ Whether the home indicator should be hidden on this screen. Defaults to `false`.
188
+
185
189
  #### `nativeBackButtonDismissalEnabled` (Android only)
186
190
 
187
191
  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.
@@ -189,6 +193,14 @@ Unfortunately the same behavior is not available on iOS since the behavior of na
189
193
 
190
194
  Defaults to `false`.
191
195
 
196
+ #### `navigationBarColor` (Android only)
197
+
198
+ Sets the navigation bar color. Defaults to initial status bar color.
199
+
200
+ #### `navigationBarHidden` (Android only)
201
+
202
+ Sets the visibility of the navigation bar. Defaults to `false`.
203
+
192
204
  #### `replaceAnimation`
193
205
 
194
206
  How should the screen replacing another screen animate.
@@ -230,10 +242,24 @@ Defaults to `push`.
230
242
 
231
243
  Using `containedModal` and `containedTransparentModal` with other types of modals in one native stack navigator is not recommended and can result in a freeze or a crash of the application.
232
244
 
245
+ #### `swipeDirection` (iOS only)
246
+
247
+ Sets the direction in which you should swipe to dismiss the screen. The following values are supported:
248
+ - `vertical` – dismiss screen vertically
249
+ - `horizontal` – dismiss screen horizontally (default)
250
+
251
+ When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.
252
+
233
253
  #### `title`
234
254
 
235
255
  A string that can be used as a fallback for `headerTitle`.
236
256
 
257
+ #### `transitionDuration` (iOS only)
258
+
259
+ Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
260
+
261
+ The duration of `default` and `flip` transitions isn't customizable.
262
+
237
263
  #### `useTransitionProgress`
238
264
 
239
265
  Hook providing context value of transition progress of the current screen to be used with `react-native` `Animated`. It consists of 2 values:
@@ -353,12 +379,10 @@ Defaults to `auto`.
353
379
 
354
380
  Sets the translucency of the status bar (similar to the `StatusBar` component). Defaults to `false`.
355
381
 
356
- ### Search bar (iOS only)
382
+ ### Search bar
357
383
 
358
384
  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.
359
385
 
360
- Search bar is only supported on iOS.
361
-
362
386
  Example:
363
387
 
364
388
  ```js
@@ -485,6 +509,18 @@ Defaults to an empty string.
485
509
 
486
510
  The search field text color.
487
511
 
512
+ #### `hintTextColor`
513
+
514
+ The search hint text color. (Android only)
515
+
516
+ #### `headerIconColor`
517
+
518
+ The search and close icon color shown in the header. (Android only)
519
+
520
+ #### `shouldShowHintSearchIcon`
521
+
522
+ Show the search hint icon when search bar is focused. (Android only)
523
+
488
524
  ### Events
489
525
 
490
526
  The navigator can [emit events](https://reactnavigation.org/docs/navigation-events) on certain actions. Supported events are:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-screens",
3
- "version": "3.10.0",
3
+ "version": "3.11.1",
4
4
  "description": "Native navigation primitives for your React Native app.",
5
5
  "scripts": {
6
6
  "check-types": "tsc --noEmit",
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/reanimated/index",
3
+ "module": "../lib/module/reanimated/index",
4
+ "react-native": "../src/reanimated/index",
5
+ "types": "../lib/typescript/reanimated/index"
6
+ }
@@ -243,6 +243,12 @@ export type NativeStackNavigationOptions = {
243
243
  * Boolean indicating whether the navigation bar is translucent.
244
244
  */
245
245
  headerTranslucent?: boolean;
246
+ /**
247
+ * Whether the home indicator should be hidden on this screen. Defaults to `false`.
248
+ *
249
+ * @platform ios
250
+ */
251
+ homeIndicatorHidden?: boolean;
246
252
  /**
247
253
  * 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.
248
254
  * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
@@ -251,6 +257,18 @@ export type NativeStackNavigationOptions = {
251
257
  * @platform android
252
258
  */
253
259
  nativeBackButtonDismissalEnabled?: boolean;
260
+ /**
261
+ * Sets the navigation bar color. Defaults to initial status bar color.
262
+ *
263
+ * @platform android
264
+ */
265
+ navigationBarColor?: string;
266
+ /**
267
+ * Sets the visibility of the navigation bar. Defaults to `false`.
268
+ *
269
+ * @platform android
270
+ */
271
+ navigationBarHidden?: boolean;
254
272
  /**
255
273
  * How should the screen replacing another screen animate. Defaults to `pop`.
256
274
  * The following values are currently supported:
@@ -325,10 +343,26 @@ export type NativeStackNavigationOptions = {
325
343
  * @platform android
326
344
  */
327
345
  statusBarTranslucent?: boolean;
346
+ /**
347
+ * Sets the direction in which you should swipe to dismiss the screen.
348
+ * When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.
349
+ * The following values are supported:
350
+ * - `vertical` – dismiss screen vertically
351
+ * - `horizontal` – dismiss screen horizontally (default)
352
+ * @platform ios
353
+ */
354
+ swipeDirection?: ScreenProps['swipeDirection'];
328
355
  /**
329
356
  * String that can be displayed in the header as a fallback for `headerTitle`.
330
357
  */
331
358
  title?: string;
359
+ /**
360
+ * Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
361
+ * The duration of `default` and `flip` transitions isn't customizable.
362
+ *
363
+ * @platform ios
364
+ */
365
+ transitionDuration?: number;
332
366
  };
333
367
 
334
368
  export type NativeStackNavigatorProps = DefaultNavigatorOptions<
@@ -149,22 +149,46 @@ const RouteView = ({
149
149
  }) => {
150
150
  const { options, render: renderScene } = descriptors[route.key];
151
151
  const {
152
- customAnimationOnSwipe,
153
- fullScreenSwipeEnabled,
154
152
  gestureEnabled,
155
153
  headerShown,
154
+ homeIndicatorHidden,
156
155
  nativeBackButtonDismissalEnabled = false,
156
+ navigationBarColor,
157
+ navigationBarHidden,
157
158
  replaceAnimation = 'pop',
158
159
  screenOrientation,
159
- stackAnimation,
160
160
  statusBarAnimation,
161
161
  statusBarColor,
162
162
  statusBarHidden,
163
163
  statusBarStyle,
164
164
  statusBarTranslucent,
165
+ swipeDirection = 'horizontal',
166
+ transitionDuration,
167
+ } = options;
168
+
169
+ let {
170
+ customAnimationOnSwipe,
171
+ fullScreenSwipeEnabled,
172
+ stackAnimation,
173
+ stackPresentation = 'push',
165
174
  } = options;
166
175
 
167
- let { stackPresentation = 'push' } = options;
176
+ if (swipeDirection === 'vertical') {
177
+ // for `vertical` direction to work, we need to set `fullScreenSwipeEnabled` to `true`
178
+ // so the screen can be dismissed from any point on screen.
179
+ // `customAnimationOnSwipe` needs to be set to `true` so the `stackAnimation` set by user can be used,
180
+ // otherwise `simple_push` will be used.
181
+ // Also, the default animation for this direction seems to be `slide_from_bottom`.
182
+ if (fullScreenSwipeEnabled === undefined) {
183
+ fullScreenSwipeEnabled = true;
184
+ }
185
+ if (customAnimationOnSwipe === undefined) {
186
+ customAnimationOnSwipe = true;
187
+ }
188
+ if (stackAnimation === undefined) {
189
+ stackAnimation = 'slide_from_bottom';
190
+ }
191
+ }
168
192
 
169
193
  if (index === 0) {
170
194
  // first screen should always be treated as `push`, it resolves problems with no header animation
@@ -194,8 +218,11 @@ const RouteView = ({
194
218
  style={StyleSheet.absoluteFill}
195
219
  customAnimationOnSwipe={customAnimationOnSwipe}
196
220
  fullScreenSwipeEnabled={fullScreenSwipeEnabled}
221
+ homeIndicatorHidden={homeIndicatorHidden}
197
222
  gestureEnabled={isAndroid ? false : gestureEnabled}
198
223
  nativeBackButtonDismissalEnabled={nativeBackButtonDismissalEnabled}
224
+ navigationBarColor={navigationBarColor}
225
+ navigationBarHidden={navigationBarHidden}
199
226
  replaceAnimation={replaceAnimation}
200
227
  screenOrientation={screenOrientation}
201
228
  stackAnimation={stackAnimation}
@@ -205,6 +232,8 @@ const RouteView = ({
205
232
  statusBarHidden={statusBarHidden}
206
233
  statusBarStyle={statusBarStyle}
207
234
  statusBarTranslucent={statusBarTranslucent}
235
+ swipeDirection={swipeDirection}
236
+ transitionDuration={transitionDuration}
208
237
  onHeaderBackButtonClicked={() => {
209
238
  navigation.dispatch({
210
239
  ...StackActions.pop(),
package/src/types.tsx CHANGED
@@ -47,6 +47,7 @@ export type BlurEffectTypes =
47
47
  | 'systemThickMaterialDark'
48
48
  | 'systemChromeMaterialDark';
49
49
  export type ScreenReplaceTypes = 'push' | 'pop';
50
+ export type SwipeDirectionTypes = 'vertical' | 'horizontal';
50
51
  export type ScreenOrientationTypes =
51
52
  | 'default'
52
53
  | 'all'
@@ -101,6 +102,12 @@ export interface ScreenProps extends ViewProps {
101
102
  * @platform ios
102
103
  */
103
104
  gestureEnabled?: boolean;
105
+ /**
106
+ * Whether the home indicator should be hidden on this screen. Defaults to `false`.
107
+ *
108
+ * @platform ios
109
+ */
110
+ homeIndicatorHidden?: boolean;
104
111
  /**
105
112
  * 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.
106
113
  * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
@@ -109,6 +116,18 @@ export interface ScreenProps extends ViewProps {
109
116
  * @platform android
110
117
  */
111
118
  nativeBackButtonDismissalEnabled?: boolean;
119
+ /**
120
+ * Sets the navigation bar color. Defaults to initial status bar color.
121
+ *
122
+ * @platform android
123
+ */
124
+ navigationBarColor?: string;
125
+ /**
126
+ * Sets the visibility of the navigation bar. Defaults to `false`.
127
+ *
128
+ * @platform android
129
+ */
130
+ navigationBarHidden?: boolean;
112
131
  /**
113
132
  * A callback that gets called when the current screen appears.
114
133
  */
@@ -214,6 +233,23 @@ export interface ScreenProps extends ViewProps {
214
233
  * @platform android
215
234
  */
216
235
  statusBarTranslucent?: boolean;
236
+ /**
237
+ * Sets the direction in which you should swipe to dismiss the screen.
238
+ * When using `vertical` option, options `fullScreenSwipeEnabled: true`, `customAnimationOnSwipe: true` and `stackAnimation: 'slide_from_bottom'` are set by default.
239
+ * The following values are supported:
240
+ * - `vertical` – dismiss screen vertically
241
+ * - `horizontal` – dismiss screen horizontally (default)
242
+ *
243
+ * @platform ios
244
+ */
245
+ swipeDirection?: SwipeDirectionTypes;
246
+ /**
247
+ * Changes the duration (in milliseconds) of `slide_from_bottom`, `fade_from_bottom`, `fade` and `simple_push` transitions on iOS. Defaults to `350`.
248
+ * The duration of `default` and `flip` transitions isn't customizable.
249
+ *
250
+ * @platform ios
251
+ */
252
+ transitionDuration?: number;
217
253
  }
218
254
 
219
255
  export interface ScreenContainerProps extends ViewProps {
@@ -441,17 +477,17 @@ export interface SearchBarProps {
441
477
  onChangeText?: (e: NativeSyntheticEvent<TextInputFocusEventData>) => void;
442
478
 
443
479
  /**
444
- * A callback that gets called when search bar has received focus
480
+ * A callback that gets called when search bar is closed
481
+ *
482
+ * @platform android
445
483
  */
446
484
  onClose?: () => void;
447
485
  /**
448
- * A callback that gets called when search bar is opened
449
- *
450
- * @platform android
486
+ * A callback that gets called when search bar has received focus
451
487
  */
452
488
  onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
453
489
  /**
454
- * A callback that gets called when search bar is closed
490
+ * A callback that gets called when search bar is opened
455
491
  *
456
492
  * @platform android
457
493
  */
@@ -470,4 +506,23 @@ export interface SearchBarProps {
470
506
  * The search field text color
471
507
  */
472
508
  textColor?: string;
509
+ /**
510
+ * The search hint text color
511
+ *
512
+ * @plaform android
513
+ */
514
+ hintTextColor?: string;
515
+ /**
516
+ * The search and close icon color shown in the header
517
+ *
518
+ * @plaform android
519
+ */
520
+ headerIconColor?: string;
521
+ /**
522
+ * Show the search hint icon when search bar is focused
523
+ *
524
+ * @plaform android
525
+ * @default true
526
+ */
527
+ shouldShowHintSearchIcon?: boolean;
473
528
  }