react-native-screens 4.0.0-beta.0 → 4.0.0-beta.10

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 (216) hide show
  1. package/README.md +1 -1
  2. package/android/build.gradle +26 -6
  3. package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +61 -0
  4. package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +4 -3
  5. package/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +54 -1
  6. package/android/src/main/java/com/swmansion/rnscreens/InsetsObserverProxy.kt +2 -4
  7. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +59 -36
  8. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +26 -5
  9. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +37 -17
  10. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +1 -2
  11. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigShadowNode.kt +25 -0
  12. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +18 -0
  13. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +8 -2
  14. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +2 -1
  15. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderHeightChangeEvent.kt +3 -3
  16. package/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt +17 -0
  17. package/android/src/main/java/com/swmansion/rnscreens/utils/PaddingBundle.kt +8 -0
  18. package/android/src/main/jni/rnscreens.h +2 -0
  19. package/android/src/main/res/base/anim/rns_ios_from_left_background_close.xml +5 -0
  20. package/android/src/main/res/base/anim/{rns_slide_out_to_left_ios.xml → rns_ios_from_left_background_open.xml} +1 -1
  21. package/android/src/main/res/base/anim/rns_ios_from_left_foreground_close.xml +6 -0
  22. package/android/src/main/res/base/anim/rns_ios_from_left_foreground_open.xml +6 -0
  23. package/android/src/main/res/base/anim/rns_ios_from_right_background_open.xml +5 -0
  24. package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledHeaderConfigViewGroup.kt +39 -0
  25. package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +1 -1
  26. package/common/cpp/react/renderer/components/rnscreens/RNSScreenComponentDescriptor.h +5 -99
  27. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +101 -0
  28. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h +2 -0
  29. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigComponentDescriptor.h +44 -0
  30. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.cpp +8 -0
  31. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigShadowNode.h +32 -0
  32. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.cpp +23 -0
  33. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderConfigState.h +50 -0
  34. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewComponentDescriptor.h +27 -0
  35. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.cpp +8 -0
  36. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewShadowNode.h +32 -0
  37. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.cpp +15 -0
  38. package/common/cpp/react/renderer/components/rnscreens/RNSScreenStackHeaderSubviewState.h +40 -0
  39. package/ios/RNSConvert.mm +4 -2
  40. package/ios/RNSFullWindowOverlay.mm +6 -0
  41. package/ios/RNSModalScreen.mm +7 -0
  42. package/ios/RNSScreen.h +9 -0
  43. package/ios/RNSScreen.mm +46 -8
  44. package/ios/RNSScreenContainer.mm +6 -0
  45. package/ios/RNSScreenContentWrapper.mm +6 -0
  46. package/ios/RNSScreenFooter.mm +6 -0
  47. package/ios/RNSScreenNavigationContainer.mm +7 -0
  48. package/ios/RNSScreenStack.mm +86 -8
  49. package/ios/RNSScreenStackHeaderConfig.h +63 -0
  50. package/ios/RNSScreenStackHeaderConfig.mm +133 -6
  51. package/ios/RNSScreenStackHeaderSubview.mm +32 -3
  52. package/ios/RNSSearchBar.mm +7 -0
  53. package/ios/utils/UINavigationBar+RNSUtility.h +37 -0
  54. package/ios/utils/UINavigationBar+RNSUtility.mm +44 -0
  55. package/ios/utils/UIView+RNSUtility.mm +0 -1
  56. package/lib/commonjs/TransitionProgressContext.js +1 -0
  57. package/lib/commonjs/TransitionProgressContext.js.map +1 -1
  58. package/lib/commonjs/components/Screen.js +111 -5
  59. package/lib/commonjs/components/Screen.js.map +1 -1
  60. package/lib/commonjs/components/Screen.web.js +2 -0
  61. package/lib/commonjs/components/Screen.web.js.map +1 -1
  62. package/lib/commonjs/components/ScreenContainer.js +1 -0
  63. package/lib/commonjs/components/ScreenContainer.js.map +1 -1
  64. package/lib/commonjs/components/ScreenContentWrapper.web.js +11 -0
  65. package/lib/commonjs/components/ScreenContentWrapper.web.js.map +1 -0
  66. package/lib/commonjs/components/ScreenFooter.web.js +11 -0
  67. package/lib/commonjs/components/ScreenFooter.web.js.map +1 -0
  68. package/lib/commonjs/components/ScreenStack.js +1 -0
  69. package/lib/commonjs/components/ScreenStack.js.map +1 -1
  70. package/lib/commonjs/components/ScreenStackHeaderConfig.js +54 -17
  71. package/lib/commonjs/components/ScreenStackHeaderConfig.js.map +1 -1
  72. package/lib/commonjs/components/SearchBar.js +1 -0
  73. package/lib/commonjs/components/SearchBar.js.map +1 -1
  74. package/lib/commonjs/components/helpers/usePrevious.js +15 -0
  75. package/lib/commonjs/components/helpers/usePrevious.js.map +1 -0
  76. package/lib/commonjs/core.js +1 -0
  77. package/lib/commonjs/core.js.map +1 -1
  78. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +1 -0
  79. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
  80. package/lib/commonjs/fabric/ModalScreenNativeComponent.js +1 -0
  81. package/lib/commonjs/fabric/ModalScreenNativeComponent.js.map +1 -1
  82. package/lib/commonjs/fabric/NativeScreensModule.js +2 -1
  83. package/lib/commonjs/fabric/NativeScreensModule.js.map +1 -1
  84. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +1 -0
  85. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js.map +1 -1
  86. package/lib/commonjs/fabric/ScreenNativeComponent.js +1 -0
  87. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
  88. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +1 -0
  89. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
  90. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js +4 -1
  91. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  92. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js +4 -1
  93. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
  94. package/lib/commonjs/fabric/ScreenStackNativeComponent.js +1 -0
  95. package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
  96. package/lib/commonjs/fabric/SearchBarNativeComponent.js +2 -2
  97. package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -1
  98. package/lib/commonjs/native-stack/contexts/GHContext.js +1 -0
  99. package/lib/commonjs/native-stack/contexts/GHContext.js.map +1 -1
  100. package/lib/commonjs/native-stack/views/NativeStackView.js +7 -13
  101. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  102. package/lib/module/TransitionProgressContext.js +2 -0
  103. package/lib/module/TransitionProgressContext.js.map +1 -1
  104. package/lib/module/components/Screen.js +112 -5
  105. package/lib/module/components/Screen.js.map +1 -1
  106. package/lib/module/components/Screen.web.js +3 -0
  107. package/lib/module/components/Screen.web.js.map +1 -1
  108. package/lib/module/components/ScreenContainer.js +2 -0
  109. package/lib/module/components/ScreenContainer.js.map +1 -1
  110. package/lib/module/components/ScreenContentWrapper.web.js +5 -0
  111. package/lib/module/components/ScreenContentWrapper.web.js.map +1 -0
  112. package/lib/module/components/ScreenFooter.web.js +5 -0
  113. package/lib/module/components/ScreenFooter.web.js.map +1 -0
  114. package/lib/module/components/ScreenStack.js +2 -0
  115. package/lib/module/components/ScreenStack.js.map +1 -1
  116. package/lib/module/components/ScreenStackHeaderConfig.js +52 -16
  117. package/lib/module/components/ScreenStackHeaderConfig.js.map +1 -1
  118. package/lib/module/components/SearchBar.js +2 -0
  119. package/lib/module/components/SearchBar.js.map +1 -1
  120. package/lib/module/components/helpers/usePrevious.js +9 -0
  121. package/lib/module/components/helpers/usePrevious.js.map +1 -0
  122. package/lib/module/core.js +2 -0
  123. package/lib/module/core.js.map +1 -1
  124. package/lib/module/fabric/FullWindowOverlayNativeComponent.js +2 -0
  125. package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
  126. package/lib/module/fabric/ModalScreenNativeComponent.js +2 -0
  127. package/lib/module/fabric/ModalScreenNativeComponent.js.map +1 -1
  128. package/lib/module/fabric/NativeScreensModule.js +2 -1
  129. package/lib/module/fabric/NativeScreensModule.js.map +1 -1
  130. package/lib/module/fabric/ScreenContainerNativeComponent.js +2 -0
  131. package/lib/module/fabric/ScreenContainerNativeComponent.js.map +1 -1
  132. package/lib/module/fabric/ScreenNativeComponent.js +2 -0
  133. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
  134. package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js +2 -0
  135. package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
  136. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js +5 -1
  137. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  138. package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js +5 -1
  139. package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
  140. package/lib/module/fabric/ScreenStackNativeComponent.js +2 -0
  141. package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
  142. package/lib/module/fabric/SearchBarNativeComponent.js +2 -0
  143. package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -1
  144. package/lib/module/index.js +6 -6
  145. package/lib/module/native-stack/contexts/GHContext.js +2 -0
  146. package/lib/module/native-stack/contexts/GHContext.js.map +1 -1
  147. package/lib/module/native-stack/views/NativeStackView.js +7 -13
  148. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  149. package/lib/typescript/TransitionProgressContext.d.ts.map +1 -1
  150. package/lib/typescript/components/Screen.d.ts +5 -1
  151. package/lib/typescript/components/Screen.d.ts.map +1 -1
  152. package/lib/typescript/components/Screen.web.d.ts.map +1 -1
  153. package/lib/typescript/components/ScreenContainer.d.ts.map +1 -1
  154. package/lib/typescript/components/ScreenContentWrapper.web.d.ts +5 -0
  155. package/lib/typescript/components/ScreenContentWrapper.web.d.ts.map +1 -0
  156. package/lib/typescript/components/ScreenFooter.web.d.ts +5 -0
  157. package/lib/typescript/components/ScreenFooter.web.d.ts.map +1 -0
  158. package/lib/typescript/components/ScreenStack.d.ts.map +1 -1
  159. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts +1 -1
  160. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts.map +1 -1
  161. package/lib/typescript/components/SearchBar.d.ts.map +1 -1
  162. package/lib/typescript/components/helpers/usePrevious.d.ts +2 -0
  163. package/lib/typescript/components/helpers/usePrevious.d.ts.map +1 -0
  164. package/lib/typescript/core.d.ts.map +1 -1
  165. package/lib/typescript/fabric/FullWindowOverlayNativeComponent.d.ts.map +1 -1
  166. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts +1 -0
  167. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts.map +1 -1
  168. package/lib/typescript/fabric/NativeScreensModule.d.ts.map +1 -1
  169. package/lib/typescript/fabric/ScreenContainerNativeComponent.d.ts.map +1 -1
  170. package/lib/typescript/fabric/ScreenNativeComponent.d.ts +1 -1
  171. package/lib/typescript/fabric/ScreenNativeComponent.d.ts.map +1 -1
  172. package/lib/typescript/fabric/ScreenNavigationContainerNativeComponent.d.ts.map +1 -1
  173. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -1
  174. package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts.map +1 -1
  175. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts.map +1 -1
  176. package/lib/typescript/fabric/SearchBarNativeComponent.d.ts.map +1 -1
  177. package/lib/typescript/index.d.ts +18 -0
  178. package/lib/typescript/index.d.ts.map +1 -1
  179. package/lib/typescript/native-stack/contexts/GHContext.d.ts.map +1 -1
  180. package/lib/typescript/native-stack/types.d.ts +14 -5
  181. package/lib/typescript/native-stack/types.d.ts.map +1 -1
  182. package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -1
  183. package/lib/typescript/types.d.ts +56 -11
  184. package/lib/typescript/types.d.ts.map +1 -1
  185. package/native-stack/README.md +30 -5
  186. package/package.json +1 -1
  187. package/src/TransitionProgressContext.tsx +2 -0
  188. package/src/components/Screen.tsx +161 -8
  189. package/src/components/Screen.web.tsx +3 -0
  190. package/src/components/ScreenContainer.tsx +2 -0
  191. package/src/components/ScreenContentWrapper.web.tsx +6 -0
  192. package/src/components/ScreenFooter.web.tsx +6 -0
  193. package/src/components/ScreenStack.tsx +2 -0
  194. package/src/components/ScreenStackHeaderConfig.tsx +61 -26
  195. package/src/components/SearchBar.tsx +2 -0
  196. package/src/components/helpers/usePrevious.tsx +11 -0
  197. package/src/core.ts +2 -0
  198. package/src/fabric/FullWindowOverlayNativeComponent.ts +2 -0
  199. package/src/fabric/ModalScreenNativeComponent.ts +3 -0
  200. package/src/fabric/NativeScreensModule.ts +2 -0
  201. package/src/fabric/ScreenContainerNativeComponent.ts +2 -0
  202. package/src/fabric/ScreenNativeComponent.ts +4 -1
  203. package/src/fabric/ScreenNavigationContainerNativeComponent.ts +2 -0
  204. package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +5 -1
  205. package/src/fabric/ScreenStackHeaderSubviewNativeComponent.ts +5 -1
  206. package/src/fabric/ScreenStackNativeComponent.ts +2 -0
  207. package/src/fabric/SearchBarNativeComponent.ts +2 -0
  208. package/src/index.tsx +6 -6
  209. package/src/native-stack/contexts/GHContext.tsx +2 -0
  210. package/src/native-stack/types.tsx +14 -5
  211. package/src/native-stack/views/NativeStackView.tsx +11 -16
  212. package/src/types.tsx +63 -11
  213. package/windows/RNScreens/Screen.h +2 -1
  214. /package/android/src/main/res/base/anim/{rns_slide_in_from_left_ios.xml → rns_ios_from_right_background_close.xml} +0 -0
  215. /package/android/src/main/res/base/anim/{rns_slide_out_to_right_ios.xml → rns_ios_from_right_foreground_close.xml} +0 -0
  216. /package/android/src/main/res/base/anim/{rns_slide_in_from_right_ios.xml → rns_ios_from_right_foreground_open.xml} +0 -0
@@ -0,0 +1,6 @@
1
+ import { View } from 'react-native';
2
+
3
+ export const NativeScreenContentWrapper = View;
4
+
5
+ const ScreenContentWrapper = View;
6
+ export default ScreenContentWrapper;
@@ -0,0 +1,6 @@
1
+ import { View } from 'react-native';
2
+
3
+ export const NativeScreenFooter = View;
4
+
5
+ const ScreenFooter = View;
6
+ export default ScreenFooter;
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import React from 'react';
2
4
  import { ScreenStackProps, freezeEnabled } from 'react-native-screens';
3
5
  import DelayedFreeze from './helpers/DelayedFreeze';
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import React from 'react';
2
4
  import {
3
5
  HeaderSubviewTypes,
@@ -10,12 +12,22 @@ import { Image, ImageProps, StyleSheet, ViewProps } from 'react-native';
10
12
  import ScreenStackHeaderConfigNativeComponent from '../fabric/ScreenStackHeaderConfigNativeComponent';
11
13
  import ScreenStackHeaderSubviewNativeComponent from '../fabric/ScreenStackHeaderSubviewNativeComponent';
12
14
 
13
- export const ScreenStackHeaderConfig: React.ComponentType<ScreenStackHeaderConfigProps> =
14
- ScreenStackHeaderConfigNativeComponent as any;
15
15
  export const ScreenStackHeaderSubview: React.ComponentType<
16
16
  React.PropsWithChildren<ViewProps & { type?: HeaderSubviewTypes }>
17
17
  > = ScreenStackHeaderSubviewNativeComponent as any;
18
18
 
19
+ export function ScreenStackHeaderConfig(
20
+ props: ScreenStackHeaderConfigProps,
21
+ ): React.JSX.Element {
22
+ return (
23
+ <ScreenStackHeaderConfigNativeComponent
24
+ {...props}
25
+ style={styles.headerConfig}
26
+ pointerEvents="box-none"
27
+ />
28
+ );
29
+ }
30
+
19
31
  export const ScreenStackHeaderBackButtonImage = (
20
32
  props: ImageProps,
21
33
  ): JSX.Element => (
@@ -26,33 +38,45 @@ export const ScreenStackHeaderBackButtonImage = (
26
38
 
27
39
  export const ScreenStackHeaderRightView = (
28
40
  props: React.PropsWithChildren<ViewProps>,
29
- ): JSX.Element => (
30
- <ScreenStackHeaderSubview
31
- {...props}
32
- type="right"
33
- style={styles.headerSubview}
34
- />
35
- );
41
+ ): JSX.Element => {
42
+ const { style, ...rest } = props;
43
+
44
+ return (
45
+ <ScreenStackHeaderSubview
46
+ {...rest}
47
+ type="right"
48
+ style={[styles.headerSubview, style]}
49
+ />
50
+ );
51
+ };
36
52
 
37
53
  export const ScreenStackHeaderLeftView = (
38
54
  props: React.PropsWithChildren<ViewProps>,
39
- ): JSX.Element => (
40
- <ScreenStackHeaderSubview
41
- {...props}
42
- type="left"
43
- style={styles.headerSubview}
44
- />
45
- );
55
+ ): JSX.Element => {
56
+ const { style, ...rest } = props;
57
+
58
+ return (
59
+ <ScreenStackHeaderSubview
60
+ {...rest}
61
+ type="left"
62
+ style={[styles.headerSubview, style]}
63
+ />
64
+ );
65
+ };
46
66
 
47
67
  export const ScreenStackHeaderCenterView = (
48
68
  props: React.PropsWithChildren<ViewProps>,
49
- ): JSX.Element => (
50
- <ScreenStackHeaderSubview
51
- {...props}
52
- type="center"
53
- style={styles.headerSubview}
54
- />
55
- );
69
+ ): JSX.Element => {
70
+ const { style, ...rest } = props;
71
+
72
+ return (
73
+ <ScreenStackHeaderSubview
74
+ {...rest}
75
+ type="center"
76
+ style={[styles.headerSubviewCenter, style]}
77
+ />
78
+ );
79
+ };
56
80
 
57
81
  export const ScreenStackHeaderSearchBarView = (
58
82
  props: React.PropsWithChildren<SearchBarProps>,
@@ -66,11 +90,22 @@ export const ScreenStackHeaderSearchBarView = (
66
90
 
67
91
  const styles = StyleSheet.create({
68
92
  headerSubview: {
69
- position: 'absolute',
70
- top: 0,
71
- right: 0,
72
93
  flexDirection: 'row',
73
94
  alignItems: 'center',
74
95
  justifyContent: 'center',
75
96
  },
97
+ headerSubviewCenter: {
98
+ flexDirection: 'row',
99
+ alignItems: 'center',
100
+ justifyContent: 'center',
101
+ flexShrink: 1,
102
+ },
103
+ headerConfig: {
104
+ position: 'absolute',
105
+ top: '-100%',
106
+ width: '100%',
107
+ flexDirection: 'row',
108
+ justifyContent: 'space-between',
109
+ alignItems: 'center',
110
+ },
76
111
  });
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import React from 'react';
2
4
  import {
3
5
  isSearchBarAvailableForCurrentPlatform,
@@ -0,0 +1,11 @@
1
+ import { useEffect, useRef } from 'react';
2
+
3
+ export function usePrevious<T>(state: T): T | undefined {
4
+ const ref = useRef<T>();
5
+
6
+ useEffect(() => {
7
+ ref.current = state;
8
+ });
9
+
10
+ return ref.current;
11
+ }
package/src/core.ts CHANGED
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { Platform, UIManager } from 'react-native';
2
4
 
3
5
  // const that tells if the library should use new implementation, will be undefined for older versions
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
4
  import type { ViewProps } from 'react-native';
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
4
  import type { ViewProps, ColorValue } from 'react-native';
3
5
  import type {
@@ -73,6 +75,7 @@ export interface NativeProps extends ViewProps {
73
75
  sheetGrabberVisible?: WithDefault<boolean, false>;
74
76
  sheetCornerRadius?: WithDefault<Float, -1.0>;
75
77
  sheetExpandsWhenScrolledToEdge?: WithDefault<boolean, false>;
78
+ sheetInitialDetent?: WithDefault<Int32, 0>;
76
79
  customAnimationOnSwipe?: boolean;
77
80
  fullScreenSwipeEnabled?: boolean;
78
81
  fullScreenSwipeShadowEnabled?: boolean;
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  /* eslint-disable @typescript-eslint/ban-types */
2
4
  import type { TurboModule } from 'react-native';
3
5
  import { TurboModuleRegistry } from 'react-native';
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
4
  import type { ViewProps } from 'react-native';
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
4
  import type { ViewProps, ColorValue } from 'react-native';
3
5
  import type {
@@ -56,7 +58,8 @@ type StackAnimation =
56
58
  | 'slide_from_left'
57
59
  | 'slide_from_bottom'
58
60
  | 'fade_from_bottom'
59
- | 'ios';
61
+ | 'ios_from_right'
62
+ | 'ios_from_left';
60
63
 
61
64
  type SwipeDirection = 'vertical' | 'horizontal';
62
65
 
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
4
  import type { ViewProps } from 'react-native';
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
4
  import type { ViewProps, ColorValue } from 'react-native';
3
5
  import type {
@@ -73,5 +75,7 @@ export interface NativeProps extends ViewProps {
73
75
 
74
76
  export default codegenNativeComponent<NativeProps>(
75
77
  'RNSScreenStackHeaderConfig',
76
- {},
78
+ {
79
+ interfaceOnly: true,
80
+ },
77
81
  );
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
4
  import type { ViewProps } from 'react-native';
3
5
  import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
@@ -16,5 +18,7 @@ export interface NativeProps extends ViewProps {
16
18
 
17
19
  export default codegenNativeComponent<NativeProps>(
18
20
  'RNSScreenStackHeaderSubview',
19
- {},
21
+ {
22
+ interfaceOnly: true,
23
+ },
20
24
  );
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
4
  import type { ViewProps } from 'react-native';
3
5
  import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  /* eslint-disable */
2
4
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
5
  import type { ViewProps, ColorValue, HostComponent } from 'react-native';
package/src/index.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from './types';
2
2
 
3
- /*
3
+ /**
4
4
  * Core
5
5
  */
6
6
  export {
@@ -11,7 +11,7 @@ export {
11
11
  shouldUseActivityState,
12
12
  } from './core';
13
13
 
14
- /*
14
+ /**
15
15
  * RNS Components
16
16
  */
17
17
  export {
@@ -57,17 +57,17 @@ export {
57
57
  NativeScreenContentWrapper,
58
58
  } from './components/ScreenContentWrapper';
59
59
 
60
- /*
60
+ /**
61
61
  * Modules
62
62
  */
63
63
  export { default as NativeScreensModule } from './fabric/NativeScreensModule';
64
64
 
65
- /*
65
+ /**
66
66
  * Contexts
67
67
  */
68
68
  export { GHContext } from './native-stack/contexts/GHContext';
69
69
 
70
- /*
70
+ /**
71
71
  * Utils
72
72
  */
73
73
  export {
@@ -76,7 +76,7 @@ export {
76
76
  executeNativeBackPress,
77
77
  } from './utils';
78
78
 
79
- /*
79
+ /**
80
80
  * Hooks
81
81
  */
82
82
  export { default as useTransitionProgress } from './useTransitionProgress';
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import React, { PropsWithChildren } from 'react';
2
4
  import { GestureProviderProps } from '../types';
3
5
 
@@ -418,7 +418,7 @@ export type NativeStackNavigationOptions = {
418
418
  *
419
419
  * Defaults to `0` - which represents first detent in the detents array.
420
420
  */
421
- sheetInitialDetent?: ScreenProps['sheetInitialDetent'];
421
+ sheetInitialDetentIndex?: ScreenProps['sheetInitialDetentIndex'];
422
422
  /**
423
423
  * The largest sheet detent for which a view underneath won't be dimmed.
424
424
  * Works only when `stackPresentation` is set to `formSheet`.
@@ -426,9 +426,17 @@ export type NativeStackNavigationOptions = {
426
426
  * This prop can be set to an number, which indicates index of detent in `sheetAllowedDetents` array for which
427
427
  * there won't be a dimming view beneath the sheet.
428
428
  *
429
- * Defaults to `-1`, indicating that the dimming view should be always present.
429
+ * Additionaly there are following options available:
430
+ *
431
+ * * `none` - there will be dimming view for all detents levels,
432
+ * * `largest` - there won't be a dimming view for any detent level.
433
+ *
434
+ * There also legacy & **deprecated** prop values available: `medium`, `large` (don't confuse with `largest`), `all`, which work in tandem with
435
+ * corresponding legacy prop values for `sheetAllowedDetents` prop.
436
+ *
437
+ * Defaults to `none`, indicating that the dimming view should be always present.
430
438
  */
431
- sheetLargestUndimmedDetent?: ScreenProps['sheetLargestUndimmedDetent'];
439
+ sheetLargestUndimmedDetentIndex?: ScreenProps['sheetLargestUndimmedDetentIndex'];
432
440
  /**
433
441
  * How the screen should appear/disappear when pushed or popped at the top of the stack.
434
442
  * The following values are currently supported:
@@ -440,7 +448,8 @@ export type NativeStackNavigationOptions = {
440
448
  * - "slide_from_bottom" – performs a slide from bottom animation
441
449
  * - "slide_from_right" - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
442
450
  * - "slide_from_left" - slide in the new screen from left to right
443
- * - "ios" - iOS like slide in animation (Android only, resolves to default transition on iOS)
451
+ * - "ios_from_right" - iOS like slide in animation. pushes in the new screen from right to left (Android only, resolves to default transition on iOS)
452
+ * - "ios_from_left" - iOS like slide in animation. pushes in the new screen from left to right (Android only, resolves to default transition on iOS)
444
453
  * - "none" – the screen appears/dissapears without an animation
445
454
  */
446
455
  stackAnimation?: ScreenProps['stackAnimation'];
@@ -515,7 +524,7 @@ export type NativeStackNavigationOptions = {
515
524
  *
516
525
  * @platform android
517
526
  */
518
- unstable_footerComponent?: React.ReactNode;
527
+ unstable_sheetFooter?: () => React.ReactNode;
519
528
  };
520
529
 
521
530
  export type NativeStackNavigatorProps =
@@ -195,12 +195,12 @@ const RouteView = ({
195
195
  headerShown,
196
196
  hideKeyboardOnSwipe,
197
197
  homeIndicatorHidden,
198
- sheetLargestUndimmedDetent = -1,
198
+ sheetLargestUndimmedDetentIndex = 'none',
199
199
  sheetGrabberVisible = false,
200
200
  sheetCornerRadius = -1.0,
201
201
  sheetElevation = 24,
202
202
  sheetExpandsWhenScrolledToEdge = true,
203
- sheetInitialDetent = 0,
203
+ sheetInitialDetentIndex = 0,
204
204
  nativeBackButtonDismissalEnabled = false,
205
205
  navigationBarColor,
206
206
  navigationBarTranslucent,
@@ -215,7 +215,7 @@ const RouteView = ({
215
215
  swipeDirection = 'horizontal',
216
216
  transitionDuration,
217
217
  freezeOnBlur,
218
- unstable_footerComponent = null,
218
+ unstable_sheetFooter = null,
219
219
  } = options;
220
220
 
221
221
  let {
@@ -229,9 +229,10 @@ const RouteView = ({
229
229
  } = options;
230
230
 
231
231
  // We only want to allow backgroundColor for now
232
- unstable_screenStyle = unstable_screenStyle
233
- ? { backgroundColor: unstable_screenStyle.backgroundColor }
234
- : null;
232
+ unstable_screenStyle =
233
+ stackPresentation === 'formSheet' && unstable_screenStyle
234
+ ? { backgroundColor: unstable_screenStyle.backgroundColor }
235
+ : null;
235
236
 
236
237
  if (sheetAllowedDetents === 'fitToContents') {
237
238
  sheetAllowedDetents = [-1];
@@ -317,9 +318,9 @@ const RouteView = ({
317
318
  hasLargeHeader={hasLargeHeader}
318
319
  style={[StyleSheet.absoluteFill, unstable_screenStyle]}
319
320
  sheetAllowedDetents={sheetAllowedDetents}
320
- sheetLargestUndimmedDetent={sheetLargestUndimmedDetent}
321
+ sheetLargestUndimmedDetentIndex={sheetLargestUndimmedDetentIndex}
321
322
  sheetGrabberVisible={sheetGrabberVisible}
322
- sheetInitialDetent={sheetInitialDetent}
323
+ sheetInitialDetentIndex={sheetInitialDetentIndex}
323
324
  sheetCornerRadius={sheetCornerRadius}
324
325
  sheetElevation={sheetElevation}
325
326
  sheetExpandsWhenScrolledToEdge={sheetExpandsWhenScrolledToEdge}
@@ -354,7 +355,6 @@ const RouteView = ({
354
355
  });
355
356
  }}
356
357
  onWillAppear={() => {
357
- console.log(`onWillAppear/transitionStart route: ${route.key}`);
358
358
  navigation.emit({
359
359
  type: 'transitionStart',
360
360
  data: { closing: false },
@@ -362,7 +362,6 @@ const RouteView = ({
362
362
  });
363
363
  }}
364
364
  onWillDisappear={() => {
365
- console.log(`onWillDisappear/transitionStart route: ${route.key}`);
366
365
  navigation.emit({
367
366
  type: 'transitionStart',
368
367
  data: { closing: true },
@@ -370,12 +369,10 @@ const RouteView = ({
370
369
  });
371
370
  }}
372
371
  onAppear={() => {
373
- console.log(`onAppear/appear route: ${route.key}`);
374
372
  navigation.emit({
375
373
  type: 'appear',
376
374
  target: route.key,
377
375
  });
378
- console.log(`onAppear/transitionEnd route: ${route.key}`);
379
376
  navigation.emit({
380
377
  type: 'transitionEnd',
381
378
  data: { closing: false },
@@ -383,7 +380,6 @@ const RouteView = ({
383
380
  });
384
381
  }}
385
382
  onDisappear={() => {
386
- console.log(`onDisappear/transitionEnd route: ${route.key}`);
387
383
  navigation.emit({
388
384
  type: 'transitionEnd',
389
385
  data: { closing: true },
@@ -403,7 +399,6 @@ const RouteView = ({
403
399
  }
404
400
  }}
405
401
  onDismissed={e => {
406
- console.log(`onDismissed/dismiss route: ${route.key}`);
407
402
  navigation.emit({
408
403
  type: 'dismiss',
409
404
  target: route.key,
@@ -450,8 +445,8 @@ const RouteView = ({
450
445
  route={route}
451
446
  headerShown={isHeaderInPush}
452
447
  />
453
- {unstable_footerComponent && (
454
- <FooterComponent>{unstable_footerComponent}</FooterComponent>
448
+ {stackPresentation === 'formSheet' && unstable_sheetFooter && (
449
+ <FooterComponent>{unstable_sheetFooter()}</FooterComponent>
455
450
  )}
456
451
  </HeaderHeightContext.Provider>
457
452
  </AnimatedHeaderHeightContext.Provider>
package/src/types.tsx CHANGED
@@ -39,7 +39,8 @@ export type StackAnimationTypes =
39
39
  | 'slide_from_bottom'
40
40
  | 'slide_from_right'
41
41
  | 'slide_from_left'
42
- | 'ios';
42
+ | 'ios_from_right'
43
+ | 'ios_from_left';
43
44
  export type BlurEffectTypes =
44
45
  | 'extraLight'
45
46
  | 'light'
@@ -102,7 +103,6 @@ export interface ScreenProps extends ViewProps {
102
103
  active?: 0 | 1 | Animated.AnimatedInterpolation<number>;
103
104
  activityState?: 0 | 1 | 2 | Animated.AnimatedInterpolation<number>;
104
105
  children?: React.ReactNode;
105
- unstable_footer?: React.ReactNode;
106
106
  /**
107
107
  * Boolean indicating that swipe dismissal should trigger animation provided by `stackAnimation`. Defaults to `false`.
108
108
  *
@@ -289,17 +289,31 @@ export interface ScreenProps extends ViewProps {
289
289
  unstable_screenStyle?: Pick<ViewStyle, 'backgroundColor'>;
290
290
  /**
291
291
  * Describes heights where a sheet can rest.
292
- * Works only when `stackPresentation` is set to `formSheet`.
292
+ * Works only when `presentation` is set to `formSheet`.
293
293
  *
294
294
  * Heights should be described as fraction (a number from `[0, 1]` interval) of screen height / maximum detent height.
295
- * There is also possibility to specify `[-1]` literal array with single element, which intets to set the sheet height
295
+ * You can pass an array of ascending values each defining allowed sheet detent. iOS accepts any number of detents,
296
+ * while **Android is limited to three**.
297
+ *
298
+ * There is also possibility to specify `fitToContents` literal, which intents to set the sheet height
296
299
  * to the height of its contents.
297
300
  *
298
- * Please note that the array **must** be sorted in ascending order.
301
+ * Please note that the array **must** be sorted in ascending order. This invariant is verified only in developement mode,
302
+ * where violation results in error.
303
+ *
304
+ * **Android is limited to up 3 values in the array** -- any surplus values, beside first three are ignored.
305
+ *
306
+ * There are also legacy & **deprecated** options available:
307
+ *
308
+ * * 'medium' - corresponds to `[0.5]` detent value, around half of the screen height,
309
+ * * 'large' - corresponds to `[1.0]` detent value, maximum height,
310
+ * * 'all' - corresponds to `[0.5, 1.0]` value, the name is deceiving due to compatibility reasons.
299
311
  *
300
- * Defaults to `[1.0]` literal.
312
+ * These are provided solely for **temporary** backward compatibility and are destined for removal in future versions.
313
+ *
314
+ * Defaults to `[1.0]`.
301
315
  */
302
- sheetAllowedDetents?: number[];
316
+ sheetAllowedDetents?: number[] | 'fitToContents' | 'medium' | 'large' | 'all';
303
317
  /**
304
318
  * Integer value describing elevation of the sheet, impacting shadow on the top edge of the sheet.
305
319
  *
@@ -344,16 +358,40 @@ export interface ScreenProps extends ViewProps {
344
358
  * This prop can be set to an number, which indicates index of detent in `sheetAllowedDetents` array for which
345
359
  * there won't be a dimming view beneath the sheet.
346
360
  *
347
- * Defaults to `-1`, indicating that the dimming view should be always present.
361
+ * If the specified index is out of bounds of `sheetAllowedDetents` array, in dev environment mode error will be thrown,
362
+ * in production the value will be reset to default value.
363
+ *
364
+ * Additionaly there are following options available:
365
+ *
366
+ * * `none` - there will be dimming view for all detents levels,
367
+ * * `last` - there won't be a dimming view for any detent level.
368
+ *
369
+ * There also legacy & **deprecated** prop values available: `medium`, `large` (don't confuse with `largest`), `all`, which work in tandem with
370
+ * corresponding legacy prop values for `sheetAllowedDetents` prop.
371
+ *
372
+ * These are provided solely for **temporary** backward compatibility and are destined for removal in future versions.
373
+ *
374
+ * Defaults to `none`, indicating that the dimming view should be always present.
348
375
  */
349
- sheetLargestUndimmedDetent?: number;
376
+ sheetLargestUndimmedDetentIndex?:
377
+ | number
378
+ | 'none'
379
+ | 'last'
380
+ | 'medium' // deprecated
381
+ | 'large' // deprecated
382
+ | 'all'; // deprecated
350
383
  /**
351
384
  * Index of the detent the sheet should expand to after being opened.
352
385
  * Works only when `stackPresentation` is set to `formSheet`.
353
386
  *
387
+ * If the specified index is out of bounds of `sheetAllowedDetents` array, in dev environment more error will be thrown,
388
+ * in production the value will be reset to default value.
389
+ *
390
+ * Additionaly there is `last` value available, when set the sheet will expand initially to last (largest) detent.
391
+ *
354
392
  * Defaults to `0` - which represents first detent in the detents array.
355
393
  */
356
- sheetInitialDetent?: number;
394
+ sheetInitialDetentIndex?: number | 'last';
357
395
  /**
358
396
  * How the screen should appear/disappear when pushed or popped at the top of the stack.
359
397
  * The following values are currently supported:
@@ -365,7 +403,8 @@ export interface ScreenProps extends ViewProps {
365
403
  * - `slide_from_bottom` – performs a slide from bottom animation
366
404
  * - "slide_from_right" - slide in the new screen from right to left (Android only, resolves to default transition on iOS)
367
405
  * - "slide_from_left" - slide in the new screen from left to right
368
- * - "ios" - iOS like slide in animation (Android only, resolves to default transition on iOS)
406
+ * - "ios_from_right" - iOS like slide in animation. pushes in the new screen from right to left (Android only, resolves to default transition on iOS)
407
+ * - "ios_from_left" - iOS like slide in animation. pushes in the new screen from left to right (Android only, resolves to default transition on iOS)
369
408
  * - "none" – the screen appears/dissapears without an animation
370
409
  */
371
410
  stackAnimation?: StackAnimationTypes;
@@ -422,6 +461,19 @@ export interface ScreenProps extends ViewProps {
422
461
  * @platform ios
423
462
  */
424
463
  transitionDuration?: number;
464
+ /**
465
+ * Footer component that can be used alongside formSheet stack presentation style.
466
+ *
467
+ * This option is provided, because due to implementation details it might be problematic
468
+ * to implement such layout with JS-only code.
469
+ *
470
+ * Please note that this prop is marked as unstable and might be subject of breaking changes,
471
+ * including removal, in particular when we find solution that will make implementing it with JS
472
+ * straightforward.
473
+ *
474
+ * @platform android
475
+ */
476
+ unstable_sheetFooter?: () => React.ReactNode;
425
477
  }
426
478
 
427
479
  export interface ScreenContainerProps extends ViewProps {
@@ -11,7 +11,8 @@ enum class StackAnimation {
11
11
  SIMPLE_FROM_BOTTOM,
12
12
  SLIDE_FROM_RIGHT,
13
13
  SLIDE_FROM_LEFT,
14
- IOS
14
+ IOS_FROM_RIGHT,
15
+ IOS_FROM_LEFT
15
16
  };
16
17
 
17
18
  enum class ReplaceAnimation { PUSH, POP };