react-native-screens 4.0.0-beta.12 → 4.0.0-beta.14

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 (197) hide show
  1. package/README.md +3 -1
  2. package/android/CMakeLists.txt +28 -19
  3. package/android/src/main/java/com/swmansion/rnscreens/NativeDismissalObserver.kt +12 -0
  4. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +59 -84
  5. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/BottomSheetBehaviorExt.kt +42 -0
  6. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/DimmingFragment.kt +24 -19
  7. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetUtils.kt +8 -0
  8. package/android/src/main/jni/CMakeLists.txt +28 -19
  9. package/ios/RNSConvert.h +13 -4
  10. package/ios/RNSConvert.mm +50 -28
  11. package/ios/RNSEnums.h +46 -0
  12. package/ios/RNSScreenStackHeaderConfig.h +1 -1
  13. package/ios/RNSScreenStackHeaderConfig.mm +30 -25
  14. package/lib/commonjs/components/FullWindowOverlay.js +8 -5
  15. package/lib/commonjs/components/FullWindowOverlay.js.map +1 -1
  16. package/lib/commonjs/components/Screen.js +28 -10
  17. package/lib/commonjs/components/Screen.js.map +1 -1
  18. package/lib/commonjs/components/ScreenContainer.js +3 -5
  19. package/lib/commonjs/components/ScreenContainer.js.map +1 -1
  20. package/lib/commonjs/components/ScreenContainer.web.js +3 -4
  21. package/lib/commonjs/components/ScreenContainer.web.js.map +1 -1
  22. package/lib/commonjs/components/ScreenContentWrapper.js +2 -4
  23. package/lib/commonjs/components/ScreenContentWrapper.js.map +1 -1
  24. package/lib/commonjs/components/ScreenContentWrapper.web.js +1 -2
  25. package/lib/commonjs/components/ScreenContentWrapper.web.js.map +1 -1
  26. package/lib/commonjs/components/ScreenFooter.js +2 -8
  27. package/lib/commonjs/components/ScreenFooter.js.map +1 -1
  28. package/lib/commonjs/components/ScreenFooter.web.js +1 -2
  29. package/lib/commonjs/components/ScreenFooter.web.js.map +1 -1
  30. package/lib/commonjs/components/ScreenStack.js +2 -2
  31. package/lib/commonjs/components/ScreenStack.js.map +1 -1
  32. package/lib/commonjs/components/ScreenStack.web.js +2 -1
  33. package/lib/commonjs/components/ScreenStack.web.js.map +1 -1
  34. package/lib/commonjs/components/SearchBar.js +5 -5
  35. package/lib/commonjs/components/SearchBar.js.map +1 -1
  36. package/lib/commonjs/components/SearchBar.web.js +3 -4
  37. package/lib/commonjs/components/SearchBar.web.js.map +1 -1
  38. package/lib/commonjs/core.js +0 -3
  39. package/lib/commonjs/core.js.map +1 -1
  40. package/lib/commonjs/fabric/ModalScreenNativeComponent.js.map +1 -1
  41. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  42. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js +2 -2
  43. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js.map +1 -1
  44. package/lib/commonjs/index.js +14 -78
  45. package/lib/commonjs/index.js.map +1 -1
  46. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +4 -0
  47. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  48. package/lib/commonjs/native-stack/views/FooterComponent.js +2 -2
  49. package/lib/commonjs/native-stack/views/FooterComponent.js.map +1 -1
  50. package/lib/commonjs/native-stack/views/HeaderConfig.js +10 -8
  51. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  52. package/lib/commonjs/native-stack/views/NativeStackView.js +12 -9
  53. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  54. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +2 -2
  55. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  56. package/lib/commonjs/reanimated/ReanimatedScreen.js +2 -2
  57. package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
  58. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +2 -2
  59. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
  60. package/lib/commonjs/utils.js +28 -6
  61. package/lib/commonjs/utils.js.map +1 -1
  62. package/lib/module/components/FullWindowOverlay.js +9 -6
  63. package/lib/module/components/FullWindowOverlay.js.map +1 -1
  64. package/lib/module/components/Screen.js +27 -9
  65. package/lib/module/components/Screen.js.map +1 -1
  66. package/lib/module/components/ScreenContainer.js +2 -4
  67. package/lib/module/components/ScreenContainer.js.map +1 -1
  68. package/lib/module/components/ScreenContainer.web.js +2 -3
  69. package/lib/module/components/ScreenContainer.web.js.map +1 -1
  70. package/lib/module/components/ScreenContentWrapper.js +1 -3
  71. package/lib/module/components/ScreenContentWrapper.js.map +1 -1
  72. package/lib/module/components/ScreenContentWrapper.web.js +0 -1
  73. package/lib/module/components/ScreenContentWrapper.web.js.map +1 -1
  74. package/lib/module/components/ScreenFooter.js +1 -7
  75. package/lib/module/components/ScreenFooter.js.map +1 -1
  76. package/lib/module/components/ScreenFooter.web.js +0 -1
  77. package/lib/module/components/ScreenFooter.web.js.map +1 -1
  78. package/lib/module/components/ScreenStack.js +1 -1
  79. package/lib/module/components/ScreenStack.js.map +1 -1
  80. package/lib/module/components/ScreenStack.web.js +2 -1
  81. package/lib/module/components/ScreenStack.web.js.map +1 -1
  82. package/lib/module/components/SearchBar.js +3 -3
  83. package/lib/module/components/SearchBar.js.map +1 -1
  84. package/lib/module/components/SearchBar.web.js +2 -3
  85. package/lib/module/components/SearchBar.web.js.map +1 -1
  86. package/lib/module/core.js +0 -3
  87. package/lib/module/core.js.map +1 -1
  88. package/lib/module/fabric/ModalScreenNativeComponent.js.map +1 -1
  89. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  90. package/lib/module/gesture-handler/GestureDetectorProvider.js +1 -1
  91. package/lib/module/gesture-handler/GestureDetectorProvider.js.map +1 -1
  92. package/lib/module/index.js +8 -13
  93. package/lib/module/index.js.map +1 -1
  94. package/lib/module/native-stack/navigators/createNativeStackNavigator.js +4 -0
  95. package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  96. package/lib/module/native-stack/views/FooterComponent.js +1 -1
  97. package/lib/module/native-stack/views/FooterComponent.js.map +1 -1
  98. package/lib/module/native-stack/views/HeaderConfig.js +3 -1
  99. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  100. package/lib/module/native-stack/views/NativeStackView.js +4 -1
  101. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  102. package/lib/module/reanimated/ReanimatedNativeStackScreen.js +1 -2
  103. package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  104. package/lib/module/reanimated/ReanimatedScreen.js +1 -2
  105. package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
  106. package/lib/module/reanimated/ReanimatedScreenProvider.js +1 -1
  107. package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
  108. package/lib/module/utils.js +26 -5
  109. package/lib/module/utils.js.map +1 -1
  110. package/lib/typescript/components/FullWindowOverlay.d.ts.map +1 -1
  111. package/lib/typescript/components/Screen.d.ts +2 -7
  112. package/lib/typescript/components/Screen.d.ts.map +1 -1
  113. package/lib/typescript/components/Screen.web.d.ts +1 -1
  114. package/lib/typescript/components/Screen.web.d.ts.map +1 -1
  115. package/lib/typescript/components/ScreenContainer.d.ts +1 -3
  116. package/lib/typescript/components/ScreenContainer.d.ts.map +1 -1
  117. package/lib/typescript/components/ScreenContainer.web.d.ts +2 -3
  118. package/lib/typescript/components/ScreenContainer.web.d.ts.map +1 -1
  119. package/lib/typescript/components/ScreenContentWrapper.d.ts +0 -1
  120. package/lib/typescript/components/ScreenContentWrapper.d.ts.map +1 -1
  121. package/lib/typescript/components/ScreenContentWrapper.web.d.ts +0 -1
  122. package/lib/typescript/components/ScreenContentWrapper.web.d.ts.map +1 -1
  123. package/lib/typescript/components/ScreenFooter.d.ts +0 -4
  124. package/lib/typescript/components/ScreenFooter.d.ts.map +1 -1
  125. package/lib/typescript/components/ScreenFooter.web.d.ts +0 -1
  126. package/lib/typescript/components/ScreenFooter.web.d.ts.map +1 -1
  127. package/lib/typescript/components/ScreenStack.d.ts +1 -1
  128. package/lib/typescript/components/ScreenStack.d.ts.map +1 -1
  129. package/lib/typescript/components/ScreenStack.web.d.ts +2 -1
  130. package/lib/typescript/components/ScreenStack.web.d.ts.map +1 -1
  131. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts +1 -1
  132. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts.map +1 -1
  133. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts +1 -1
  134. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts.map +1 -1
  135. package/lib/typescript/components/SearchBar.d.ts +1 -15
  136. package/lib/typescript/components/SearchBar.d.ts.map +1 -1
  137. package/lib/typescript/components/SearchBar.web.d.ts +2 -3
  138. package/lib/typescript/components/SearchBar.web.d.ts.map +1 -1
  139. package/lib/typescript/core.d.ts +0 -1
  140. package/lib/typescript/core.d.ts.map +1 -1
  141. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts +7 -1
  142. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts.map +1 -1
  143. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +2 -2
  144. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -1
  145. package/lib/typescript/index.d.ts +8 -12
  146. package/lib/typescript/index.d.ts.map +1 -1
  147. package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts +3 -0
  148. package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts.map +1 -1
  149. package/lib/typescript/native-stack/types.d.ts +49 -1
  150. package/lib/typescript/native-stack/types.d.ts.map +1 -1
  151. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -1
  152. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts.map +1 -1
  153. package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -1
  154. package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -1
  155. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
  156. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts.map +1 -1
  157. package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
  158. package/lib/typescript/reanimated/ReanimatedScreen.d.ts.map +1 -1
  159. package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts.map +1 -1
  160. package/lib/typescript/types.d.ts +1 -1
  161. package/lib/typescript/types.d.ts.map +1 -1
  162. package/lib/typescript/utils.d.ts +26 -1
  163. package/lib/typescript/utils.d.ts.map +1 -1
  164. package/native-stack/README.md +2 -1
  165. package/native-stack/package.json +4 -4
  166. package/package.json +1 -1
  167. package/src/components/FullWindowOverlay.tsx +10 -2
  168. package/src/components/Screen.tsx +42 -25
  169. package/src/components/Screen.web.tsx +1 -1
  170. package/src/components/ScreenContainer.tsx +4 -11
  171. package/src/components/ScreenContainer.web.tsx +2 -3
  172. package/src/components/ScreenContentWrapper.tsx +2 -5
  173. package/src/components/ScreenContentWrapper.web.tsx +1 -2
  174. package/src/components/ScreenFooter.tsx +2 -8
  175. package/src/components/ScreenFooter.web.tsx +1 -2
  176. package/src/components/ScreenStack.tsx +2 -1
  177. package/src/components/ScreenStack.web.tsx +3 -1
  178. package/src/components/ScreenStackHeaderConfig.tsx +1 -1
  179. package/src/components/ScreenStackHeaderConfig.web.tsx +1 -1
  180. package/src/components/SearchBar.tsx +4 -7
  181. package/src/components/SearchBar.web.tsx +2 -3
  182. package/src/core.ts +0 -3
  183. package/src/fabric/ModalScreenNativeComponent.ts +9 -1
  184. package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +2 -1
  185. package/src/gesture-handler/GestureDetectorProvider.tsx +1 -1
  186. package/src/index.tsx +6 -32
  187. package/src/native-stack/navigators/createNativeStackNavigator.tsx +3 -0
  188. package/src/native-stack/types.tsx +50 -6
  189. package/src/native-stack/utils/getDefaultHeaderHeight.tsx +1 -1
  190. package/src/native-stack/views/FooterComponent.tsx +1 -1
  191. package/src/native-stack/views/HeaderConfig.tsx +7 -5
  192. package/src/native-stack/views/NativeStackView.tsx +5 -8
  193. package/src/reanimated/ReanimatedNativeStackScreen.tsx +2 -2
  194. package/src/reanimated/ReanimatedScreen.tsx +2 -1
  195. package/src/reanimated/ReanimatedScreenProvider.tsx +2 -1
  196. package/src/types.tsx +1 -0
  197. package/src/utils.ts +27 -5
@@ -1,4 +1,29 @@
1
1
  export declare const isSearchBarAvailableForCurrentPlatform: boolean;
2
2
  export declare function executeNativeBackPress(): boolean;
3
- export declare const isNewBackTitleImplementation = true;
3
+ /**
4
+ * Exposes information useful for downstream navigation library implementers,
5
+ * so they can keep reasonable backward compatibility, if desired.
6
+ *
7
+ * We don't mean for this object to only grow in number of fields, however at the same time
8
+ * we won't be very hasty to reduce it. Expect gradual changes.
9
+ */
10
+ export declare const compatibilityFlags: {
11
+ /**
12
+ * Because of a bug introduced in https://github.com/software-mansion/react-native-screens/pull/1646
13
+ * react-native-screens v3.21 changed how header's backTitle handles whitespace strings in https://github.com/software-mansion/react-native-screens/pull/1726
14
+ * To allow for backwards compatibility in @react-navigation/native-stack we need a way to check if this version or newer is used.
15
+ * See https://github.com/react-navigation/react-navigation/pull/11423 for more context.
16
+ */
17
+ isNewBackTitleImplementation: boolean;
18
+ /**
19
+ * With version 4.0.0 the header implementation has been changed. To allow for backward compat
20
+ * with native-stack@v6 we want to expose a way to check whether the new implementation
21
+ * is in use or not.
22
+ *
23
+ * See:
24
+ * * https://github.com/software-mansion/react-native-screens/pull/2325
25
+ * * https://github.com/react-navigation/react-navigation/pull/12125
26
+ */
27
+ usesHeaderFlexboxImplementation: boolean;
28
+ };
4
29
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sCAAsC,SAG5B,CAAC;AAExB,wBAAgB,sBAAsB,YAIrC;AAMD,eAAO,MAAM,4BAA4B,OAAO,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sCAAsC,SAG5B,CAAC;AAExB,wBAAgB,sBAAsB,YAIrC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;IAC7B;;;;;OAKG;;IAGH;;;;;;;;OAQG;;CAEJ,CAAC"}
@@ -1,6 +1,7 @@
1
1
  # Native Stack Navigator
2
2
 
3
- > **_NOTE:_** This README is dedicated for using `native-stack` with React Navigation **v5**. For using `native-stack` in React Navigation **v6** please refer to the [Native Stack Navigator part of React Navigation documentation](https://reactnavigation.org/docs/native-stack-navigator).
3
+ > [!CAUTION]
4
+ > NativeStack has been moved from react-native-screens/native-stack to @react-navigation/native since version v6. With react-native-screens v4 native stack v5 (react-native-screens/native-stack) is deprecated and marked for removal in the upcoming minor release, react-native-screens v4 will support only @react-navigation/native-stack v7.
4
5
 
5
6
  Provides a way for your app to transition between screens where each new screen is placed on top of a stack.
6
7
 
@@ -1,6 +1,6 @@
1
1
  {
2
- "main": "../lib/commonjs/native-stack/index",
3
- "module": "../lib/module/native-stack/index",
4
- "react-native": "../src/native-stack/index",
5
- "types": "../lib/typescript/native-stack/index.d.ts"
2
+ "main": "../lib/commonjs/native-stack/index",
3
+ "module": "../lib/module/native-stack/index",
4
+ "react-native": "../src/native-stack/index",
5
+ "types": "../lib/typescript/native-stack/index.d.ts"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-screens",
3
- "version": "4.0.0-beta.12",
3
+ "version": "4.0.0-beta.14",
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)",
@@ -1,5 +1,12 @@
1
1
  import React, { PropsWithChildren, ReactNode } from 'react';
2
- import { Platform, StyleProp, View, ViewStyle } from 'react-native';
2
+ import {
3
+ Platform,
4
+ StyleProp,
5
+ StyleSheet,
6
+ View,
7
+ ViewStyle,
8
+ useWindowDimensions,
9
+ } from 'react-native';
3
10
 
4
11
  // Native components
5
12
  import FullWindowOverlayNativeComponent from '../fabric/FullWindowOverlayNativeComponent';
@@ -10,13 +17,14 @@ const NativeFullWindowOverlay: React.ComponentType<
10
17
  > = FullWindowOverlayNativeComponent as any;
11
18
 
12
19
  function FullWindowOverlay(props: { children: ReactNode }) {
20
+ const { width, height } = useWindowDimensions();
13
21
  if (Platform.OS !== 'ios') {
14
22
  console.warn('Using FullWindowOverlay is only valid on iOS devices.');
15
23
  return <View {...props} />;
16
24
  }
17
25
  return (
18
26
  <NativeFullWindowOverlay
19
- style={{ position: 'absolute', width: '100%', height: '100%' }}>
27
+ style={[StyleSheet.absoluteFill, { width, height }]}>
20
28
  {props.children}
21
29
  </NativeFullWindowOverlay>
22
30
  );
@@ -5,7 +5,7 @@ import { Animated, View, Platform } from 'react-native';
5
5
 
6
6
  import TransitionProgressContext from '../TransitionProgressContext';
7
7
  import DelayedFreeze from './helpers/DelayedFreeze';
8
- import { ScreenProps } from 'react-native-screens';
8
+ import { ScreenProps } from '../types';
9
9
 
10
10
  import {
11
11
  freezeEnabled,
@@ -14,23 +14,20 @@ import {
14
14
  } from '../core';
15
15
 
16
16
  // Native components
17
- import ScreenNativeComponent from '../fabric/ScreenNativeComponent';
18
- import ModalScreenNativeComponent from '../fabric/ModalScreenNativeComponent';
17
+ import ScreenNativeComponent, {
18
+ NativeProps as ScreenNativeComponentProps,
19
+ } from '../fabric/ScreenNativeComponent';
20
+ import ModalScreenNativeComponent, {
21
+ NativeProps as ModalScreenNativeComponentProps,
22
+ } from '../fabric/ModalScreenNativeComponent';
19
23
  import { usePrevious } from './helpers/usePrevious';
20
24
 
21
- type NativeScreenProps = Omit<
22
- ScreenProps,
23
- 'sheetInitialDetentIndex' | 'sheetLargestUndimmedDetentIndex'
24
- > & {
25
- sheetInitialDetent: number;
26
- sheetLargestUndimmedDetent: number;
27
- };
28
-
29
- export const NativeScreen: React.ComponentType<NativeScreenProps> =
30
- ScreenNativeComponent as React.ComponentType<NativeScreenProps>;
31
- const AnimatedNativeScreen = Animated.createAnimatedComponent(NativeScreen);
25
+ type NativeProps = ScreenNativeComponentProps | ModalScreenNativeComponentProps;
26
+ const AnimatedNativeScreen = Animated.createAnimatedComponent(
27
+ ScreenNativeComponent,
28
+ );
32
29
  const AnimatedNativeModalScreen = Animated.createAnimatedComponent(
33
- ModalScreenNativeComponent as React.ComponentType<NativeScreenProps>,
30
+ ModalScreenNativeComponent,
34
31
  );
35
32
 
36
33
  // Incomplete type, all accessible properties available at:
@@ -196,6 +193,11 @@ export const InnerScreen = React.forwardRef<View, ScreenProps>(
196
193
  sheetInitialDetentIndex = 0,
197
194
  // Other
198
195
  stackPresentation,
196
+ // Events for override
197
+ onAppear,
198
+ onDisappear,
199
+ onWillAppear,
200
+ onWillDisappear,
199
201
  } = rest;
200
202
 
201
203
  if (enabled && isNativePlatformSupported) {
@@ -273,6 +275,22 @@ export const InnerScreen = React.forwardRef<View, ScreenProps>(
273
275
  <DelayedFreeze freeze={freezeOnBlur && activityState === 0}>
274
276
  <AnimatedScreen
275
277
  {...props}
278
+ /**
279
+ * This messy override is to conform NativeProps used by codegen and
280
+ * our Public API. To see reasoning go to this PR:
281
+ * https://github.com/software-mansion/react-native-screens/pull/2423#discussion_r1810616995
282
+ */
283
+ onAppear={onAppear as NativeProps['onAppear']}
284
+ onDisappear={onDisappear as NativeProps['onDisappear']}
285
+ onWillAppear={onWillAppear as NativeProps['onWillAppear']}
286
+ onWillDisappear={onWillDisappear as NativeProps['onWillDisappear']}
287
+ onGestureCancel={
288
+ (onGestureCancel as NativeProps['onGestureCancel']) ??
289
+ (() => {
290
+ // for internal use
291
+ })
292
+ }
293
+ //
276
294
  // Hierarchy of screens is handled on the native side and setting zIndex value causes this issue:
277
295
  // https://github.com/software-mansion/react-native-screens/issues/2345
278
296
  // With below change of zIndex, we force RN diffing mechanism to NOT include detaching and attaching mutation in one transaction.
@@ -310,12 +328,6 @@ export const InnerScreen = React.forwardRef<View, ScreenProps>(
310
328
  ],
311
329
  { useNativeDriver: true },
312
330
  )
313
- }
314
- onGestureCancel={
315
- onGestureCancel ??
316
- (() => {
317
- // for internal use
318
- })
319
331
  }>
320
332
  {!isNativeStack ? ( // see comment of this prop in types.tsx for information why it is needed
321
333
  children
@@ -361,10 +373,15 @@ export const InnerScreen = React.forwardRef<View, ScreenProps>(
361
373
  // e.g. to use `useReanimatedTransitionProgress` (see `reanimated` folder in repo)
362
374
  export const ScreenContext = React.createContext(InnerScreen);
363
375
 
364
- const Screen: React.FC<ScreenProps> = props => {
365
- const ScreenWrapper = React.useContext(ScreenContext) || InnerScreen;
376
+ const Screen = React.forwardRef<View, ScreenProps>(
377
+ (props, ref) => {
378
+ const ScreenWrapper = React.useContext(ScreenContext) || InnerScreen;
379
+
380
+ return <ScreenWrapper {...props} ref={ref} />;
381
+ }
382
+ );
383
+
384
+ Screen.displayName = 'Screen';
366
385
 
367
- return <ScreenWrapper {...props} />;
368
- };
369
386
 
370
387
  export default Screen;
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { ScreenProps } from 'react-native-screens';
3
+ import { ScreenProps } from '../types';
4
4
  import { Animated, View } from 'react-native';
5
5
  import React from 'react';
6
6
 
@@ -2,20 +2,13 @@
2
2
 
3
3
  import { Platform, View } from 'react-native';
4
4
  import React from 'react';
5
- import { ScreenContainerProps } from 'react-native-screens';
5
+ import { ScreenContainerProps } from '../types';
6
6
  import { isNativePlatformSupported, screensEnabled } from '../core';
7
7
 
8
8
  // Native components
9
9
  import ScreenContainerNativeComponent from '../fabric/ScreenContainerNativeComponent';
10
10
  import ScreenNavigationContainerNativeComponent from '../fabric/ScreenNavigationContainerNativeComponent';
11
11
 
12
- export const NativeScreenContainer: React.ComponentType<ScreenContainerProps> =
13
- Platform.OS !== 'web' ? (ScreenContainerNativeComponent as any) : View;
14
- export const NativeScreenNavigationContainer: React.ComponentType<ScreenContainerProps> =
15
- Platform.OS !== 'web'
16
- ? (ScreenNavigationContainerNativeComponent as any)
17
- : View;
18
-
19
12
  function ScreenContainer(props: ScreenContainerProps) {
20
13
  const { enabled = screensEnabled(), hasTwoStates, ...rest } = props;
21
14
 
@@ -23,11 +16,11 @@ function ScreenContainer(props: ScreenContainerProps) {
23
16
  if (hasTwoStates) {
24
17
  const ScreenNavigationContainer =
25
18
  Platform.OS === 'ios'
26
- ? NativeScreenNavigationContainer
27
- : NativeScreenContainer;
19
+ ? ScreenNavigationContainerNativeComponent
20
+ : ScreenContainerNativeComponent;
28
21
  return <ScreenNavigationContainer {...rest} />;
29
22
  }
30
- return <NativeScreenContainer {...rest} />;
23
+ return <ScreenContainerNativeComponent {...rest} />;
31
24
  }
32
25
  return <View {...rest} />;
33
26
  }
@@ -1,6 +1,5 @@
1
1
  import { View } from 'react-native';
2
2
 
3
- export const NativeScreenContainer = View;
4
- export const NativeScreenNavigationContainer = View;
3
+ const ScreenContainer = View;
5
4
 
6
- export default View;
5
+ export default ScreenContainer;
@@ -1,12 +1,9 @@
1
1
  import React from 'react';
2
- import { Platform, View, ViewProps } from 'react-native';
2
+ import { ViewProps } from 'react-native';
3
3
  import ScreenContentWrapperNativeComponent from '../fabric/ScreenContentWrapperNativeComponent';
4
4
 
5
- export const NativeScreenContentWrapper: React.ComponentType<ViewProps> =
6
- Platform.OS !== 'web' ? (ScreenContentWrapperNativeComponent as any) : View;
7
-
8
5
  function ScreenContentWrapper(props: ViewProps) {
9
- return <NativeScreenContentWrapper collapsable={false} {...props} />;
6
+ return <ScreenContentWrapperNativeComponent collapsable={false} {...props} />;
10
7
  }
11
8
 
12
9
  export default ScreenContentWrapper;
@@ -1,6 +1,5 @@
1
1
  import { View } from 'react-native';
2
2
 
3
- export const NativeScreenContentWrapper = View;
4
-
5
3
  const ScreenContentWrapper = View;
4
+
6
5
  export default ScreenContentWrapper;
@@ -1,18 +1,12 @@
1
1
  import React from 'react';
2
- import { Platform, View, ViewProps } from 'react-native';
2
+ import { ViewProps } from 'react-native';
3
3
  import ScreenFooterNativeComponent from '../fabric/ScreenFooterNativeComponent';
4
4
 
5
- /**
6
- * Unstable API
7
- */
8
- export const NativeScreenFooter: React.ComponentType<ViewProps> =
9
- Platform.OS !== 'web' ? (ScreenFooterNativeComponent as any) : View;
10
-
11
5
  /**
12
6
  * Unstable API
13
7
  */
14
8
  function ScreenFooter(props: ViewProps) {
15
- return <NativeScreenFooter {...props} />;
9
+ return <ScreenFooterNativeComponent {...props} />;
16
10
  }
17
11
 
18
12
  export default ScreenFooter;
@@ -1,6 +1,5 @@
1
1
  import { View } from 'react-native';
2
2
 
3
- export const NativeScreenFooter = View;
4
-
5
3
  const ScreenFooter = View;
4
+
6
5
  export default ScreenFooter;
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import React from 'react';
4
- import { ScreenStackProps, freezeEnabled } from 'react-native-screens';
4
+ import { ScreenStackProps } from '../types';
5
+ import { freezeEnabled } from '../core';
5
6
  import DelayedFreeze from './helpers/DelayedFreeze';
6
7
 
7
8
  // Native components
@@ -1,3 +1,5 @@
1
1
  import { View } from 'react-native';
2
2
 
3
- export default View;
3
+ const ScreenStack = View;
4
+
5
+ export default ScreenStack;
@@ -5,7 +5,7 @@ import {
5
5
  HeaderSubviewTypes,
6
6
  ScreenStackHeaderConfigProps,
7
7
  SearchBarProps,
8
- } from 'react-native-screens';
8
+ } from '../types';
9
9
  import { Image, ImageProps, StyleSheet, ViewProps } from 'react-native';
10
10
 
11
11
  // Native components
@@ -4,7 +4,7 @@ import {
4
4
  HeaderSubviewTypes,
5
5
  ScreenStackHeaderConfigProps,
6
6
  SearchBarProps,
7
- } from 'react-native-screens';
7
+ } from '../types';
8
8
 
9
9
  export const ScreenStackHeaderBackButtonImage = (
10
10
  props: ImageProps,
@@ -1,11 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import React from 'react';
4
- import {
5
- isSearchBarAvailableForCurrentPlatform,
6
- SearchBarCommands,
7
- SearchBarProps,
8
- } from 'react-native-screens';
4
+ import { SearchBarCommands, SearchBarProps } from '../types';
5
+ import { isSearchBarAvailableForCurrentPlatform } from '../utils';
9
6
  import { View } from 'react-native';
10
7
 
11
8
  // Native components
@@ -18,13 +15,13 @@ import SearchBarNativeComponent, {
18
15
  } from '../fabric/SearchBarNativeComponent';
19
16
  import { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
20
17
 
21
- export const NativeSearchBar: React.ComponentType<
18
+ const NativeSearchBar: React.ComponentType<
22
19
  SearchBarNativeProps & { ref?: React.RefObject<SearchBarCommands> }
23
20
  > &
24
21
  typeof NativeSearchBarCommands =
25
22
  SearchBarNativeComponent as unknown as React.ComponentType<SearchBarNativeProps> &
26
23
  SearchBarCommandsType;
27
- export const NativeSearchBarCommands: SearchBarCommandsType =
24
+ const NativeSearchBarCommands: SearchBarCommandsType =
28
25
  SearchBarNativeCommands as SearchBarCommandsType;
29
26
 
30
27
  type NativeSearchBarRef = React.ElementRef<typeof NativeSearchBar>;
@@ -1,6 +1,5 @@
1
1
  import { View } from 'react-native';
2
2
 
3
- export const NativeSearchBar = View;
4
- export const NativeSearchBarCommands = View;
3
+ const SearchBar = View;
5
4
 
6
- export default View;
5
+ export default SearchBar;
package/src/core.ts CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  import { Platform, UIManager } from 'react-native';
4
4
 
5
- // const that tells if the library should use new implementation, will be undefined for older versions
6
- export const shouldUseActivityState = true;
7
-
8
5
  export const isNativePlatformSupported =
9
6
  Platform.OS === 'ios' ||
10
7
  Platform.OS === 'android' ||
@@ -27,6 +27,11 @@ type HeaderHeightChangeEvent = Readonly<{
27
27
  headerHeight: Double;
28
28
  }>;
29
29
 
30
+ type SheetDetentChangedEvent = Readonly<{
31
+ index: Int32;
32
+ isStable: boolean;
33
+ }>;
34
+
30
35
  type GestureResponseDistanceType = Readonly<{
31
36
  start: Float;
32
37
  end: Float;
@@ -53,7 +58,8 @@ type StackAnimation =
53
58
  | 'slide_from_left'
54
59
  | 'slide_from_bottom'
55
60
  | 'fade_from_bottom'
56
- | 'ios';
61
+ | 'ios_from_right'
62
+ | 'ios_from_left';
57
63
 
58
64
  type SwipeDirection = 'vertical' | 'horizontal';
59
65
 
@@ -70,12 +76,14 @@ export interface NativeProps extends ViewProps {
70
76
  onTransitionProgress?: DirectEventHandler<TransitionProgressEvent>;
71
77
  onGestureCancel?: DirectEventHandler<ScreenEvent>;
72
78
  onHeaderBackButtonClicked?: DirectEventHandler<ScreenEvent>;
79
+ onSheetDetentChanged?: DirectEventHandler<SheetDetentChangedEvent>;
73
80
  sheetAllowedDetents?: number[];
74
81
  sheetLargestUndimmedDetent?: WithDefault<Int32, -1>;
75
82
  sheetGrabberVisible?: WithDefault<boolean, false>;
76
83
  sheetCornerRadius?: WithDefault<Float, -1.0>;
77
84
  sheetExpandsWhenScrolledToEdge?: WithDefault<boolean, false>;
78
85
  sheetInitialDetent?: WithDefault<Int32, 0>;
86
+ sheetElevation?: WithDefault<Int32, 24>;
79
87
  customAnimationOnSwipe?: boolean;
80
88
  fullScreenSwipeEnabled?: boolean;
81
89
  fullScreenSwipeShadowEnabled?: boolean;
@@ -18,6 +18,7 @@ type OnDetachedEvent = Readonly<{}>;
18
18
  type BackButtonDisplayMode = 'minimal' | 'default' | 'generic';
19
19
 
20
20
  type BlurEffect =
21
+ | 'none'
21
22
  | 'extraLight'
22
23
  | 'light'
23
24
  | 'dark'
@@ -68,7 +69,7 @@ export interface NativeProps extends ViewProps {
68
69
  backButtonDisplayMode?: WithDefault<BackButtonDisplayMode, 'default'>;
69
70
  hideBackButton?: boolean;
70
71
  backButtonInCustomView?: boolean;
71
- blurEffect?: WithDefault<BlurEffect, 'extraLight'>;
72
+ blurEffect?: WithDefault<BlurEffect, 'none'>;
72
73
  // TODO: implement this props on iOS
73
74
  topInsetEnabled?: boolean;
74
75
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { GHContext } from 'react-native-screens';
2
+ import { GHContext } from '../native-stack/contexts/GHContext';
3
3
  import ScreenGestureDetector from './ScreenGestureDetector';
4
4
  import type { GestureProviderProps } from '../native-stack/types';
5
5
 
package/src/index.tsx CHANGED
@@ -8,7 +8,6 @@ export {
8
8
  enableFreeze,
9
9
  screensEnabled,
10
10
  freezeEnabled,
11
- shouldUseActivityState,
12
11
  } from './core';
13
12
 
14
13
  /**
@@ -16,19 +15,10 @@ export {
16
15
  */
17
16
  export {
18
17
  default as Screen,
19
- NativeScreen,
20
18
  InnerScreen,
21
19
  ScreenContext,
22
20
  } from './components/Screen';
23
21
 
24
- export {
25
- default as ScreenContainer,
26
- NativeScreenContainer,
27
- NativeScreenNavigationContainer,
28
- } from './components/ScreenContainer';
29
-
30
- export { default as ScreenStack } from './components/ScreenStack';
31
-
32
22
  export {
33
23
  ScreenStackHeaderConfig,
34
24
  ScreenStackHeaderSubview,
@@ -39,28 +29,12 @@ export {
39
29
  ScreenStackHeaderSearchBarView,
40
30
  } from './components/ScreenStackHeaderConfig';
41
31
 
42
- export {
43
- default as SearchBar,
44
- NativeSearchBar,
45
- NativeSearchBarCommands,
46
- } from './components/SearchBar';
47
-
32
+ export { default as SearchBar } from './components/SearchBar';
33
+ export { default as ScreenContainer } from './components/ScreenContainer';
34
+ export { default as ScreenStack } from './components/ScreenStack';
48
35
  export { default as FullWindowOverlay } from './components/FullWindowOverlay';
49
-
50
- export {
51
- default as ScreenFooter,
52
- NativeScreenFooter,
53
- } from './components/ScreenFooter';
54
-
55
- export {
56
- default as ScreenContentWrapper,
57
- NativeScreenContentWrapper,
58
- } from './components/ScreenContentWrapper';
59
-
60
- /**
61
- * Modules
62
- */
63
- export { default as NativeScreensModule } from './fabric/NativeScreensModule';
36
+ export { default as ScreenFooter } from './components/ScreenFooter';
37
+ export { default as ScreenContentWrapper } from './components/ScreenContentWrapper';
64
38
 
65
39
  /**
66
40
  * Contexts
@@ -72,7 +46,7 @@ export { GHContext } from './native-stack/contexts/GHContext';
72
46
  */
73
47
  export {
74
48
  isSearchBarAvailableForCurrentPlatform,
75
- isNewBackTitleImplementation,
49
+ compatibilityFlags,
76
50
  executeNativeBackPress,
77
51
  } from './utils';
78
52
 
@@ -85,6 +85,9 @@ function NativeStackNavigator({
85
85
  );
86
86
  }
87
87
 
88
+ /**
89
+ * @deprecated NativeStack has been moved from react-native-screens/native-stack to @react-navigation/native since version v6. With react-native-screens v4 native stack v5 (react-native-screens/native-stack) is deprecated and marked for removal in the upcoming minor release, react-native-screens v4 will support only @react-navigation/native-stack v7.
90
+ */
88
91
  export default createNavigatorFactory<
89
92
  StackNavigationState<ParamListBase>,
90
93
  NativeStackNavigationOptions,