react-native-screens 3.10.2 → 3.11.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/LICENSE +1 -1
- package/README.md +9 -7
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +28 -11
- package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +1 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +64 -33
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +9 -31
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +0 -30
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +12 -5
- package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +10 -0
- package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +72 -11
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +18 -1
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +7 -2
- package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +29 -2
- package/android/src/main/res/anim/rns_default_enter_in.xml +18 -0
- package/android/src/main/res/anim/rns_default_enter_out.xml +19 -0
- package/android/src/main/res/anim/rns_default_exit_in.xml +17 -0
- package/android/src/main/res/anim/rns_default_exit_out.xml +18 -0
- package/android/src/main/res/anim/rns_fade_in.xml +7 -0
- package/android/src/main/res/anim/rns_fade_out.xml +7 -0
- package/android/src/main/res/anim/rns_no_animation_20.xml +6 -0
- package/createNativeStackNavigator/README.md +12 -0
- package/ios/RNSScreen.h +10 -0
- package/ios/RNSScreen.m +34 -0
- package/ios/RNSScreenContainer.m +5 -0
- package/ios/RNSScreenStack.m +22 -7
- package/ios/RNSScreenStackAnimator.m +45 -14
- package/ios/RNSScreenStackHeaderConfig.m +4 -1
- package/ios/RNSScreenWindowTraits.h +1 -0
- package/ios/RNSScreenWindowTraits.m +20 -0
- package/ios/UIViewController+RNScreens.m +10 -0
- package/lib/commonjs/native-stack/views/NativeStackView.js +33 -4
- package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.js +33 -4
- package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/typescript/native-stack/types.d.ts +34 -0
- package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
- package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
- package/lib/typescript/types.d.ts +60 -5
- package/native-stack/README.md +39 -3
- package/package.json +1 -1
- package/reanimated/package.json +6 -0
- package/src/native-stack/types.tsx +34 -0
- package/src/native-stack/views/NativeStackView.tsx +33 -4
- package/src/types.tsx +60 -5
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
}
|