react-native-screens 3.31.1 → 3.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/README.md +21 -11
  2. package/RNScreens.podspec +11 -52
  3. package/android/CMakeLists.txt +48 -4
  4. package/android/build.gradle +16 -9
  5. package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +25 -16
  6. package/android/src/fabric/java/com/swmansion/rnscreens/NativeProxy.kt +53 -0
  7. package/android/src/main/cpp/NativeProxy.cpp +51 -0
  8. package/android/src/main/cpp/NativeProxy.h +35 -0
  9. package/android/src/main/cpp/OnLoad.cpp +8 -0
  10. package/android/src/main/cpp/jni-adapter.cpp +86 -93
  11. package/android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt +7 -2
  12. package/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +6 -1
  13. package/android/src/main/java/com/swmansion/rnscreens/FragmentBackPressOverrider.kt +2 -2
  14. package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +36 -17
  15. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +150 -40
  16. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +52 -30
  17. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainerViewManager.kt +27 -4
  18. package/android/src/main/java/com/swmansion/rnscreens/ScreenEventDispatcher.kt +10 -2
  19. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +56 -27
  20. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragmentWrapper.kt +8 -1
  21. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +50 -19
  22. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +63 -39
  23. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragmentWrapper.kt +4 -0
  24. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +88 -57
  25. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +131 -36
  26. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt +19 -4
  27. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt +16 -10
  28. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackViewManager.kt +28 -25
  29. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +177 -77
  30. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +77 -25
  31. package/android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt +31 -9
  32. package/android/src/main/java/com/swmansion/rnscreens/ScreensShadowNode.kt +3 -1
  33. package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +160 -54
  34. package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +29 -22
  35. package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +7 -2
  36. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderAttachedEvent.kt +4 -1
  37. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderBackButtonClickedEvent.kt +4 -1
  38. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderDetachedEvent.kt +4 -1
  39. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderHeightChangeEvent.kt +5 -6
  40. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenAppearEvent.kt +4 -1
  41. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDisappearEvent.kt +4 -1
  42. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenDismissedEvent.kt +8 -4
  43. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenTransitionProgressEvent.kt +7 -6
  44. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillAppearEvent.kt +4 -1
  45. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenWillDisappearEvent.kt +4 -1
  46. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarBlurEvent.kt +5 -2
  47. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarChangeTextEvent.kt +4 -3
  48. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarCloseEvent.kt +4 -1
  49. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarFocusEvent.kt +5 -2
  50. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarOpenEvent.kt +4 -1
  51. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarSearchButtonPressEvent.kt +9 -4
  52. package/android/src/main/java/com/swmansion/rnscreens/events/StackFinishTransitioningEvent.kt +4 -1
  53. package/android/src/main/java/com/swmansion/rnscreens/utils/DeviceUtils.kt +1 -5
  54. package/android/src/main/java/com/swmansion/rnscreens/utils/ScreenDummyLayoutHelper.kt +214 -0
  55. package/android/src/main/jni/CMakeLists.txt +5 -4
  56. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenContainerManagerDelegate.java +25 -0
  57. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenContainerManagerInterface.java +16 -0
  58. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerDelegate.java +6 -0
  59. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerInterface.java +2 -0
  60. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +3 -0
  61. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +1 -0
  62. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerDelegate.java +99 -0
  63. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSSearchBarManagerInterface.java +37 -0
  64. package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +10 -5
  65. package/android/src/paper/java/com/swmansion/rnscreens/NativeProxy.kt +19 -0
  66. package/android/src/paper/java/com/swmansion/rnscreens/NativeScreensModuleSpec.java +4 -0
  67. package/common/cpp/react/renderer/components/rnscreens/FrameCorrectionModes.h +51 -0
  68. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenComponentDescriptor.h +8 -9
  69. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.cpp +2 -1
  70. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.h +9 -8
  71. package/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h +147 -10
  72. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +51 -1
  73. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h +29 -7
  74. package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.cpp +22 -1
  75. package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h +30 -10
  76. package/common/cpp/react/renderer/components/rnscreens/utils/RectUtil.h +36 -0
  77. package/cpp/RNSScreenRemovalListener.cpp +25 -0
  78. package/cpp/RNSScreenRemovalListener.h +20 -0
  79. package/cpp/RNScreensTurboModule.cpp +31 -23
  80. package/cpp/RNScreensTurboModule.h +17 -20
  81. package/ios/RNSConvert.h +7 -0
  82. package/ios/RNSConvert.mm +24 -0
  83. package/ios/RNSModalScreen.mm +22 -0
  84. package/ios/RNSModule.mm +2 -3
  85. package/ios/RNSScreen.h +2 -1
  86. package/ios/RNSScreen.mm +35 -19
  87. package/ios/RNSScreenContainer.mm +1 -1
  88. package/ios/RNSScreenStack.mm +59 -54
  89. package/ios/RNSScreenStackAnimator.mm +43 -6
  90. package/ios/RNSScreenStackHeaderConfig.h +2 -0
  91. package/ios/RNSScreenStackHeaderConfig.mm +93 -28
  92. package/ios/RNSScreenStackHeaderSubview.mm +8 -0
  93. package/ios/RNSSearchBar.h +5 -5
  94. package/ios/RNSSearchBar.mm +11 -11
  95. package/ios/utils/RCTSurfaceTouchHandler+RNSUtility.h +15 -0
  96. package/ios/utils/RCTSurfaceTouchHandler+RNSUtility.mm +14 -0
  97. package/ios/utils/RCTTouchHandler+RNSUtility.h +15 -0
  98. package/ios/utils/RCTTouchHandler+RNSUtility.mm +15 -0
  99. package/ios/utils/UIView+RNSUtility.h +23 -0
  100. package/ios/utils/UIView+RNSUtility.mm +55 -0
  101. package/lib/commonjs/components/Screen.js +119 -127
  102. package/lib/commonjs/components/Screen.js.map +1 -1
  103. package/lib/commonjs/components/ScreenStack.js +8 -1
  104. package/lib/commonjs/components/ScreenStack.js.map +1 -1
  105. package/lib/commonjs/components/SearchBar.js +39 -36
  106. package/lib/commonjs/components/SearchBar.js.map +1 -1
  107. package/lib/commonjs/fabric/ModalScreenNativeComponent.js.map +1 -1
  108. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
  109. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  110. package/lib/commonjs/native-stack/views/HeaderConfig.js +2 -0
  111. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  112. package/lib/commonjs/native-stack/views/NativeStackView.js +4 -0
  113. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  114. package/lib/module/components/Screen.js +118 -126
  115. package/lib/module/components/Screen.js.map +1 -1
  116. package/lib/module/components/ScreenStack.js +8 -1
  117. package/lib/module/components/ScreenStack.js.map +1 -1
  118. package/lib/module/components/SearchBar.js +39 -36
  119. package/lib/module/components/SearchBar.js.map +1 -1
  120. package/lib/module/fabric/ModalScreenNativeComponent.js.map +1 -1
  121. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
  122. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  123. package/lib/module/native-stack/views/HeaderConfig.js +2 -0
  124. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  125. package/lib/module/native-stack/views/NativeStackView.js +4 -0
  126. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  127. package/lib/typescript/TransitionProgressContext.d.ts +1 -1
  128. package/lib/typescript/TransitionProgressContext.d.ts.map +1 -1
  129. package/lib/typescript/components/Screen.d.ts +3 -14
  130. package/lib/typescript/components/Screen.d.ts.map +1 -1
  131. package/lib/typescript/components/ScreenStack.d.ts.map +1 -1
  132. package/lib/typescript/components/SearchBar.d.ts +14 -21
  133. package/lib/typescript/components/SearchBar.d.ts.map +1 -1
  134. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts +12 -10
  135. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts.map +1 -1
  136. package/lib/typescript/fabric/ScreenNativeComponent.d.ts +12 -10
  137. package/lib/typescript/fabric/ScreenNativeComponent.d.ts.map +1 -1
  138. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +5 -3
  139. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -1
  140. package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts +1 -1
  141. package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts.map +1 -1
  142. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts +1 -1
  143. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts.map +1 -1
  144. package/lib/typescript/fabric/SearchBarNativeComponent.d.ts +9 -9
  145. package/lib/typescript/fabric/SearchBarNativeComponent.d.ts.map +1 -1
  146. package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts +1 -1
  147. package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts.map +1 -1
  148. package/lib/typescript/native-stack/types.d.ts +39 -14
  149. package/lib/typescript/native-stack/types.d.ts.map +1 -1
  150. package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts +1 -1
  151. package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts.map +1 -1
  152. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -1
  153. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts.map +1 -1
  154. package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts +1 -1
  155. package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts.map +1 -1
  156. package/lib/typescript/native-stack/views/HeaderConfig.d.ts +2 -2
  157. package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -1
  158. package/lib/typescript/native-stack/views/NativeStackView.d.ts +1 -1
  159. package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -1
  160. package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts +1 -1
  161. package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts.map +1 -1
  162. package/lib/typescript/types.d.ts +39 -13
  163. package/lib/typescript/types.d.ts.map +1 -1
  164. package/lib/typescript/useTransitionProgress.d.ts +3 -3
  165. package/native-stack/README.md +116 -98
  166. package/package.json +16 -7
  167. package/react-native.config.js +17 -15
  168. package/src/TransitionProgressContext.tsx +1 -1
  169. package/src/components/Screen.tsx +31 -37
  170. package/src/components/ScreenStack.tsx +11 -1
  171. package/src/components/ScreenStackHeaderConfig.tsx +5 -5
  172. package/src/components/ScreenStackHeaderConfig.web.tsx +6 -6
  173. package/src/components/SearchBar.tsx +77 -65
  174. package/src/core.ts +1 -1
  175. package/src/fabric/ModalScreenNativeComponent.ts +2 -0
  176. package/src/fabric/ScreenNativeComponent.ts +2 -0
  177. package/src/fabric/ScreenNavigationContainerNativeComponent.ts +1 -1
  178. package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +4 -1
  179. package/src/fabric/ScreenStackHeaderSubviewNativeComponent.ts +1 -1
  180. package/src/fabric/SearchBarNativeComponent.ts +7 -7
  181. package/src/gesture-handler/ScreenGestureDetector.tsx +5 -5
  182. package/src/gesture-handler/constraints.ts +5 -5
  183. package/src/gesture-handler/fabricUtils.ts +1 -1
  184. package/src/native-stack/contexts/GHContext.tsx +1 -1
  185. package/src/native-stack/navigators/createNativeStackNavigator.tsx +3 -3
  186. package/src/native-stack/types.tsx +29 -4
  187. package/src/native-stack/utils/getDefaultHeaderHeight.tsx +1 -1
  188. package/src/native-stack/utils/getStatusBarHeight.tsx +1 -1
  189. package/src/native-stack/utils/useAnimatedHeaderHeight.tsx +1 -1
  190. package/src/native-stack/utils/useBackPressSubscription.tsx +1 -1
  191. package/src/native-stack/utils/useHeaderHeight.tsx +1 -1
  192. package/src/native-stack/views/FontProcessor.tsx +1 -1
  193. package/src/native-stack/views/HeaderConfig.tsx +3 -1
  194. package/src/native-stack/views/NativeStackView.tsx +13 -9
  195. package/src/reanimated/ReanimatedHeaderHeightContext.tsx +1 -1
  196. package/src/reanimated/ReanimatedNativeStackScreen.tsx +5 -5
  197. package/src/reanimated/ReanimatedScreen.tsx +2 -2
  198. package/src/reanimated/ReanimatedScreenProvider.tsx +1 -1
  199. package/src/reanimated/useReanimatedHeaderHeight.tsx +1 -1
  200. package/src/reanimated/useReanimatedTransitionProgress.tsx +1 -1
  201. package/src/types.tsx +31 -5
  202. package/src/useTransitionProgress.tsx +1 -1
  203. package/windows/README.md +4 -1
@@ -41,7 +41,7 @@ function NativeStackNavigator({
41
41
  // @ts-ignore navigation.dangerouslyGetParent was removed in v6
42
42
  if (navigation?.dangerouslyGetParent === undefined) {
43
43
  console.warn(
44
- 'Looks like you are importing `native-stack` from `react-native-screens/native-stack`. Since version 6 of `react-navigation`, it should be imported from `@react-navigation/native-stack`.'
44
+ 'Looks like you are importing `native-stack` from `react-native-screens/native-stack`. Since version 6 of `react-navigation`, it should be imported from `@react-navigation/native-stack`.',
45
45
  );
46
46
  }
47
47
  }, [navigation]);
@@ -70,9 +70,9 @@ function NativeStackNavigator({
70
70
  });
71
71
  }
72
72
  });
73
- }
73
+ },
74
74
  ),
75
- [navigation, state.index, state.key]
75
+ [navigation, state.index, state.key],
76
76
  );
77
77
 
78
78
  return (
@@ -56,7 +56,7 @@ export type NativeStackNavigationEventMap = {
56
56
 
57
57
  export type NativeStackNavigationProp<
58
58
  ParamList extends ParamListBase,
59
- RouteName extends keyof ParamList = string
59
+ RouteName extends keyof ParamList = string,
60
60
  > = NavigationProp<
61
61
  ParamList,
62
62
  RouteName,
@@ -68,7 +68,7 @@ export type NativeStackNavigationProp<
68
68
 
69
69
  export type NativeStackScreenProps<
70
70
  ParamList extends ParamListBase,
71
- RouteName extends keyof ParamList = string
71
+ RouteName extends keyof ParamList = string,
72
72
  > = {
73
73
  navigation: NativeStackNavigationProp<ParamList, RouteName>;
74
74
  route: RouteProp<ParamList, RouteName>;
@@ -112,6 +112,15 @@ export type NativeStackNavigationOptions = {
112
112
  * @platform ios
113
113
  */
114
114
  disableBackButtonMenu?: boolean;
115
+ /**
116
+ * How the back button behaves by default (when not customized). Available on iOS>=14, and is used only when none of: `backTitleFontFamily`, `backTitleFontSize`, `disableBackButtonMenu` or `backTitle` is set.
117
+ * The following values are currently supported (they correspond to https://developer.apple.com/documentation/uikit/uinavigationitembackbuttondisplaymode?language=objc):
118
+ * - "default" – show given back button previous controller title, system generic or just icon based on available space
119
+ * - "generic" – show given system generic or just icon based on available space
120
+ * - "minimal" – show just an icon
121
+ * @platform ios
122
+ */
123
+ backButtonDisplayMode?: ScreenStackHeaderConfigProps['backButtonDisplayMode'];
115
124
  /**
116
125
  * Whether inactive screens should be suspended from re-rendering. Defaults to `false`.
117
126
  * Defaults to `true` when `enableFreeze()` is run at the top of the application.
@@ -125,6 +134,16 @@ export type NativeStackNavigationOptions = {
125
134
  * @platform ios
126
135
  */
127
136
  fullScreenSwipeEnabled?: boolean;
137
+ /**
138
+ * Whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
139
+ * doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
140
+ * default iOS shadow. Defaults to `false`.
141
+ *
142
+ * This does not affect the behavior of transitions that don't use gestures, enabled by `fullScreenGestureEnabled` prop.
143
+ *
144
+ * @platform ios
145
+ */
146
+ fullScreenSwipeShadowEnabled?: boolean;
128
147
  /**
129
148
  * Whether you can use gestures to dismiss this screen. Defaults to `true`.
130
149
  * Only supported on iOS.
@@ -296,6 +315,12 @@ export type NativeStackNavigationOptions = {
296
315
  * @platform android
297
316
  */
298
317
  navigationBarColor?: ColorValue;
318
+ /**
319
+ * Boolean indicating whether the content should be visible behind the navigation bar. Defaults to `false`.
320
+ *
321
+ * @platform android
322
+ */
323
+ navigationBarTranslucent?: boolean;
299
324
  /**
300
325
  * Sets the visibility of the navigation bar. Defaults to `false`.
301
326
  *
@@ -509,11 +534,11 @@ export interface MeasuredDimensions {
509
534
  export type AnimatedScreenTransition = {
510
535
  topScreenStyle: (
511
536
  event: PanGestureHandlerEventPayload,
512
- screenSize: MeasuredDimensions
537
+ screenSize: MeasuredDimensions,
513
538
  ) => Record<string, unknown>;
514
539
  belowTopScreenStyle: (
515
540
  event: PanGestureHandlerEventPayload,
516
- screenSize: MeasuredDimensions
541
+ screenSize: MeasuredDimensions,
517
542
  ) => Record<string, unknown>;
518
543
  };
519
544
 
@@ -8,7 +8,7 @@ export default function getDefaultHeaderHeight(
8
8
  layout: Layout,
9
9
  statusBarHeight: number,
10
10
  stackPresentation: StackPresentationTypes,
11
- isLargeHeader = false
11
+ isLargeHeader = false,
12
12
  ): number {
13
13
  // default header heights
14
14
  let headerHeight = Platform.OS === 'android' ? 56 : 64;
@@ -4,7 +4,7 @@ import { Platform } from 'react-native';
4
4
  export default function getStatusBarHeight(
5
5
  topInset: number,
6
6
  dimensions: Rect,
7
- isStatusBarTranslucent: boolean
7
+ isStatusBarTranslucent: boolean,
8
8
  ) {
9
9
  if (Platform.OS === 'ios') {
10
10
  // It looks like some iOS devices don't have strictly set status bar height to 44.
@@ -7,7 +7,7 @@ export default function useAnimatedHeaderHeight() {
7
7
 
8
8
  if (animatedValue === undefined) {
9
9
  throw new Error(
10
- "Couldn't find the header height. Are you inside a screen in a navigator with a header?"
10
+ "Couldn't find the header height. Are you inside a screen in a navigator with a header?",
11
11
  );
12
12
  }
13
13
 
@@ -35,7 +35,7 @@ export function useBackPressSubscription({
35
35
  subscription.current?.remove();
36
36
  subscription.current = BackHandler.addEventListener(
37
37
  'hardwareBackPress',
38
- onBackPress
38
+ onBackPress,
39
39
  );
40
40
  setIsActive(true);
41
41
  }
@@ -7,7 +7,7 @@ export default function useHeaderHeight() {
7
7
 
8
8
  if (height === undefined) {
9
9
  throw new Error(
10
- "Couldn't find the header height. Are you inside a screen in a navigator with a header?"
10
+ "Couldn't find the header height. Are you inside a screen in a navigator with a header?",
11
11
  );
12
12
  }
13
13
 
@@ -3,7 +3,7 @@
3
3
  import ReactNativeStyleAttributes from 'react-native/Libraries/Components/View/ReactNativeStyleAttributes';
4
4
 
5
5
  export function processFonts(
6
- fontFamilies: (string | undefined)[]
6
+ fontFamilies: (string | undefined)[],
7
7
  ): (string | undefined)[] {
8
8
  // @ts-ignore: React Native types are incorrect here and don't consider fontFamily a style value
9
9
  const fontFamilyProcessor = ReactNativeStyleAttributes.fontFamily?.process;
@@ -27,6 +27,7 @@ export default function HeaderConfig({
27
27
  backButtonInCustomView,
28
28
  direction,
29
29
  disableBackButtonMenu,
30
+ backButtonDisplayMode = 'default',
30
31
  headerBackTitle,
31
32
  headerBackTitleStyle = {},
32
33
  headerBackTitleVisible = true,
@@ -103,7 +104,7 @@ export default function HeaderConfig({
103
104
  warnOnce(
104
105
  isVisionOS &&
105
106
  (headerTitleStyle.color !== undefined || headerTintColor !== undefined),
106
- 'headerTitleStyle.color and headerTintColor are not supported on visionOS.'
107
+ 'headerTitleStyle.color and headerTintColor are not supported on visionOS.',
107
108
  );
108
109
 
109
110
  return (
@@ -120,6 +121,7 @@ export default function HeaderConfig({
120
121
  color={tintColor}
121
122
  direction={direction}
122
123
  disableBackButtonMenu={disableBackButtonMenu}
124
+ backButtonDisplayMode={backButtonDisplayMode}
123
125
  hidden={headerShown === false}
124
126
  hideBackButton={headerHideBackButton}
125
127
  hideShadow={headerHideShadow}
@@ -44,7 +44,7 @@ let Container = View;
44
44
 
45
45
  if (__DEV__) {
46
46
  const DebugContainer = (
47
- props: ViewProps & { stackPresentation: StackPresentationTypes }
47
+ props: ViewProps & { stackPresentation: StackPresentationTypes },
48
48
  ) => {
49
49
  const { stackPresentation, ...rest } = props;
50
50
  if (Platform.OS === 'ios' && stackPresentation !== 'push') {
@@ -87,7 +87,7 @@ const MaybeNestedStack = ({
87
87
  !isAndroid &&
88
88
  stackPresentation !== 'push' &&
89
89
  headerShownPreviousRef.current !== headerShown,
90
- `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`
90
+ `Dynamically changing 'headerShown' in modals will result in remounting the screen and losing all local state. See options for the screen '${route.name}'.`,
91
91
  );
92
92
 
93
93
  headerShownPreviousRef.current = headerShown;
@@ -119,7 +119,7 @@ const MaybeNestedStack = ({
119
119
  const statusBarHeight = getStatusBarHeight(
120
120
  topInset,
121
121
  dimensions,
122
- isStatusBarTranslucent
122
+ isStatusBarTranslucent,
123
123
  );
124
124
 
125
125
  const hasLargeHeader = options.headerLargeTitle ?? false;
@@ -128,7 +128,7 @@ const MaybeNestedStack = ({
128
128
  dimensions,
129
129
  statusBarHeight,
130
130
  stackPresentation,
131
- hasLargeHeader
131
+ hasLargeHeader,
132
132
  );
133
133
 
134
134
  if (isHeaderInModal) {
@@ -152,7 +152,7 @@ const MaybeNestedStack = ({
152
152
 
153
153
  type NavigationRoute<
154
154
  ParamList extends ParamListBase,
155
- RouteName extends keyof ParamList
155
+ RouteName extends keyof ParamList,
156
156
  > = Route<Extract<RouteName, string>, ParamList[RouteName]> & {
157
157
  state?: NavigationState | PartialState<NavigationState>;
158
158
  };
@@ -174,6 +174,7 @@ const RouteView = ({
174
174
  }) => {
175
175
  const { options, render: renderScene } = descriptors[route.key];
176
176
  const {
177
+ fullScreenSwipeShadowEnabled = false,
177
178
  gestureEnabled,
178
179
  headerShown,
179
180
  hideKeyboardOnSwipe,
@@ -185,6 +186,7 @@ const RouteView = ({
185
186
  sheetExpandsWhenScrolledToEdge = true,
186
187
  nativeBackButtonDismissalEnabled = false,
187
188
  navigationBarColor,
189
+ navigationBarTranslucent,
188
190
  navigationBarHidden,
189
191
  replaceAnimation = 'pop',
190
192
  screenOrientation,
@@ -235,7 +237,7 @@ const RouteView = ({
235
237
  const statusBarHeight = getStatusBarHeight(
236
238
  topInset,
237
239
  dimensions,
238
- isStatusBarTranslucent
240
+ isStatusBarTranslucent,
239
241
  );
240
242
 
241
243
  const hasLargeHeader = options.headerLargeTitle ?? false;
@@ -244,7 +246,7 @@ const RouteView = ({
244
246
  dimensions,
245
247
  statusBarHeight,
246
248
  stackPresentation,
247
- hasLargeHeader
249
+ hasLargeHeader,
248
250
  );
249
251
 
250
252
  const parentHeaderHeight = React.useContext(HeaderHeightContext);
@@ -262,7 +264,7 @@ const RouteView = ({
262
264
  const animatedHeaderHeight = React.useRef(
263
265
  new Animated.Value(staticHeaderHeight, {
264
266
  useNativeDriver: true,
265
- })
267
+ }),
266
268
  ).current;
267
269
 
268
270
  const Screen = React.useContext(ScreenContext);
@@ -293,12 +295,14 @@ const RouteView = ({
293
295
  customAnimationOnSwipe={customAnimationOnSwipe}
294
296
  freezeOnBlur={freezeOnBlur}
295
297
  fullScreenSwipeEnabled={fullScreenSwipeEnabled}
298
+ fullScreenSwipeShadowEnabled={fullScreenSwipeShadowEnabled}
296
299
  hideKeyboardOnSwipe={hideKeyboardOnSwipe}
297
300
  homeIndicatorHidden={homeIndicatorHidden}
298
301
  gestureEnabled={isAndroid ? false : gestureEnabled}
299
302
  gestureResponseDistance={gestureResponseDistance}
300
303
  nativeBackButtonDismissalEnabled={nativeBackButtonDismissalEnabled}
301
304
  navigationBarColor={navigationBarColor}
305
+ navigationBarTranslucent={navigationBarTranslucent}
302
306
  navigationBarHidden={navigationBarHidden}
303
307
  replaceAnimation={replaceAnimation}
304
308
  screenOrientation={screenOrientation}
@@ -439,7 +443,7 @@ function NativeStackViewInner({
439
443
  goBackGesture !== undefined
440
444
  ) {
441
445
  console.warn(
442
- 'Cannot detect GestureDetectorProvider in a screen that uses `goBackGesture`. Make sure your navigator is wrapped in GestureDetectorProvider.'
446
+ 'Cannot detect GestureDetectorProvider in a screen that uses `goBackGesture`. Make sure your navigator is wrapped in GestureDetectorProvider.',
443
447
  );
444
448
  }
445
449
  }, [ScreenGestureDetector.name, goBackGesture]);
@@ -3,5 +3,5 @@ import * as React from 'react';
3
3
  import Animated from 'react-native-reanimated';
4
4
 
5
5
  export default React.createContext<Animated.SharedValue<number> | undefined>(
6
- undefined
6
+ undefined,
7
7
  );
@@ -19,7 +19,7 @@ import getStatusBarHeight from '../native-stack/utils/getStatusBarHeight';
19
19
  import ReanimatedHeaderHeightContext from './ReanimatedHeaderHeightContext';
20
20
 
21
21
  const AnimatedScreen = Animated.createAnimatedComponent(
22
- InnerScreen as unknown as React.ComponentClass
22
+ InnerScreen as unknown as React.ComponentClass,
23
23
  );
24
24
 
25
25
  // We use prop added to global by reanimated since it seems safer than the one from RN. See:
@@ -40,7 +40,7 @@ const ReanimatedNativeStackScreen = React.forwardRef<
40
40
  const statusBarHeight = getStatusBarHeight(
41
41
  topInset,
42
42
  dimensions,
43
- isStatusBarTranslucent
43
+ isStatusBarTranslucent,
44
44
  );
45
45
 
46
46
  // Default header height, normally used in `useHeaderHeight` hook.
@@ -49,7 +49,7 @@ const ReanimatedNativeStackScreen = React.forwardRef<
49
49
  dimensions,
50
50
  statusBarHeight,
51
51
  stackPresentation,
52
- hasLargeHeader
52
+ hasLargeHeader,
53
53
  );
54
54
 
55
55
  const cachedHeaderHeight = React.useRef(defaultHeaderHeight);
@@ -79,7 +79,7 @@ const ReanimatedNativeStackScreen = React.forwardRef<
79
79
  ENABLE_FABRIC
80
80
  ? 'onTransitionProgress'
81
81
  : 'topTransitionProgress',
82
- ]
82
+ ],
83
83
  )}
84
84
  onHeaderHeightChangeReanimated={useEvent(
85
85
  (event: HeaderHeightChangeEventType) => {
@@ -96,7 +96,7 @@ const ReanimatedNativeStackScreen = React.forwardRef<
96
96
  : ENABLE_FABRIC
97
97
  ? 'onHeaderHeightChange'
98
98
  : 'topHeaderHeightChange',
99
- ]
99
+ ],
100
100
  )}
101
101
  {...rest}>
102
102
  <ReanimatedHeaderHeightContext.Provider value={headerHeight}>
@@ -5,7 +5,7 @@ import { InnerScreen, ScreenProps } from 'react-native-screens';
5
5
  import Animated from 'react-native-reanimated';
6
6
 
7
7
  const AnimatedScreen = Animated.createAnimatedComponent(
8
- InnerScreen as unknown as React.ComponentClass
8
+ InnerScreen as unknown as React.ComponentClass,
9
9
  );
10
10
 
11
11
  const ReanimatedScreen = React.forwardRef<typeof AnimatedScreen, ScreenProps>(
@@ -17,7 +17,7 @@ const ReanimatedScreen = React.forwardRef<typeof AnimatedScreen, ScreenProps>(
17
17
  {...props}
18
18
  />
19
19
  );
20
- }
20
+ },
21
21
  );
22
22
 
23
23
  ReanimatedScreen.displayName = 'ReanimatedScreen';
@@ -31,7 +31,7 @@ class ReanimatedScreenWrapper extends React.Component<ScreenProps> {
31
31
  }
32
32
 
33
33
  export default function ReanimatedScreenProvider(
34
- props: PropsWithChildren<unknown>
34
+ props: PropsWithChildren<unknown>,
35
35
  ) {
36
36
  return (
37
37
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -6,7 +6,7 @@ export default function useReanimatedHeaderHeight() {
6
6
 
7
7
  if (height === undefined) {
8
8
  throw new Error(
9
- "Couldn't find the header height using Reanimated. Are you inside a screen in a navigator with a header and your NavigationContainer is wrapped in ReanimatedScreenProvider?"
9
+ "Couldn't find the header height using Reanimated. Are you inside a screen in a navigator with a header and your NavigationContainer is wrapped in ReanimatedScreenProvider?",
10
10
  );
11
11
  }
12
12
 
@@ -6,7 +6,7 @@ export default function useReanimatedTransitionProgress() {
6
6
 
7
7
  if (progress === undefined) {
8
8
  throw new Error(
9
- "Couldn't find values for reanimated transition progress. Are you inside a screen in Native Stack?"
9
+ "Couldn't find values for reanimated transition progress. Are you inside a screen in Native Stack?",
10
10
  );
11
11
  }
12
12
 
package/src/types.tsx CHANGED
@@ -19,6 +19,7 @@ export type SearchBarCommands = {
19
19
  cancelSearch: () => void;
20
20
  };
21
21
 
22
+ export type BackButtonDisplayMode = 'default' | 'generic' | 'minimal';
22
23
  export type StackPresentationTypes =
23
24
  | 'push'
24
25
  | 'modal'
@@ -132,6 +133,16 @@ export interface ScreenProps extends ViewProps {
132
133
  * @platform ios
133
134
  */
134
135
  fullScreenSwipeEnabled?: boolean;
136
+ /**
137
+ * Whether the full screen dismiss gesture has shadow under view during transition. The gesture uses custom transition and thus
138
+ * doesn't have a shadow by default. When enabled, a custom shadow view is added during the transition which tries to mimic the
139
+ * default iOS shadow. Defaults to `false`.
140
+ *
141
+ * This does not affect the behavior of transitions that don't use gestures, enabled by `fullScreenGestureEnabled` prop.
142
+ *
143
+ * @platform ios
144
+ */
145
+ fullScreenSwipeShadowEnabled?: boolean;
135
146
  /**
136
147
  * Whether you can use gestures to dismiss this screen. Defaults to `true`.
137
148
  *
@@ -170,6 +181,12 @@ export interface ScreenProps extends ViewProps {
170
181
  * @platform android
171
182
  */
172
183
  navigationBarColor?: ColorValue;
184
+ /**
185
+ * Boolean indicating whether the content should be visible behind the navigation bar. Defaults to `false`.
186
+ *
187
+ * @platform android
188
+ */
189
+ navigationBarTranslucent?: boolean;
173
190
  /**
174
191
  * Sets the visibility of the navigation bar. Defaults to `false`.
175
192
  *
@@ -194,7 +211,7 @@ export interface ScreenProps extends ViewProps {
194
211
  * A callback that gets called when the header height has changed.
195
212
  */
196
213
  onHeaderHeightChange?: (
197
- e: NativeSyntheticEvent<HeaderHeightChangeEventType>
214
+ e: NativeSyntheticEvent<HeaderHeightChangeEventType>,
198
215
  ) => void;
199
216
  /**
200
217
  * A callback that gets called after swipe back is canceled.
@@ -212,13 +229,13 @@ export interface ScreenProps extends ViewProps {
212
229
  * @platform ios
213
230
  */
214
231
  onNativeDismissCancelled?: (
215
- e: NativeSyntheticEvent<{ dismissCount: number }>
232
+ e: NativeSyntheticEvent<{ dismissCount: number }>,
216
233
  ) => void;
217
234
  /**
218
235
  * An internal callback called every frame during the transition of screens of `native-stack`, used to feed transition context.
219
236
  */
220
237
  onTransitionProgress?: (
221
- e: NativeSyntheticEvent<TransitionProgressEventType>
238
+ e: NativeSyntheticEvent<TransitionProgressEventType>,
222
239
  ) => void;
223
240
  /**
224
241
  * A callback that gets called when the current screen will appear. This is called as soon as the transition begins.
@@ -396,7 +413,7 @@ export interface ScreenContainerProps extends ViewProps {
396
413
 
397
414
  export interface GestureDetectorBridge {
398
415
  stackUseEffectCallback: (
399
- stackRef: React.MutableRefObject<React.Ref<NativeStackNavigatorProps>>
416
+ stackRef: React.MutableRefObject<React.Ref<NativeStackNavigatorProps>>,
400
417
  ) => void;
401
418
  }
402
419
 
@@ -461,6 +478,15 @@ export interface ScreenStackHeaderConfigProps extends ViewProps {
461
478
  * @platform ios
462
479
  */
463
480
  disableBackButtonMenu?: boolean;
481
+ /**
482
+ * How the back button behaves by default (when not customized). Available on iOS>=14, and is used only when none of: `backTitleFontFamily`, `backTitleFontSize`, `disableBackButtonMenu` or `backTitle` is set.
483
+ * The following values are currently supported (they correspond to https://developer.apple.com/documentation/uikit/uinavigationitembackbuttondisplaymode?language=objc):
484
+ * - "default" – show given back button previous controller title, system generic or just icon based on available space
485
+ * - "generic" – show given system generic or just icon based on available space
486
+ * - "minimal" – show just an icon
487
+ * @platform ios
488
+ */
489
+ backButtonDisplayMode?: BackButtonDisplayMode;
464
490
  /**
465
491
  * When set to true the header will be hidden while the parent Screen is on the top of the stack. The default value is false.
466
492
  */
@@ -659,7 +685,7 @@ export interface SearchBarProps {
659
685
  * A callback that gets called when the search button is pressed. It receives the current text value of the search bar.
660
686
  */
661
687
  onSearchButtonPress?: (
662
- e: NativeSyntheticEvent<TextInputFocusEventData>
688
+ e: NativeSyntheticEvent<TextInputFocusEventData>,
663
689
  ) => void;
664
690
  /**
665
691
  * Text displayed when search field is empty
@@ -7,7 +7,7 @@ export default function useTransitionProgress() {
7
7
 
8
8
  if (progress === undefined) {
9
9
  throw new Error(
10
- "Couldn't find values for transition progress. Are you inside a screen in Native Stack?"
10
+ "Couldn't find values for transition progress. Are you inside a screen in Native Stack?",
11
11
  );
12
12
  }
13
13
 
package/windows/README.md CHANGED
@@ -1,12 +1,15 @@
1
1
  # react-native-screens Windows Implementation
2
2
 
3
3
  ## Module Installation
4
+
4
5
  You can either use autolinking on react-native-windows 0.63 and later or manually link the module on earlier releases.
5
6
 
6
7
  ## Automatic install with autolinking on RNW >= 0.63
8
+
7
9
  RNScreens supports autolinking. Just call: `npm i react-native-screens --save`
8
10
 
9
11
  ## Manual installation on RNW >= 0.62
12
+
10
13
  1. `npm install react-native-screens --save`
11
14
  2. Open your solution in Visual Studio 2019 (eg. `windows\yourapp.sln`)
12
15
  3. Right-click Solution icon in Solution Explorer > Add > Existing Project...
@@ -22,4 +25,4 @@ If you want to contribute to this module Windows implementation, first you must
22
25
 
23
26
  You must temporarily install the `react-native-windows` package. Versions of `react-native-windows` and `react-native` must match, e.g. if the module uses `react-native@0.62`, install `npm i react-native-windows@^0.62 --dev`.
24
27
 
25
- Now, you will be able to open corresponding `RNScreens...sln` file, e.g. `RNScreens62.sln` for `react-native-windows@0.62`.
28
+ Now, you will be able to open corresponding `RNScreens...sln` file, e.g. `RNScreens62.sln` for `react-native-windows@0.62`.