react-native-screens 3.13.1 → 3.15.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 (123) hide show
  1. package/README.md +2 -2
  2. package/RNScreens.podspec +5 -4
  3. package/android/build.gradle +18 -1
  4. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +0 -5
  5. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +8 -4
  6. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +24 -6
  7. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +17 -21
  8. package/android/src/main/jni/Android.mk +1 -2
  9. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerDelegate.java +39 -14
  10. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerInterface.java +15 -6
  11. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +3 -3
  12. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +1 -1
  13. package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +4 -10
  14. package/common/cpp/Android.mk +1 -2
  15. package/createNativeStackNavigator/README.md +4 -0
  16. package/ios/RNSConvert.h +30 -0
  17. package/ios/RNSConvert.mm +120 -0
  18. package/ios/RNSEnums.h +59 -0
  19. package/ios/RNSFullWindowOverlay.h +17 -2
  20. package/ios/RNSFullWindowOverlay.mm +199 -0
  21. package/ios/RNSScreen.h +70 -79
  22. package/ios/{RNSScreen.m → RNSScreen.mm} +678 -302
  23. package/ios/RNSScreenContainer.h +15 -1
  24. package/ios/{RNSScreenContainer.m → RNSScreenContainer.mm} +99 -8
  25. package/ios/{RNSScreenNavigationContainer.m → RNSScreenNavigationContainer.mm} +22 -0
  26. package/ios/RNSScreenStack.h +19 -3
  27. package/ios/{RNSScreenStack.m → RNSScreenStack.mm} +431 -137
  28. package/ios/{RNSScreenStackAnimator.m → RNSScreenStackAnimator.mm} +19 -14
  29. package/ios/RNSScreenStackHeaderConfig.h +20 -21
  30. package/ios/{RNSScreenStackHeaderConfig.m → RNSScreenStackHeaderConfig.mm} +232 -117
  31. package/ios/RNSScreenStackHeaderSubview.h +45 -0
  32. package/ios/RNSScreenStackHeaderSubview.mm +137 -0
  33. package/ios/RNSScreenViewEvent.h +12 -0
  34. package/ios/RNSScreenViewEvent.mm +59 -0
  35. package/ios/{RNSScreenWindowTraits.m → RNSScreenWindowTraits.mm} +3 -2
  36. package/ios/RNSSearchBar.h +14 -1
  37. package/ios/RNSSearchBar.mm +351 -0
  38. package/ios/{UIViewController+RNScreens.m → UIViewController+RNScreens.mm} +0 -0
  39. package/ios/{UIWindow+RNScreens.m → UIWindow+RNScreens.mm} +0 -0
  40. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +21 -0
  41. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -0
  42. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +21 -0
  43. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js.map +1 -0
  44. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
  45. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +21 -0
  46. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -0
  47. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  48. package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
  49. package/lib/commonjs/fabric/SearchBarNativeComponent.js +25 -0
  50. package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -0
  51. package/lib/commonjs/index.native.js +20 -32
  52. package/lib/commonjs/index.native.js.map +1 -1
  53. package/lib/commonjs/native-stack/views/NativeStackView.js +4 -0
  54. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  55. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +10 -2
  56. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  57. package/lib/module/fabric/FullWindowOverlayNativeComponent.js +9 -0
  58. package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -0
  59. package/lib/module/fabric/ScreenContainerNativeComponent.js +9 -0
  60. package/lib/module/fabric/ScreenContainerNativeComponent.js.map +1 -0
  61. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
  62. package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js +9 -0
  63. package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -0
  64. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  65. package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
  66. package/lib/module/fabric/SearchBarNativeComponent.js +11 -0
  67. package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -0
  68. package/lib/module/index.native.js +21 -34
  69. package/lib/module/index.native.js.map +1 -1
  70. package/lib/module/native-stack/views/NativeStackView.js +4 -0
  71. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  72. package/lib/module/reanimated/ReanimatedNativeStackScreen.js +9 -2
  73. package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  74. package/lib/typescript/native-stack/types.d.ts +12 -0
  75. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
  76. package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
  77. package/lib/typescript/types.d.ts +24 -0
  78. package/native-stack/README.md +21 -0
  79. package/package.json +2 -2
  80. package/src/fabric/FullWindowOverlayNativeComponent.js +19 -0
  81. package/src/fabric/ScreenContainerNativeComponent.js +19 -0
  82. package/src/fabric/ScreenNativeComponent.js +41 -8
  83. package/src/fabric/ScreenNavigationContainerNativeComponent.js +19 -0
  84. package/src/fabric/ScreenStackHeaderConfigNativeComponent.js +1 -1
  85. package/src/fabric/ScreenStackNativeComponent.js +4 -0
  86. package/src/fabric/SearchBarNativeComponent.js +62 -0
  87. package/src/index.native.tsx +17 -36
  88. package/src/native-stack/types.tsx +12 -0
  89. package/src/native-stack/views/NativeStackView.tsx +4 -0
  90. package/src/reanimated/ReanimatedNativeStackScreen.tsx +8 -0
  91. package/src/types.tsx +25 -0
  92. package/ios/RNSFullWindowOverlay.m +0 -105
  93. package/ios/RNSScreenComponentView.h +0 -23
  94. package/ios/RNSScreenComponentView.mm +0 -159
  95. package/ios/RNSScreenController.h +0 -10
  96. package/ios/RNSScreenController.mm +0 -79
  97. package/ios/RNSScreenStackComponentView.h +0 -15
  98. package/ios/RNSScreenStackComponentView.mm +0 -295
  99. package/ios/RNSScreenStackHeaderConfigComponentView.h +0 -42
  100. package/ios/RNSScreenStackHeaderConfigComponentView.mm +0 -662
  101. package/ios/RNSScreenStackHeaderSubviewComponentView.h +0 -14
  102. package/ios/RNSScreenStackHeaderSubviewComponentView.mm +0 -77
  103. package/ios/RNSSearchBar.m +0 -198
  104. package/lib/commonjs/fabric/Screen.js +0 -29
  105. package/lib/commonjs/fabric/Screen.js.map +0 -1
  106. package/lib/commonjs/fabric/ScreenStack.js +0 -26
  107. package/lib/commonjs/fabric/ScreenStack.js.map +0 -1
  108. package/lib/commonjs/fabric/ScreenStackHeaderSubview.js +0 -37
  109. package/lib/commonjs/fabric/ScreenStackHeaderSubview.js.map +0 -1
  110. package/lib/commonjs/fabric/index.js +0 -40
  111. package/lib/commonjs/fabric/index.js.map +0 -1
  112. package/lib/module/fabric/Screen.js +0 -16
  113. package/lib/module/fabric/Screen.js.map +0 -1
  114. package/lib/module/fabric/ScreenStack.js +0 -15
  115. package/lib/module/fabric/ScreenStack.js.map +0 -1
  116. package/lib/module/fabric/ScreenStackHeaderSubview.js +0 -24
  117. package/lib/module/fabric/ScreenStackHeaderSubview.js.map +0 -1
  118. package/lib/module/fabric/index.js +0 -6
  119. package/lib/module/fabric/index.js.map +0 -1
  120. package/src/fabric/Screen.js +0 -15
  121. package/src/fabric/ScreenStack.js +0 -10
  122. package/src/fabric/ScreenStackHeaderSubview.js +0 -22
  123. package/src/fabric/index.js +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-screens",
3
- "version": "3.13.1",
3
+ "version": "3.15.0",
4
4
  "description": "Native navigation primitives for your React Native app.",
5
5
  "scripts": {
6
6
  "check-types": "tsc --noEmit",
@@ -111,7 +111,7 @@
111
111
  "{src,Example}/**/*.{js,ts,tsx}": "yarn format-js",
112
112
  "src/**/*.{js,ts,tsx}": "yarn lint-js",
113
113
  "android/**/*.kt": "yarn format-android",
114
- "ios/**/*.{h,m,cpp}": "yarn format-ios"
114
+ "ios/**/*.{h,m,mm,cpp}": "yarn format-ios"
115
115
  },
116
116
  "@react-native-community/bob": {
117
117
  "source": "src",
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
8
+ import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
9
+
10
+ type NativeProps = $ReadOnly<{|
11
+ ...ViewProps,
12
+ |}>;
13
+
14
+ type ComponentType = HostComponent<NativeProps>;
15
+
16
+ export default (codegenNativeComponent<NativeProps>(
17
+ 'RNSFullWindowOverlay',
18
+ {}
19
+ ): ComponentType);
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
8
+ import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
9
+
10
+ type NativeProps = $ReadOnly<{|
11
+ ...ViewProps,
12
+ |}>;
13
+
14
+ type ComponentType = HostComponent<NativeProps>;
15
+
16
+ export default (codegenNativeComponent<NativeProps>(
17
+ 'RNSScreenContainer',
18
+ {}
19
+ ): ComponentType);
@@ -19,7 +19,28 @@ type ScreenDismissedEvent = $ReadOnly<{|
19
19
  dismissCount: Int32,
20
20
  |}>;
21
21
 
22
- type StackPresentation = 'push' | 'modal' | 'transparentModal';
22
+ type TransitionProgressEvent = $ReadOnly<{|
23
+ progress: Double,
24
+ closing: Int32,
25
+ goingForward: Int32,
26
+ |}>;
27
+
28
+ type GestureResponseDistanceType = $ReadOnly<{|
29
+ start: Float,
30
+ end: Float,
31
+ top: Float,
32
+ bottom: Float,
33
+ |}>;
34
+
35
+ type StackPresentation =
36
+ | 'push'
37
+ | 'modal'
38
+ | 'transparentModal'
39
+ | 'fullScreenModal'
40
+ | 'formSheet'
41
+ | 'containedModal'
42
+ | 'containedTransparentModal';
43
+
23
44
  type StackAnimation =
24
45
  | 'default'
25
46
  | 'flip'
@@ -31,6 +52,8 @@ type StackAnimation =
31
52
  | 'slide_from_bottom'
32
53
  | 'fade_from_bottom';
33
54
 
55
+ type SwipeDirection = 'vertical' | 'horizontal';
56
+
34
57
  type ReplaceAnimation = 'pop' | 'push';
35
58
 
36
59
  export type NativeProps = $ReadOnly<{|
@@ -38,23 +61,33 @@ export type NativeProps = $ReadOnly<{|
38
61
  onAppear?: ?BubblingEventHandler<ScreenEvent>,
39
62
  onDisappear?: ?BubblingEventHandler<ScreenEvent>,
40
63
  onDismissed?: ?BubblingEventHandler<ScreenDismissedEvent>,
64
+ onNativeDismissCancelled?: ?BubblingEventHandler<ScreenDismissedEvent>,
41
65
  onWillAppear?: ?BubblingEventHandler<ScreenEvent>,
42
66
  onWillDisappear?: ?BubblingEventHandler<ScreenEvent>,
43
- // TODO: implement this props on iOS
44
- stackPresentation?: WithDefault<StackPresentation, 'push'>,
45
- stackAnimation?: WithDefault<StackAnimation, 'default'>,
67
+ onTransitionProgress?: ?BubblingEventHandler<TransitionProgressEvent>,
68
+ customAnimationOnSwipe?: boolean,
69
+ fullScreenSwipeEnabled?: boolean,
70
+ homeIndicatorHidden?: boolean,
71
+ preventNativeDismiss?: boolean,
46
72
  gestureEnabled?: WithDefault<boolean, true>,
47
- replaceAnimation?: WithDefault<ReplaceAnimation, 'pop'>,
73
+ statusBarColor?: ColorValue,
74
+ statusBarHidden?: boolean,
48
75
  screenOrientation?: string,
49
76
  statusBarAnimation?: string,
50
- statusBarColor?: ColorValue,
51
77
  statusBarStyle?: string,
52
78
  statusBarTranslucent?: boolean,
53
- statusBarHidden?: boolean,
79
+ gestureResponseDistance?: GestureResponseDistanceType,
80
+ stackPresentation?: WithDefault<StackPresentation, 'push'>,
81
+ stackAnimation?: WithDefault<StackAnimation, 'default'>,
82
+ transitionDuration?: WithDefault<Int32, 350>,
83
+ replaceAnimation?: WithDefault<ReplaceAnimation, 'pop'>,
84
+ swipeDirection?: WithDefault<SwipeDirection, 'horizontal'>,
85
+ hideKeyboardOnSwipe?: boolean,
86
+ activityState?: WithDefault<Float, -1.0>,
87
+ // TODO: implement these props on iOS
54
88
  navigationBarColor?: ColorValue,
55
89
  navigationBarHidden?: boolean,
56
90
  nativeBackButtonDismissalEnabled?: boolean,
57
- activityState?: WithDefault<Int32, -1>,
58
91
  |}>;
59
92
 
60
93
  type ComponentType = HostComponent<NativeProps>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
8
+ import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
9
+
10
+ type NativeProps = $ReadOnly<{|
11
+ ...ViewProps,
12
+ |}>;
13
+
14
+ type ComponentType = HostComponent<NativeProps>;
15
+
16
+ export default (codegenNativeComponent<NativeProps>(
17
+ 'RNSScreenNavigationContainer',
18
+ {}
19
+ ): ComponentType);
@@ -41,9 +41,9 @@ export type NativeProps = $ReadOnly<{|
41
41
  titleColor?: ColorValue,
42
42
  disableBackButtonMenu?: boolean,
43
43
  hideBackButton?: boolean,
44
+ backButtonInCustomView?: boolean,
44
45
  // TODO: implement this props on iOS
45
46
  topInsetEnabled?: boolean,
46
- backButtonInCustomView?: boolean,
47
47
  |}>;
48
48
 
49
49
  type ComponentType = HostComponent<NativeProps>;
@@ -6,9 +6,13 @@
6
6
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
7
  import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
8
8
  import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
9
+ import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
10
+
11
+ type FinishTransitioningEvent = $ReadOnly<{||}>;
9
12
 
10
13
  type NativeProps = $ReadOnly<{|
11
14
  ...ViewProps,
15
+ onFinishTransitioning?: ?DirectEventHandler<FinishTransitioningEvent>,
12
16
  |}>;
13
17
 
14
18
  type ComponentType = HostComponent<NativeProps>;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
8
+ import type { HostComponent } from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
9
+ import { ColorValue } from 'react-native/Libraries/StyleSheet/StyleSheet';
10
+ import type {
11
+ WithDefault,
12
+ BubblingEventHandler,
13
+ } from 'react-native/Libraries/Types/CodegenTypes';
14
+ import { tintColor } from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
15
+
16
+ type SearchBarEvent = $ReadOnly<{||}>;
17
+
18
+ type SearchButtonPressedEvent = $ReadOnly<{|
19
+ text?: string,
20
+ |}>;
21
+
22
+ type ChangeTextEvent = $ReadOnly<{|
23
+ text?: string,
24
+ |}>;
25
+
26
+ type AutoCapitalizeType = 'none' | 'words' | 'sentences' | 'characters';
27
+
28
+ type NativeProps = $ReadOnly<{|
29
+ ...ViewProps,
30
+ onFocus?: ?BubblingEventHandler<SearchBarEvent>,
31
+ onBlur?: ?BubblingEventHandler<SearchBarEvent>,
32
+ onSearchButtonPress?: ?BubblingEventHandler<SearchButtonPressedEvent>,
33
+ onCancelButtonPress?: ?BubblingEventHandler<SearchBarEvent>,
34
+ onChangeText?: ?BubblingEventHandler<ChangeTextEvent>,
35
+ hideWhenScrolling?: boolean,
36
+ autoCapitalize?: WithDefault<AutoCapitalizeType, 'none'>,
37
+ placeholder?: string,
38
+ obscureBackground?: boolean,
39
+ hideNavigationBar?: boolean,
40
+ cancelButtonText?: string,
41
+ // TODO: implement these on iOS
42
+ barTintColor?: ColorValue,
43
+ tintColor?: ColorValue,
44
+ textColor?: ColorValue,
45
+
46
+ // Android only
47
+ disableBackButtonOverride?: boolean,
48
+ // TODO: consider creating enum here
49
+ inputType?: string,
50
+ onClose?: ?BubblingEventHandler<SearchBarEvent>,
51
+ onOpen?: ?BubblingEventHandler<SearchBarEvent>,
52
+ hintTextColor?: ColorValue,
53
+ headerIconColor?: ColorValue,
54
+ shouldShowHintSearchIcon?: WithDefault<boolean, true>,
55
+ |}>;
56
+
57
+ type ComponentType = HostComponent<NativeProps>;
58
+
59
+ export default (codegenNativeComponent<NativeProps>(
60
+ 'RNSSearchBar',
61
+ {}
62
+ ): ComponentType);
@@ -11,9 +11,6 @@ import {
11
11
  ViewProps,
12
12
  } from 'react-native';
13
13
  import { Freeze } from 'react-freeze';
14
- // @ts-ignore Getting private component
15
- // eslint-disable-next-line import/default
16
- import processColor from 'react-native/Libraries/StyleSheet/processColor';
17
14
  import { version } from 'react-native/package.json';
18
15
 
19
16
  import TransitionProgressContext from './TransitionProgressContext';
@@ -44,11 +41,6 @@ const isPlatformSupported =
44
41
 
45
42
  let ENABLE_SCREENS = isPlatformSupported;
46
43
 
47
- // @ts-expect-error nativeFabricUIManager is not yet included in the RN types
48
- const ENABLE_FABRIC = !!global?.nativeFabricUIManager;
49
-
50
- const FabricComponents = ENABLE_FABRIC ? require('./fabric') : {};
51
-
52
44
  function enableScreens(shouldEnableScreens = true): void {
53
45
  ENABLE_SCREENS = isPlatformSupported && shouldEnableScreens;
54
46
  if (ENABLE_SCREENS && !UIManager.getViewManagerConfig('RNSScreen')) {
@@ -97,9 +89,7 @@ let NativeFullWindowOverlay: React.ComponentType<View>;
97
89
  const ScreensNativeModules = {
98
90
  get NativeScreen() {
99
91
  NativeScreenValue =
100
- NativeScreenValue ||
101
- FabricComponents.Screen ||
102
- requireNativeComponent('RNSScreen');
92
+ NativeScreenValue || requireNativeComponent('RNSScreen');
103
93
  return NativeScreenValue;
104
94
  },
105
95
 
@@ -121,16 +111,13 @@ const ScreensNativeModules = {
121
111
 
122
112
  get NativeScreenStack() {
123
113
  NativeScreenStack =
124
- NativeScreenStack ||
125
- FabricComponents.ScreenStack ||
126
- requireNativeComponent('RNSScreenStack');
114
+ NativeScreenStack || requireNativeComponent('RNSScreenStack');
127
115
  return NativeScreenStack;
128
116
  },
129
117
 
130
118
  get NativeScreenStackHeaderConfig() {
131
119
  NativeScreenStackHeaderConfig =
132
120
  NativeScreenStackHeaderConfig ||
133
- FabricComponents.ScreenStackHeaderConfig ||
134
121
  requireNativeComponent('RNSScreenStackHeaderConfig');
135
122
  return NativeScreenStackHeaderConfig;
136
123
  },
@@ -138,7 +125,6 @@ const ScreensNativeModules = {
138
125
  get NativeScreenStackHeaderSubview() {
139
126
  NativeScreenStackHeaderSubview =
140
127
  NativeScreenStackHeaderSubview ||
141
- FabricComponents.ScreenStackHeaderSubview ||
142
128
  requireNativeComponent('RNSScreenStackHeaderSubview');
143
129
  return NativeScreenStackHeaderSubview;
144
130
  },
@@ -233,15 +219,9 @@ class Screen extends React.Component<ScreenProps> {
233
219
  const { enabled = ENABLE_SCREENS, ...rest } = this.props;
234
220
 
235
221
  if (enabled && isPlatformSupported) {
236
- if (!AnimatedNativeScreen) {
237
- if (ENABLE_FABRIC) {
238
- AnimatedNativeScreen = ScreensNativeModules.NativeScreen;
239
- } else {
240
- AnimatedNativeScreen = Animated.createAnimatedComponent(
241
- ScreensNativeModules.NativeScreen
242
- ) as React.ComponentType<ScreenProps>;
243
- }
244
- }
222
+ AnimatedNativeScreen =
223
+ AnimatedNativeScreen ||
224
+ Animated.createAnimatedComponent(ScreensNativeModules.NativeScreen);
245
225
 
246
226
  let {
247
227
  // Filter out active prop in this case because it is unused and
@@ -251,7 +231,7 @@ class Screen extends React.Component<ScreenProps> {
251
231
  activityState,
252
232
  children,
253
233
  isNativeStack,
254
- statusBarColor,
234
+ gestureResponseDistance,
255
235
  ...props
256
236
  } = rest;
257
237
 
@@ -262,16 +242,12 @@ class Screen extends React.Component<ScreenProps> {
262
242
  activityState = active !== 0 ? 2 : 0; // in the new version, we need one of the screens to have value of 2 after the transition
263
243
  }
264
244
 
265
- const processedColor = processColor(statusBarColor);
266
-
267
245
  const handleRef = (ref: ViewConfig) => {
268
- if (!ENABLE_FABRIC) {
269
- if (ref?.viewConfig?.validAttributes?.style) {
270
- ref.viewConfig.validAttributes.style = {
271
- ...ref.viewConfig.validAttributes.style,
272
- display: false,
273
- };
274
- }
246
+ if (ref?.viewConfig?.validAttributes?.style) {
247
+ ref.viewConfig.validAttributes.style = {
248
+ ...ref.viewConfig.validAttributes.style,
249
+ display: false,
250
+ };
275
251
  this.setRef(ref);
276
252
  }
277
253
  };
@@ -280,8 +256,13 @@ class Screen extends React.Component<ScreenProps> {
280
256
  <MaybeFreeze freeze={activityState === 0}>
281
257
  <AnimatedNativeScreen
282
258
  {...props}
283
- statusBarColor={processedColor}
284
259
  activityState={activityState}
260
+ gestureResponseDistance={{
261
+ start: gestureResponseDistance?.start ?? -1,
262
+ end: gestureResponseDistance?.end ?? -1,
263
+ top: gestureResponseDistance?.top ?? -1,
264
+ bottom: gestureResponseDistance?.bottom ?? -1,
265
+ }}
285
266
  // This prevents showing blank screen when navigating between multiple screens with freezing
286
267
  // https://github.com/software-mansion/react-native-screens/pull/1208
287
268
  ref={handleRef}
@@ -111,6 +111,12 @@ export type NativeStackNavigationOptions = {
111
111
  * @platform ios
112
112
  */
113
113
  gestureEnabled?: boolean;
114
+ /**
115
+ * Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`.
116
+ *
117
+ * @platform ios
118
+ */
119
+ gestureResponseDistance?: ScreenProps['gestureResponseDistance'];
114
120
  /**
115
121
  * Title to display in the back button.
116
122
  * Only supported on iOS.
@@ -249,6 +255,12 @@ export type NativeStackNavigationOptions = {
249
255
  * @platform ios
250
256
  */
251
257
  homeIndicatorHidden?: boolean;
258
+ /**
259
+ * Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.
260
+ *
261
+ * @platform ios
262
+ */
263
+ hideKeyboardOnSwipe?: boolean;
252
264
  /**
253
265
  * 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.
254
266
  * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
@@ -151,6 +151,7 @@ const RouteView = ({
151
151
  const {
152
152
  gestureEnabled,
153
153
  headerShown,
154
+ hideKeyboardOnSwipe,
154
155
  homeIndicatorHidden,
155
156
  nativeBackButtonDismissalEnabled = false,
156
157
  navigationBarColor,
@@ -169,6 +170,7 @@ const RouteView = ({
169
170
  let {
170
171
  customAnimationOnSwipe,
171
172
  fullScreenSwipeEnabled,
173
+ gestureResponseDistance,
172
174
  stackAnimation,
173
175
  stackPresentation = 'push',
174
176
  } = options;
@@ -218,8 +220,10 @@ const RouteView = ({
218
220
  style={StyleSheet.absoluteFill}
219
221
  customAnimationOnSwipe={customAnimationOnSwipe}
220
222
  fullScreenSwipeEnabled={fullScreenSwipeEnabled}
223
+ hideKeyboardOnSwipe={hideKeyboardOnSwipe}
221
224
  homeIndicatorHidden={homeIndicatorHidden}
222
225
  gestureEnabled={isAndroid ? false : gestureEnabled}
226
+ gestureResponseDistance={gestureResponseDistance}
223
227
  nativeBackButtonDismissalEnabled={nativeBackButtonDismissalEnabled}
224
228
  navigationBarColor={navigationBarColor}
225
229
  navigationBarHidden={navigationBarHidden}
@@ -14,6 +14,11 @@ const AnimatedScreen = Animated.createAnimatedComponent(
14
14
  (Screen as unknown) as React.ComponentClass
15
15
  );
16
16
 
17
+ // We use prop added to global by reanimated since it seems safer than the one from RN. See:
18
+ // https://github.com/software-mansion/react-native-reanimated/blob/3fe8b35b05e82b2f2aefda1fb97799cf81e4b7bb/src/reanimated2/UpdateProps.ts#L46
19
+ // @ts-expect-error nativeFabricUIManager is not yet included in the RN types
20
+ const ENABLE_FABRIC = !!global?._IS_FABRIC;
21
+
17
22
  const ReanimatedNativeStackScreen = React.forwardRef<
18
23
  typeof AnimatedScreen,
19
24
  ScreenProps
@@ -39,6 +44,9 @@ const ReanimatedNativeStackScreen = React.forwardRef<
39
44
  // This should not be necessary, but is not properly managed by `react-native-reanimated`
40
45
  // @ts-ignore wrong type
41
46
  Platform.OS === 'android'
47
+ ? 'onTransitionProgress'
48
+ : // for some reason there is a difference in required event name between architectures
49
+ ENABLE_FABRIC
42
50
  ? 'onTransitionProgress'
43
51
  : 'topTransitionProgress',
44
52
  ]
package/src/types.tsx CHANGED
@@ -70,6 +70,13 @@ export type TransitionProgressEventType = {
70
70
  goingForward: number;
71
71
  };
72
72
 
73
+ export type GestureResponseDistanceType = {
74
+ start?: number;
75
+ end?: number;
76
+ top?: number;
77
+ bottom?: number;
78
+ };
79
+
73
80
  export interface ScreenProps extends ViewProps {
74
81
  active?: 0 | 1 | Animated.AnimatedInterpolation;
75
82
  activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation;
@@ -102,12 +109,24 @@ export interface ScreenProps extends ViewProps {
102
109
  * @platform ios
103
110
  */
104
111
  gestureEnabled?: boolean;
112
+ /**
113
+ * Use it to restrict the distance from the edges of screen in which the gesture should be recognized. To be used alongside `fullScreenSwipeEnabled`.
114
+ *
115
+ * @platform ios
116
+ */
117
+ gestureResponseDistance?: GestureResponseDistanceType;
105
118
  /**
106
119
  * Whether the home indicator should be hidden on this screen. Defaults to `false`.
107
120
  *
108
121
  * @platform ios
109
122
  */
110
123
  homeIndicatorHidden?: boolean;
124
+ /**
125
+ * Whether the keyboard should hide when swiping to the previous screen. Defaults to `false`.
126
+ *
127
+ * @platform ios
128
+ */
129
+ hideKeyboardOnSwipe?: boolean;
111
130
  /**
112
131
  * 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.
113
132
  * Unfortunately the same behavior is not available on iOS since the behavior of native back button cannot be changed there.
@@ -425,6 +444,12 @@ export interface SearchBarProps {
425
444
  * The search field background color
426
445
  */
427
446
  barTintColor?: string;
447
+ /**
448
+ * The color for the cursor caret and cancel button text.
449
+ *
450
+ * @platform ios
451
+ */
452
+ tintColor?: string;
428
453
  /**
429
454
  * The text to be used instead of default `Cancel` button text
430
455
  *
@@ -1,105 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- #import "RNSFullWindowOverlay.h"
4
-
5
- #import <React/RCTTouchHandler.h>
6
-
7
- @implementation RNSFullWindowOverlayContainer
8
-
9
- - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
10
- {
11
- for (UIView *view in [self subviews]) {
12
- if (view.userInteractionEnabled && [view pointInside:[self convertPoint:point toView:view] withEvent:event]) {
13
- return YES;
14
- }
15
- }
16
- return NO;
17
- }
18
-
19
- @end
20
-
21
- @implementation RNSFullWindowOverlay {
22
- __weak RCTBridge *_bridge;
23
- RNSFullWindowOverlayContainer *_container;
24
- CGRect _reactFrame;
25
- RCTTouchHandler *_touchHandler;
26
- }
27
-
28
- - (instancetype)initWithBridge:(RCTBridge *)bridge
29
- {
30
- if (self = [super init]) {
31
- _bridge = bridge;
32
- _reactFrame = CGRectNull;
33
- _container = self.container;
34
- [self show];
35
- }
36
-
37
- return self;
38
- }
39
-
40
- - (void)reactSetFrame:(CGRect)frame
41
- {
42
- _reactFrame = frame;
43
- [_container setFrame:frame];
44
- }
45
-
46
- - (void)addSubview:(UIView *)view
47
- {
48
- [_container addSubview:view];
49
- }
50
-
51
- - (RNSFullWindowOverlayContainer *)container
52
- {
53
- if (_container == nil) {
54
- _container = [[RNSFullWindowOverlayContainer alloc] initWithFrame:_reactFrame];
55
- }
56
-
57
- return _container;
58
- }
59
-
60
- - (void)show
61
- {
62
- UIWindow *window = RCTSharedApplication().delegate.window;
63
- [window addSubview:_container];
64
- }
65
-
66
- - (void)hide
67
- {
68
- if (!_container) {
69
- return;
70
- }
71
-
72
- [_container removeFromSuperview];
73
- }
74
-
75
- - (void)didMoveToWindow
76
- {
77
- if (self.window == nil) {
78
- [self hide];
79
- [_touchHandler detachFromView:_container];
80
- } else {
81
- if (_touchHandler == nil) {
82
- _touchHandler = [[RCTTouchHandler alloc] initWithBridge:_bridge];
83
- }
84
- [_touchHandler attachToView:_container];
85
- }
86
- }
87
-
88
- - (void)invalidate
89
- {
90
- [self hide];
91
- _container = nil;
92
- }
93
-
94
- @end
95
-
96
- @implementation RNSFullWindowOverlayManager
97
-
98
- RCT_EXPORT_MODULE()
99
-
100
- - (UIView *)view
101
- {
102
- return [[RNSFullWindowOverlay alloc] initWithBridge:self.bridge];
103
- }
104
-
105
- @end
@@ -1,23 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- #import <React/RCTViewComponentView.h>
4
- #import "RNSScreenController.h"
5
-
6
- NS_ASSUME_NONNULL_BEGIN
7
-
8
- @interface RNSScreenComponentView : RCTViewComponentView
9
-
10
- @property (weak, nonatomic) UIView *reactSuperview;
11
- @property (weak, nonatomic) UIView *config;
12
- @property (nonatomic, retain) RNSScreenController *controller;
13
-
14
- - (void)notifyWillAppear;
15
- - (void)notifyWillDisappear;
16
- - (void)notifyAppear;
17
- - (void)notifyDisappear;
18
- - (void)updateBounds;
19
- - (void)notifyDismissedWithCount:(int)dismissCount;
20
-
21
- @end
22
-
23
- NS_ASSUME_NONNULL_END