react-native-screens 3.29.0 → 3.30.1

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 (448) hide show
  1. package/README.md +7 -7
  2. package/RNScreens.podspec +3 -3
  3. package/android/CMakeLists.txt +27 -0
  4. package/android/build.gradle +21 -2
  5. package/android/src/fabric/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +17 -14
  6. package/android/src/main/cpp/jni-adapter.cpp +110 -0
  7. package/android/src/main/java/com/swmansion/rnscreens/CustomSearchView.kt +13 -8
  8. package/android/src/main/java/com/swmansion/rnscreens/FragmentBackPressOverrider.kt +8 -8
  9. package/android/src/main/java/com/swmansion/rnscreens/ModalScreenViewManager.kt +12 -0
  10. package/android/src/main/java/com/swmansion/rnscreens/RNScreensPackage.kt +38 -5
  11. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +32 -42
  12. package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.kt +76 -48
  13. package/android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt +38 -35
  14. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +43 -37
  15. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +23 -23
  16. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt +73 -71
  17. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfigViewManager.kt +3 -3
  18. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubview.kt +5 -5
  19. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderSubviewManager.kt +3 -3
  20. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackViewManager.kt +3 -3
  21. package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +4 -4
  22. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +13 -16
  23. package/android/src/main/java/com/swmansion/rnscreens/ScreensModule.kt +105 -0
  24. package/android/src/main/java/com/swmansion/rnscreens/ScreensShadowNode.kt +2 -2
  25. package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +1 -0
  26. package/android/src/main/java/com/swmansion/rnscreens/SearchBarView.kt +14 -10
  27. package/android/src/main/java/com/swmansion/rnscreens/SearchViewFormatter.kt +8 -8
  28. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderAttachedEvent.kt +3 -7
  29. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderBackButtonClickedEvent.kt +4 -8
  30. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderDetachedEvent.kt +3 -7
  31. package/android/src/main/java/com/swmansion/rnscreens/events/HeaderHeightChangeEvent.kt +3 -3
  32. package/android/src/main/java/com/swmansion/rnscreens/events/ScreenTransitionProgressEvent.kt +9 -13
  33. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarBlurEvent.kt +3 -7
  34. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarChangeTextEvent.kt +3 -7
  35. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarCloseEvent.kt +3 -7
  36. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarFocusEvent.kt +3 -7
  37. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarOpenEvent.kt +3 -7
  38. package/android/src/main/java/com/swmansion/rnscreens/events/SearchBarSearchButtonPressEvent.kt +3 -7
  39. package/android/src/main/jni/rnscreens.h +1 -0
  40. package/android/src/main/res/v33/anim-v33/rns_default_enter_in.xml +0 -1
  41. package/android/src/main/res/v33/anim-v33/rns_default_enter_out.xml +2 -2
  42. package/android/src/paper/java/com/swmansion/rnscreens/FabricEnabledViewGroup.kt +1 -1
  43. package/android/src/paper/java/com/swmansion/rnscreens/NativeScreensModuleSpec.java +32 -0
  44. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenComponentDescriptor.h +41 -0
  45. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.cpp +15 -0
  46. package/common/cpp/react/renderer/components/rnscreens/RNSModalScreenShadowNode.h +31 -0
  47. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp +6 -0
  48. package/common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.h +1 -5
  49. package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.cpp +1 -1
  50. package/common/cpp/react/renderer/components/rnscreens/RNSScreenState.h +8 -3
  51. package/cpp/RNScreensTurboModule.cpp +107 -0
  52. package/cpp/RNScreensTurboModule.h +43 -0
  53. package/gesture-handler/package.json +6 -0
  54. package/ios/RNSConvert.h +2 -0
  55. package/ios/RNSConvert.mm +5 -2
  56. package/ios/RNSEnums.h +1 -0
  57. package/ios/RNSModalScreen.h +8 -0
  58. package/ios/RNSModalScreen.mm +36 -0
  59. package/ios/RNSModule.h +19 -0
  60. package/ios/RNSModule.mm +174 -0
  61. package/ios/RNSScreen.h +4 -1
  62. package/ios/RNSScreen.mm +48 -26
  63. package/ios/RNSScreenStack.h +6 -0
  64. package/ios/RNSScreenStack.mm +81 -15
  65. package/ios/RNSScreenStackAnimator.mm +89 -1
  66. package/ios/RNSScreenStackHeaderConfig.mm +7 -1
  67. package/ios/RNSScreenWindowTraits.h +1 -1
  68. package/ios/RNSScreenWindowTraits.mm +24 -50
  69. package/ios/RNSSearchBar.mm +24 -0
  70. package/ios/utils/RNSUIBarButtonItem.h +2 -0
  71. package/lib/commonjs/TransitionProgressContext.js +3 -4
  72. package/lib/commonjs/TransitionProgressContext.js.map +1 -1
  73. package/lib/commonjs/components/FullWindowOverlay.js +28 -0
  74. package/lib/commonjs/components/FullWindowOverlay.js.map +1 -0
  75. package/lib/commonjs/components/FullWindowOverlay.web.js +9 -0
  76. package/lib/commonjs/components/FullWindowOverlay.web.js.map +1 -0
  77. package/lib/commonjs/components/Screen.js +161 -0
  78. package/lib/commonjs/components/Screen.js.map +1 -0
  79. package/lib/commonjs/components/Screen.web.js +46 -0
  80. package/lib/commonjs/components/Screen.web.js.map +1 -0
  81. package/lib/commonjs/components/ScreenContainer.js +33 -0
  82. package/lib/commonjs/components/ScreenContainer.js.map +1 -0
  83. package/lib/commonjs/components/ScreenContainer.web.js +11 -0
  84. package/lib/commonjs/components/ScreenContainer.web.js.map +1 -0
  85. package/lib/commonjs/components/ScreenStack.js +45 -0
  86. package/lib/commonjs/components/ScreenStack.js.map +1 -0
  87. package/lib/commonjs/components/ScreenStack.web.js +9 -0
  88. package/lib/commonjs/components/ScreenStack.web.js.map +1 -0
  89. package/lib/commonjs/components/ScreenStackHeaderConfig.js +53 -0
  90. package/lib/commonjs/components/ScreenStackHeaderConfig.js.map +1 -0
  91. package/lib/commonjs/components/ScreenStackHeaderConfig.web.js +27 -0
  92. package/lib/commonjs/components/ScreenStackHeaderConfig.web.js.map +1 -0
  93. package/lib/commonjs/components/SearchBar.js +59 -0
  94. package/lib/commonjs/components/SearchBar.js.map +1 -0
  95. package/lib/commonjs/components/SearchBar.web.js +11 -0
  96. package/lib/commonjs/components/SearchBar.web.js.map +1 -0
  97. package/lib/commonjs/components/helpers/DelayedFreeze.js +32 -0
  98. package/lib/commonjs/components/helpers/DelayedFreeze.js.map +1 -0
  99. package/lib/commonjs/core.js +41 -0
  100. package/lib/commonjs/core.js.map +1 -0
  101. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +1 -2
  102. package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
  103. package/lib/commonjs/fabric/ModalScreenNativeComponent.js +13 -0
  104. package/lib/commonjs/fabric/ModalScreenNativeComponent.js.map +1 -0
  105. package/lib/commonjs/fabric/NativeScreensModule.js +10 -0
  106. package/lib/commonjs/fabric/NativeScreensModule.js.map +1 -0
  107. package/lib/commonjs/fabric/NativeScreensModule.web.js +8 -0
  108. package/lib/commonjs/fabric/NativeScreensModule.web.js.map +1 -0
  109. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +1 -2
  110. package/lib/commonjs/fabric/ScreenContainerNativeComponent.js.map +1 -1
  111. package/lib/commonjs/fabric/ScreenNativeComponent.js +1 -2
  112. package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
  113. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +1 -2
  114. package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
  115. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js +1 -2
  116. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  117. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js +1 -2
  118. package/lib/commonjs/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
  119. package/lib/commonjs/fabric/ScreenStackNativeComponent.js +1 -2
  120. package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
  121. package/lib/commonjs/fabric/SearchBarNativeComponent.js +3 -5
  122. package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -1
  123. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js +19 -0
  124. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js.map +1 -0
  125. package/lib/commonjs/gesture-handler/RNScreensTurboModule.js +8 -0
  126. package/lib/commonjs/gesture-handler/RNScreensTurboModule.js.map +1 -0
  127. package/lib/commonjs/gesture-handler/ScreenGestureDetector.js +202 -0
  128. package/lib/commonjs/gesture-handler/ScreenGestureDetector.js.map +1 -0
  129. package/lib/commonjs/gesture-handler/constraints.js +64 -0
  130. package/lib/commonjs/gesture-handler/constraints.js.map +1 -0
  131. package/lib/commonjs/gesture-handler/defaults.js +38 -0
  132. package/lib/commonjs/gesture-handler/defaults.js.map +1 -0
  133. package/lib/commonjs/gesture-handler/fabricUtils.js +30 -0
  134. package/lib/commonjs/gesture-handler/fabricUtils.js.map +1 -0
  135. package/lib/commonjs/gesture-handler/fabricUtils.web.js +17 -0
  136. package/lib/commonjs/gesture-handler/fabricUtils.web.js.map +1 -0
  137. package/lib/commonjs/gesture-handler/index.js +14 -0
  138. package/lib/commonjs/gesture-handler/index.js.map +1 -0
  139. package/lib/commonjs/index.js +183 -100
  140. package/lib/commonjs/index.js.map +1 -1
  141. package/lib/commonjs/native-stack/contexts/GHContext.js +11 -0
  142. package/lib/commonjs/native-stack/contexts/GHContext.js.map +1 -0
  143. package/lib/commonjs/native-stack/index.js.map +1 -1
  144. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +20 -24
  145. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  146. package/lib/commonjs/native-stack/types.js.map +1 -1
  147. package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js +3 -4
  148. package/lib/commonjs/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -1
  149. package/lib/commonjs/native-stack/utils/HeaderHeightContext.js +3 -4
  150. package/lib/commonjs/native-stack/utils/HeaderHeightContext.js.map +1 -1
  151. package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js +2 -2
  152. package/lib/commonjs/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  153. package/lib/commonjs/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
  154. package/lib/commonjs/native-stack/utils/getStatusBarHeight.js.map +1 -1
  155. package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js +2 -2
  156. package/lib/commonjs/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -1
  157. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js +2 -4
  158. package/lib/commonjs/native-stack/utils/useBackPressSubscription.js.map +1 -1
  159. package/lib/commonjs/native-stack/utils/useHeaderHeight.js +2 -2
  160. package/lib/commonjs/native-stack/utils/useHeaderHeight.js.map +1 -1
  161. package/lib/commonjs/native-stack/views/FontProcessor.js +1 -2
  162. package/lib/commonjs/native-stack/views/FontProcessor.js.map +1 -1
  163. package/lib/commonjs/native-stack/views/HeaderConfig.js +11 -7
  164. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  165. package/lib/commonjs/native-stack/views/NativeStackView.js +50 -15
  166. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  167. package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js +3 -4
  168. package/lib/commonjs/reanimated/ReanimatedHeaderHeightContext.js.map +1 -1
  169. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +6 -9
  170. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  171. package/lib/commonjs/reanimated/ReanimatedScreen.js +1 -2
  172. package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
  173. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +6 -14
  174. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
  175. package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js +3 -4
  176. package/lib/commonjs/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
  177. package/lib/commonjs/reanimated/index.js.map +1 -1
  178. package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js +2 -2
  179. package/lib/commonjs/reanimated/useReanimatedHeaderHeight.js.map +1 -1
  180. package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js +2 -2
  181. package/lib/commonjs/reanimated/useReanimatedTransitionProgress.js.map +1 -1
  182. package/lib/commonjs/types.js.map +1 -1
  183. package/lib/commonjs/useTransitionProgress.js +2 -2
  184. package/lib/commonjs/useTransitionProgress.js.map +1 -1
  185. package/lib/commonjs/utils.js +2 -4
  186. package/lib/commonjs/utils.js.map +1 -1
  187. package/lib/module/TransitionProgressContext.js.map +1 -1
  188. package/lib/module/components/FullWindowOverlay.js +21 -0
  189. package/lib/module/components/FullWindowOverlay.js.map +1 -0
  190. package/lib/module/components/FullWindowOverlay.web.js +3 -0
  191. package/lib/module/components/FullWindowOverlay.web.js.map +1 -0
  192. package/lib/module/components/Screen.js +156 -0
  193. package/lib/module/components/Screen.js.map +1 -0
  194. package/lib/module/components/Screen.web.js +38 -0
  195. package/lib/module/components/Screen.web.js.map +1 -0
  196. package/lib/module/components/ScreenContainer.js +26 -0
  197. package/lib/module/components/ScreenContainer.js.map +1 -0
  198. package/lib/module/components/ScreenContainer.web.js +5 -0
  199. package/lib/module/components/ScreenContainer.web.js.map +1 -0
  200. package/lib/module/components/ScreenStack.js +40 -0
  201. package/lib/module/components/ScreenStack.js.map +1 -0
  202. package/lib/module/components/ScreenStack.web.js +3 -0
  203. package/lib/module/components/ScreenStack.web.js.map +1 -0
  204. package/lib/module/components/ScreenStackHeaderConfig.js +43 -0
  205. package/lib/module/components/ScreenStackHeaderConfig.js.map +1 -0
  206. package/lib/module/components/ScreenStackHeaderConfig.web.js +14 -0
  207. package/lib/module/components/ScreenStackHeaderConfig.web.js.map +1 -0
  208. package/lib/module/components/SearchBar.js +52 -0
  209. package/lib/module/components/SearchBar.js.map +1 -0
  210. package/lib/module/components/SearchBar.web.js +5 -0
  211. package/lib/module/components/SearchBar.web.js.map +1 -0
  212. package/lib/module/components/helpers/DelayedFreeze.js +25 -0
  213. package/lib/module/components/helpers/DelayedFreeze.js.map +1 -0
  214. package/lib/module/core.js +31 -0
  215. package/lib/module/core.js.map +1 -0
  216. package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -1
  217. package/lib/module/fabric/ModalScreenNativeComponent.js +8 -0
  218. package/lib/module/fabric/ModalScreenNativeComponent.js.map +1 -0
  219. package/lib/module/fabric/NativeScreensModule.js +5 -0
  220. package/lib/module/fabric/NativeScreensModule.js.map +1 -0
  221. package/lib/module/fabric/NativeScreensModule.web.js +2 -0
  222. package/lib/module/fabric/NativeScreensModule.web.js.map +1 -0
  223. package/lib/module/fabric/ScreenContainerNativeComponent.js.map +1 -1
  224. package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
  225. package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -1
  226. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  227. package/lib/module/fabric/ScreenStackHeaderSubviewNativeComponent.js.map +1 -1
  228. package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
  229. package/lib/module/fabric/SearchBarNativeComponent.js +1 -1
  230. package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -1
  231. package/lib/module/gesture-handler/GestureDetectorProvider.js +12 -0
  232. package/lib/module/gesture-handler/GestureDetectorProvider.js.map +1 -0
  233. package/lib/module/gesture-handler/RNScreensTurboModule.js +2 -0
  234. package/lib/module/gesture-handler/RNScreensTurboModule.js.map +1 -0
  235. package/lib/module/gesture-handler/ScreenGestureDetector.js +194 -0
  236. package/lib/module/gesture-handler/ScreenGestureDetector.js.map +1 -0
  237. package/lib/module/gesture-handler/constraints.js +56 -0
  238. package/lib/module/gesture-handler/constraints.js.map +1 -0
  239. package/lib/module/gesture-handler/defaults.js +32 -0
  240. package/lib/module/gesture-handler/defaults.js.map +1 -0
  241. package/lib/module/gesture-handler/fabricUtils.js +23 -0
  242. package/lib/module/gesture-handler/fabricUtils.js.map +1 -0
  243. package/lib/module/gesture-handler/fabricUtils.web.js +10 -0
  244. package/lib/module/gesture-handler/fabricUtils.web.js.map +1 -0
  245. package/lib/module/gesture-handler/index.js +5 -0
  246. package/lib/module/gesture-handler/index.js.map +1 -0
  247. package/lib/module/index.js +31 -64
  248. package/lib/module/index.js.map +1 -1
  249. package/lib/module/native-stack/contexts/GHContext.js +4 -0
  250. package/lib/module/native-stack/contexts/GHContext.js.map +1 -0
  251. package/lib/module/native-stack/index.js.map +1 -1
  252. package/lib/module/native-stack/navigators/createNativeStackNavigator.js +17 -20
  253. package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  254. package/lib/module/native-stack/types.js.map +1 -1
  255. package/lib/module/native-stack/utils/AnimatedHeaderHeightContext.js.map +1 -1
  256. package/lib/module/native-stack/utils/HeaderHeightContext.js.map +1 -1
  257. package/lib/module/native-stack/utils/SafeAreaProviderCompat.js.map +1 -1
  258. package/lib/module/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
  259. package/lib/module/native-stack/utils/getStatusBarHeight.js.map +1 -1
  260. package/lib/module/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -1
  261. package/lib/module/native-stack/utils/useBackPressSubscription.js +2 -4
  262. package/lib/module/native-stack/utils/useBackPressSubscription.js.map +1 -1
  263. package/lib/module/native-stack/utils/useHeaderHeight.js.map +1 -1
  264. package/lib/module/native-stack/views/FontProcessor.js +1 -2
  265. package/lib/module/native-stack/views/FontProcessor.js.map +1 -1
  266. package/lib/module/native-stack/views/HeaderConfig.js +8 -5
  267. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  268. package/lib/module/native-stack/views/NativeStackView.js +49 -14
  269. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  270. package/lib/module/reanimated/ReanimatedHeaderHeightContext.js.map +1 -1
  271. package/lib/module/reanimated/ReanimatedNativeStackScreen.js +2 -4
  272. package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  273. package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
  274. package/lib/module/reanimated/ReanimatedScreenProvider.js +6 -14
  275. package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
  276. package/lib/module/reanimated/ReanimatedTransitionProgressContext.js.map +1 -1
  277. package/lib/module/reanimated/index.js.map +1 -1
  278. package/lib/module/reanimated/useReanimatedHeaderHeight.js.map +1 -1
  279. package/lib/module/reanimated/useReanimatedTransitionProgress.js.map +1 -1
  280. package/lib/module/types.js.map +1 -1
  281. package/lib/module/useTransitionProgress.js.map +1 -1
  282. package/lib/module/utils.js.map +1 -1
  283. package/lib/typescript/TransitionProgressContext.d.ts +1 -0
  284. package/lib/typescript/TransitionProgressContext.d.ts.map +1 -0
  285. package/lib/typescript/components/FullWindowOverlay.d.ts +6 -0
  286. package/lib/typescript/components/FullWindowOverlay.d.ts.map +1 -0
  287. package/lib/typescript/components/FullWindowOverlay.web.d.ts +6 -0
  288. package/lib/typescript/components/FullWindowOverlay.web.d.ts.map +1 -0
  289. package/lib/typescript/components/Screen.d.ts +20 -0
  290. package/lib/typescript/components/Screen.d.ts.map +1 -0
  291. package/lib/typescript/components/Screen.web.d.ts +11 -0
  292. package/lib/typescript/components/Screen.web.d.ts.map +1 -0
  293. package/lib/typescript/components/ScreenContainer.d.ts +7 -0
  294. package/lib/typescript/components/ScreenContainer.d.ts.map +1 -0
  295. package/lib/typescript/components/ScreenContainer.web.d.ts +5 -0
  296. package/lib/typescript/components/ScreenContainer.web.d.ts.map +1 -0
  297. package/lib/typescript/components/ScreenStack.d.ts +5 -0
  298. package/lib/typescript/components/ScreenStack.d.ts.map +1 -0
  299. package/lib/typescript/components/ScreenStack.web.d.ts +3 -0
  300. package/lib/typescript/components/ScreenStack.web.d.ts.map +1 -0
  301. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts +13 -0
  302. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts.map +1 -0
  303. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts +13 -0
  304. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts.map +1 -0
  305. package/lib/typescript/components/SearchBar.d.ts +26 -0
  306. package/lib/typescript/components/SearchBar.d.ts.map +1 -0
  307. package/lib/typescript/components/SearchBar.web.d.ts +5 -0
  308. package/lib/typescript/components/SearchBar.web.d.ts.map +1 -0
  309. package/lib/typescript/components/helpers/DelayedFreeze.d.ts +8 -0
  310. package/lib/typescript/components/helpers/DelayedFreeze.d.ts.map +1 -0
  311. package/lib/typescript/core.d.ts +7 -0
  312. package/lib/typescript/core.d.ts.map +1 -0
  313. package/lib/typescript/fabric/FullWindowOverlayNativeComponent.d.ts +1 -0
  314. package/lib/typescript/fabric/FullWindowOverlayNativeComponent.d.ts.map +1 -0
  315. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts +68 -0
  316. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts.map +1 -0
  317. package/lib/typescript/fabric/NativeScreensModule.d.ts +6 -0
  318. package/lib/typescript/fabric/NativeScreensModule.d.ts.map +1 -0
  319. package/lib/typescript/fabric/NativeScreensModule.web.d.ts +3 -0
  320. package/lib/typescript/fabric/NativeScreensModule.web.d.ts.map +1 -0
  321. package/lib/typescript/fabric/ScreenContainerNativeComponent.d.ts +1 -0
  322. package/lib/typescript/fabric/ScreenContainerNativeComponent.d.ts.map +1 -0
  323. package/lib/typescript/fabric/ScreenNativeComponent.d.ts +2 -1
  324. package/lib/typescript/fabric/ScreenNativeComponent.d.ts.map +1 -0
  325. package/lib/typescript/fabric/ScreenNavigationContainerNativeComponent.d.ts +1 -0
  326. package/lib/typescript/fabric/ScreenNavigationContainerNativeComponent.d.ts.map +1 -0
  327. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +1 -0
  328. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -0
  329. package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts +1 -0
  330. package/lib/typescript/fabric/ScreenStackHeaderSubviewNativeComponent.d.ts.map +1 -0
  331. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts +1 -0
  332. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts.map +1 -0
  333. package/lib/typescript/fabric/SearchBarNativeComponent.d.ts +3 -1
  334. package/lib/typescript/fabric/SearchBarNativeComponent.d.ts.map +1 -0
  335. package/lib/typescript/gesture-handler/GestureDetectorProvider.d.ts +5 -0
  336. package/lib/typescript/gesture-handler/GestureDetectorProvider.d.ts.map +1 -0
  337. package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts +13 -0
  338. package/lib/typescript/gesture-handler/RNScreensTurboModule.d.ts.map +1 -0
  339. package/lib/typescript/gesture-handler/ScreenGestureDetector.d.ts +5 -0
  340. package/lib/typescript/gesture-handler/ScreenGestureDetector.d.ts.map +1 -0
  341. package/lib/typescript/gesture-handler/constraints.d.ts +6 -0
  342. package/lib/typescript/gesture-handler/constraints.d.ts.map +1 -0
  343. package/lib/typescript/gesture-handler/defaults.d.ts +20 -0
  344. package/lib/typescript/gesture-handler/defaults.d.ts.map +1 -0
  345. package/lib/typescript/gesture-handler/fabricUtils.d.ts +8 -0
  346. package/lib/typescript/gesture-handler/fabricUtils.d.ts.map +1 -0
  347. package/lib/typescript/gesture-handler/fabricUtils.web.d.ts +6 -0
  348. package/lib/typescript/gesture-handler/fabricUtils.web.d.ts.map +1 -0
  349. package/lib/typescript/gesture-handler/index.d.ts +2 -0
  350. package/lib/typescript/gesture-handler/index.d.ts.map +1 -0
  351. package/lib/typescript/index.d.ts +11 -31
  352. package/lib/typescript/index.d.ts.map +1 -0
  353. package/lib/typescript/native-stack/contexts/GHContext.d.ts +4 -0
  354. package/lib/typescript/native-stack/contexts/GHContext.d.ts.map +1 -0
  355. package/lib/typescript/native-stack/index.d.ts +1 -0
  356. package/lib/typescript/native-stack/index.d.ts.map +1 -0
  357. package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts +1 -0
  358. package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts.map +1 -0
  359. package/lib/typescript/native-stack/types.d.ts +39 -2
  360. package/lib/typescript/native-stack/types.d.ts.map +1 -0
  361. package/lib/typescript/native-stack/utils/AnimatedHeaderHeightContext.d.ts +1 -0
  362. package/lib/typescript/native-stack/utils/AnimatedHeaderHeightContext.d.ts.map +1 -0
  363. package/lib/typescript/native-stack/utils/HeaderHeightContext.d.ts +1 -0
  364. package/lib/typescript/native-stack/utils/HeaderHeightContext.d.ts.map +1 -0
  365. package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts +1 -0
  366. package/lib/typescript/native-stack/utils/SafeAreaProviderCompat.d.ts.map +1 -0
  367. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -0
  368. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts.map +1 -0
  369. package/lib/typescript/native-stack/utils/getStatusBarHeight.d.ts +1 -0
  370. package/lib/typescript/native-stack/utils/getStatusBarHeight.d.ts.map +1 -0
  371. package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts +1 -0
  372. package/lib/typescript/native-stack/utils/useAnimatedHeaderHeight.d.ts.map +1 -0
  373. package/lib/typescript/native-stack/utils/useBackPressSubscription.d.ts +1 -0
  374. package/lib/typescript/native-stack/utils/useBackPressSubscription.d.ts.map +1 -0
  375. package/lib/typescript/native-stack/utils/useHeaderHeight.d.ts +1 -0
  376. package/lib/typescript/native-stack/utils/useHeaderHeight.d.ts.map +1 -0
  377. package/lib/typescript/native-stack/views/FontProcessor.d.ts +1 -0
  378. package/lib/typescript/native-stack/views/FontProcessor.d.ts.map +1 -0
  379. package/lib/typescript/native-stack/views/HeaderConfig.d.ts +1 -0
  380. package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -0
  381. package/lib/typescript/native-stack/views/NativeStackView.d.ts +1 -0
  382. package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -0
  383. package/lib/typescript/reanimated/ReanimatedHeaderHeightContext.d.ts +1 -0
  384. package/lib/typescript/reanimated/ReanimatedHeaderHeightContext.d.ts.map +1 -0
  385. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +2 -2
  386. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts.map +1 -0
  387. package/lib/typescript/reanimated/ReanimatedScreen.d.ts +2 -2
  388. package/lib/typescript/reanimated/ReanimatedScreen.d.ts.map +1 -0
  389. package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts +1 -0
  390. package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts.map +1 -0
  391. package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts +1 -0
  392. package/lib/typescript/reanimated/ReanimatedTransitionProgressContext.d.ts.map +1 -0
  393. package/lib/typescript/reanimated/index.d.ts +1 -0
  394. package/lib/typescript/reanimated/index.d.ts.map +1 -0
  395. package/lib/typescript/reanimated/useReanimatedHeaderHeight.d.ts +2 -3
  396. package/lib/typescript/reanimated/useReanimatedHeaderHeight.d.ts.map +1 -0
  397. package/lib/typescript/reanimated/useReanimatedTransitionProgress.d.ts +4 -9
  398. package/lib/typescript/reanimated/useReanimatedTransitionProgress.d.ts.map +1 -0
  399. package/lib/typescript/types.d.ts +11 -2
  400. package/lib/typescript/types.d.ts.map +1 -0
  401. package/lib/typescript/useTransitionProgress.d.ts +1 -0
  402. package/lib/typescript/useTransitionProgress.d.ts.map +1 -0
  403. package/lib/typescript/utils.d.ts +1 -0
  404. package/lib/typescript/utils.d.ts.map +1 -0
  405. package/native-stack/README.md +2 -1
  406. package/native-stack/package.json +1 -1
  407. package/package.json +17 -11
  408. package/react-native.config.js +2 -1
  409. package/reanimated/package.json +1 -1
  410. package/src/components/FullWindowOverlay.tsx +25 -0
  411. package/src/components/FullWindowOverlay.web.tsx +6 -0
  412. package/src/components/Screen.tsx +218 -0
  413. package/src/components/Screen.web.tsx +43 -0
  414. package/src/components/ScreenContainer.tsx +33 -0
  415. package/src/components/ScreenContainer.web.tsx +6 -0
  416. package/src/components/ScreenStack.tsx +41 -0
  417. package/src/components/ScreenStack.web.tsx +3 -0
  418. package/src/components/ScreenStackHeaderConfig.tsx +76 -0
  419. package/src/components/ScreenStackHeaderConfig.web.tsx +39 -0
  420. package/src/components/SearchBar.tsx +91 -0
  421. package/src/components/SearchBar.web.tsx +6 -0
  422. package/src/components/helpers/DelayedFreeze.tsx +27 -0
  423. package/src/core.ts +43 -0
  424. package/src/fabric/ModalScreenNativeComponent.ts +104 -0
  425. package/src/fabric/NativeScreensModule.ts +7 -0
  426. package/src/fabric/NativeScreensModule.web.ts +1 -0
  427. package/src/fabric/ScreenNativeComponent.ts +1 -1
  428. package/src/fabric/SearchBarNativeComponent.ts +2 -0
  429. package/src/gesture-handler/GestureDetectorProvider.tsx +16 -0
  430. package/src/gesture-handler/RNScreensTurboModule.ts +13 -0
  431. package/src/gesture-handler/ScreenGestureDetector.tsx +241 -0
  432. package/src/gesture-handler/constraints.ts +87 -0
  433. package/src/gesture-handler/defaults.ts +38 -0
  434. package/src/gesture-handler/fabricUtils.ts +39 -0
  435. package/src/gesture-handler/fabricUtils.web.ts +10 -0
  436. package/src/gesture-handler/index.tsx +4 -0
  437. package/src/index.tsx +65 -112
  438. package/src/native-stack/contexts/GHContext.tsx +7 -0
  439. package/src/native-stack/types.tsx +62 -1
  440. package/src/native-stack/views/HeaderConfig.tsx +11 -0
  441. package/src/native-stack/views/NativeStackView.tsx +65 -13
  442. package/src/types.tsx +13 -1
  443. package/lib/commonjs/index.native.js +0 -418
  444. package/lib/commonjs/index.native.js.map +0 -1
  445. package/lib/module/index.native.js +0 -415
  446. package/lib/module/index.native.js.map +0 -1
  447. package/lib/typescript/index.native.d.ts +0 -2
  448. package/src/index.native.tsx +0 -619
@@ -0,0 +1,174 @@
1
+ #import "RNSModule.h"
2
+ #import <React/RCTBridge+Private.h>
3
+ #import <React/RCTBridge.h>
4
+ #import <React/RCTUIManager.h>
5
+ #import <React/RCTUIManagerUtils.h>
6
+ #import <React/RCTUtils.h>
7
+ #include <jsi/jsi.h>
8
+ #import "RNSScreenStack.h"
9
+ #import "RNScreensTurboModule.h"
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @implementation RNSModule {
14
+ std::atomic<bool> isActiveTransition;
15
+ }
16
+
17
+ RCT_EXPORT_MODULE()
18
+
19
+ #ifdef RCT_NEW_ARCH_ENABLED
20
+ @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
21
+ #endif // RCT_NEW_ARCH_ENABLED
22
+ @synthesize bridge = _bridge;
23
+
24
+ - (dispatch_queue_t)methodQueue
25
+ {
26
+ // It seems that due to how UIBlocks work with uiManager, we need to call the methods there
27
+ // for the blocks to be dispatched before the batch is completed
28
+ return dispatch_get_main_queue();
29
+ }
30
+
31
+ - (NSDictionary *)constantsToExport
32
+ {
33
+ [self installHostObject];
34
+ return @{};
35
+ }
36
+
37
+ + (BOOL)requiresMainQueueSetup
38
+ {
39
+ return NO;
40
+ }
41
+
42
+ - (RNSScreenStackView *)getScreenStackView:(NSNumber *)reactTag
43
+ {
44
+ RCTAssertMainQueue();
45
+ RNSScreenStackView *view;
46
+ #ifdef RCT_NEW_ARCH_ENABLED
47
+ view = (RNSScreenStackView *)[self.viewRegistry_DEPRECATED viewForReactTag:reactTag];
48
+ #else
49
+ view = (RNSScreenStackView *)[self.bridge.uiManager viewForReactTag:reactTag];
50
+ #endif // RCT_NEW_ARCH_ENABLED
51
+ return view;
52
+ }
53
+
54
+ - (NSArray<NSNumber *> *)startTransition:(NSNumber *)stackTag
55
+ {
56
+ RCTAssertMainQueue();
57
+ RNSScreenStackView *stackView = [self getStackView:stackTag];
58
+ if (stackView == nil || isActiveTransition) {
59
+ return @[ @(-1), @(-1) ];
60
+ }
61
+ NSArray<NSNumber *> *screenTags = @[ @(-1), @(-1) ];
62
+ auto screens = stackView.reactViewController.childViewControllers;
63
+ unsigned long screenCount = [screens count];
64
+ if (screenCount > 1) {
65
+ UIView *topScreen = screens[screenCount - 1].view;
66
+ UIView *belowTopScreen = screens[screenCount - 2].view;
67
+ belowTopScreen.transform = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
68
+ isActiveTransition = true;
69
+ #ifdef RCT_NEW_ARCH_ENABLED
70
+ screenTags = @[ @(topScreen.tag), @(belowTopScreen.tag) ];
71
+ #else
72
+ screenTags = @[ topScreen.reactTag, belowTopScreen.reactTag ];
73
+ #endif // RCT_NEW_ARCH_ENABLED
74
+ [stackView startScreenTransition];
75
+ }
76
+ return screenTags;
77
+ }
78
+
79
+ - (bool)updateTransition:(NSNumber *)stackTag progress:(double)progress
80
+ {
81
+ RCTAssertMainQueue();
82
+ RNSScreenStackView *stackView = [self getStackView:stackTag];
83
+ if (stackView == nil || !isActiveTransition) {
84
+ return false;
85
+ }
86
+ [stackView updateScreenTransition:progress];
87
+ return true;
88
+ }
89
+
90
+ - (bool)finishTransition:(NSNumber *)stackTag canceled:(bool)canceled
91
+ {
92
+ RCTAssertMainQueue();
93
+ RNSScreenStackView *stackView = [self getStackView:stackTag];
94
+ if (stackView == nil || !isActiveTransition) {
95
+ return false;
96
+ }
97
+ [stackView finishScreenTransition:canceled];
98
+ if (!canceled) {
99
+ stackView.disableSwipeBack = NO;
100
+ }
101
+ isActiveTransition = false;
102
+ return true;
103
+ }
104
+
105
+ - (void)disableSwipeBackForTopScreen:(NSNumber *)stackTag
106
+ {
107
+ RCTAssertMainQueue();
108
+ RNSScreenStackView *stackView = [self getStackView:stackTag];
109
+ if (stackView == nil) {
110
+ return;
111
+ }
112
+ stackView.disableSwipeBack = YES;
113
+ }
114
+
115
+ - (RNSScreenStackView *)getStackView:(NSNumber *)stackTag
116
+ {
117
+ RNSScreenStackView *view = [self getScreenStackView:stackTag];
118
+ if (view != nil && ![view isKindOfClass:[RNSScreenStackView class]]) {
119
+ RCTLogError(@"Invalid view type, expecting RNSScreenStackView, got: %@", view);
120
+ return nil;
121
+ }
122
+ return view;
123
+ }
124
+
125
+ #ifdef RCT_NEW_ARCH_ENABLED
126
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
127
+ (const facebook::react::ObjCTurboModule::InitParams &)params
128
+ {
129
+ [self installHostObject];
130
+ return std::make_shared<facebook::react::NativeScreensModuleSpecJSI>(params);
131
+ }
132
+ #endif
133
+
134
+ - (void)installHostObject
135
+ {
136
+ /*
137
+ installHostObject method is called from constantsToExport and getTurboModule,
138
+ because depending on the selected architecture, only one method will be called.
139
+ For `Paper`, it will be constantsToExport, and for `Fabric`, it will be getTurboModule.
140
+ */
141
+ RCTBridge *bridge = [RCTBridge currentBridge];
142
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)bridge;
143
+ if (cxxBridge != nil) {
144
+ auto jsiRuntime = (jsi::Runtime *)cxxBridge.runtime;
145
+ if (jsiRuntime != nil) {
146
+ auto &runtime = *jsiRuntime;
147
+ __weak auto weakSelf = self;
148
+
149
+ const auto &startTransition = [weakSelf](int stackTag) -> std::array<int, 2> {
150
+ auto screensTags = [weakSelf startTransition:@(stackTag)];
151
+ return {[screensTags[0] intValue], [screensTags[1] intValue]};
152
+ };
153
+ const auto &updateTransition = [weakSelf](int stackTag, double progress) {
154
+ [weakSelf updateTransition:@(stackTag) progress:progress];
155
+ };
156
+ const auto &finishTransition = [weakSelf](int stackTag, bool canceled) {
157
+ [weakSelf finishTransition:@(stackTag) canceled:canceled];
158
+ };
159
+ const auto &disableSwipeBackForTopScreen = [weakSelf](int stackTag) {
160
+ [weakSelf disableSwipeBackForTopScreen:@(stackTag)];
161
+ };
162
+
163
+ auto rnScreensModule = std::make_shared<RNScreens::RNScreensTurboModule>(
164
+ startTransition, updateTransition, finishTransition, disableSwipeBackForTopScreen);
165
+ auto rnScreensModuleHostObject = jsi::Object::createFromHostObject(runtime, rnScreensModule);
166
+ runtime.global().setProperty(
167
+ runtime, RNScreens::RNScreensTurboModule::MODULE_NAME, std::move(rnScreensModuleHostObject));
168
+ }
169
+ }
170
+ }
171
+
172
+ @end
173
+
174
+ NS_ASSUME_NONNULL_END
package/ios/RNSScreen.h CHANGED
@@ -42,6 +42,7 @@ namespace react = facebook::react;
42
42
  #ifdef RCT_NEW_ARCH_ENABLED
43
43
  - (void)setViewToSnapshot:(UIView *)snapshot;
44
44
  - (void)resetViewToScreen;
45
+ - (CGFloat)calculateHeaderHeightIsModal:(BOOL)isModal;
45
46
  #endif
46
47
 
47
48
  @end
@@ -121,7 +122,9 @@ namespace react = facebook::react;
121
122
  - (void)updateBounds;
122
123
  - (void)notifyDismissedWithCount:(int)dismissCount;
123
124
  - (instancetype)initWithFrame:(CGRect)frame;
124
- #endif
125
+ #else
126
+ - (instancetype)initWithBridge:(RCTBridge *)bridge;
127
+ #endif // RCT_NEW_ARCH_ENABLED
125
128
 
126
129
  - (void)notifyTransitionProgress:(double)progress closing:(BOOL)closing goingForward:(BOOL)goingForward;
127
130
  - (void)notifyDismissCancelledWithDismissCount:(int)dismissCount;
package/ios/RNSScreen.mm CHANGED
@@ -38,13 +38,13 @@ namespace react = facebook::react;
38
38
  @end
39
39
 
40
40
  @implementation RNSScreenView {
41
- __weak RCTBridge *_bridge;
42
41
  #ifdef RCT_NEW_ARCH_ENABLED
43
42
  RCTSurfaceTouchHandler *_touchHandler;
44
43
  react::RNSScreenShadowNode::ConcreteState::Shared _state;
45
44
  // on fabric, they are not available by default so we need them exposed here too
46
45
  NSMutableArray<UIView *> *_reactSubviews;
47
46
  #else
47
+ __weak RCTBridge *_bridge;
48
48
  RCTTouchHandler *_touchHandler;
49
49
  CGRect _reactFrame;
50
50
  #endif
@@ -61,8 +61,7 @@ namespace react = facebook::react;
61
61
  }
62
62
  return self;
63
63
  }
64
- #endif // RCT_NEW_ARCH_ENABLED
65
-
64
+ #else
66
65
  - (instancetype)initWithBridge:(RCTBridge *)bridge
67
66
  {
68
67
  if (self = [super init]) {
@@ -72,6 +71,7 @@ namespace react = facebook::react;
72
71
 
73
72
  return self;
74
73
  }
74
+ #endif // RCT_NEW_ARCH_ENABLED
75
75
 
76
76
  - (void)initCommonProps
77
77
  {
@@ -107,7 +107,12 @@ namespace react = facebook::react;
107
107
  {
108
108
  #ifdef RCT_NEW_ARCH_ENABLED
109
109
  if (_state != nullptr) {
110
- auto newState = react::RNSScreenState{RCTSizeFromCGSize(self.bounds.size)};
110
+ RNSScreenStackHeaderConfig *config = [self findHeaderConfig];
111
+ // in large title, ScrollView handles the offset of content so we cannot set it here also.
112
+ CGFloat headerHeight =
113
+ config.largeTitle ? 0 : [_controller calculateHeaderHeightIsModal:self.isPresentedAsNativeModal];
114
+ auto newState =
115
+ react::RNSScreenState{RCTSizeFromCGSize(self.bounds.size), RCTPointFromCGPoint(CGPointMake(0, headerHeight))};
111
116
  _state->updateState(std::move(newState));
112
117
  UINavigationController *navctr = _controller.navigationController;
113
118
  [navctr.view setNeedsLayout];
@@ -194,6 +199,7 @@ namespace react = facebook::react;
194
199
  case RNSScreenStackAnimationSimplePush:
195
200
  case RNSScreenStackAnimationSlideFromBottom:
196
201
  case RNSScreenStackAnimationFadeFromBottom:
202
+ case RNSScreenStackAnimationSlideFromLeft:
197
203
  // Default
198
204
  break;
199
205
  }
@@ -229,7 +235,7 @@ namespace react = facebook::react;
229
235
  }
230
236
  }
231
237
 
232
- #if !TARGET_OS_TV
238
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
233
239
  - (void)setStatusBarStyle:(RNSStatusBarStyle)statusBarStyle
234
240
  {
235
241
  _hasStatusBarStyleSet = YES;
@@ -560,13 +566,19 @@ namespace react = facebook::react;
560
566
  }
561
567
  }
562
568
 
563
- - (RNSScreenStackHeaderConfig *_Nullable)findHeaderConfig
569
+ - (nullable RNSScreenStackHeaderConfig *)findHeaderConfig
564
570
  {
571
+ // Fast path
572
+ if ([self.reactSubviews.lastObject isKindOfClass:RNSScreenStackHeaderConfig.class]) {
573
+ return (RNSScreenStackHeaderConfig *)self.reactSubviews.lastObject;
574
+ }
575
+
565
576
  for (UIView *view in self.reactSubviews) {
566
577
  if ([view isKindOfClass:RNSScreenStackHeaderConfig.class]) {
567
578
  return (RNSScreenStackHeaderConfig *)view;
568
579
  }
569
580
  }
581
+
570
582
  return nil;
571
583
  }
572
584
 
@@ -598,7 +610,7 @@ namespace react = facebook::react;
598
610
  self.controller.modalPresentationStyle == UIModalPresentationOverCurrentContext;
599
611
  }
600
612
 
601
- #if !TARGET_OS_TV
613
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
602
614
  /**
603
615
  * Updates settings for sheet presentation controller.
604
616
  * Note that this method should not be called inside `stackPresentation` setter, because on Paper we don't have
@@ -815,7 +827,7 @@ namespace react = facebook::react;
815
827
  - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask
816
828
  {
817
829
  [super finalizeUpdates:updateMask];
818
- #if !TARGET_OS_TV
830
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
819
831
  [self updatePresentationStyle];
820
832
  #endif // !TARGET_OS_TV
821
833
  }
@@ -826,7 +838,7 @@ namespace react = facebook::react;
826
838
  - (void)didSetProps:(NSArray<NSString *> *)changedProps
827
839
  {
828
840
  [super didSetProps:changedProps];
829
- #if !TARGET_OS_TV
841
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
830
842
  [self updatePresentationStyle];
831
843
  #endif // !TARGET_OS_TV
832
844
  }
@@ -1059,7 +1071,7 @@ Class<RCTComponentViewProtocol> RNSScreenCls(void)
1059
1071
 
1060
1072
  - (CGSize)getStatusBarHeightIsModal:(BOOL)isModal
1061
1073
  {
1062
- #if !TARGET_OS_TV
1074
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
1063
1075
  CGSize fallbackStatusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
1064
1076
 
1065
1077
  #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_13_0) && \
@@ -1105,17 +1117,11 @@ Class<RCTComponentViewProtocol> RNSScreenCls(void)
1105
1117
  {
1106
1118
  UINavigationController *navctr = [self getVisibleNavigationControllerIsModal:isModal];
1107
1119
 
1108
- // If navigation controller doesn't exists (or it is hidden) we want to handle two possible cases.
1109
- // If there's no navigation controller for the modal, we simply don't want to return header height, as modal possibly
1110
- // does not have header and we don't want to count status bar. If there's no navigation controller for the view we
1111
- // just want to return status bar height (if it's hidden, it will simply return 0).
1120
+ // If there's no navigation controller for the modal (or the navigation bar is hidden), we simply don't want to
1121
+ // return header height, as modal possibly does not have header when navigation controller is nil,
1122
+ // and we don't want to count status bar if navigation bar is hidden (inset could be negative).
1112
1123
  if (navctr == nil || navctr.isNavigationBarHidden) {
1113
- if (isModal) {
1114
- return 0;
1115
- } else {
1116
- CGSize statusBarSize = [self getStatusBarHeightIsModal:isModal];
1117
- return MIN(statusBarSize.width, statusBarSize.height);
1118
- }
1124
+ return 0;
1119
1125
  }
1120
1126
 
1121
1127
  CGFloat navbarHeight = navctr.navigationBar.frame.size.height;
@@ -1220,15 +1226,28 @@ Class<RCTComponentViewProtocol> RNSScreenCls(void)
1220
1226
  UIViewController *lastViewController = [[self childViewControllers] lastObject];
1221
1227
  if ([self.presentedViewController isKindOfClass:[RNSScreen class]]) {
1222
1228
  lastViewController = self.presentedViewController;
1229
+
1230
+ if (!includingModals) {
1231
+ return nil;
1232
+ }
1233
+
1223
1234
  // we don't want to allow controlling of status bar appearance when we present non-fullScreen modal
1224
1235
  // and it is not possible if `modalPresentationCapturesStatusBarAppearance` is not set to YES, so even
1225
1236
  // if we went into a modal here and ask it, it wouldn't take any effect. For fullScreen modals, the system
1226
1237
  // asks them by itself, so we can stop traversing here.
1227
1238
  // for screen orientation, we need to start the search again from that modal
1228
- return !includingModals
1229
- ? nil
1230
- : [(RNSScreen *)lastViewController findChildVCForConfigAndTrait:trait includingModals:includingModals]
1231
- ?: lastViewController;
1239
+ UIViewController *modalOrChild = [(RNSScreen *)lastViewController findChildVCForConfigAndTrait:trait
1240
+ includingModals:includingModals];
1241
+ if (modalOrChild != nil) {
1242
+ return modalOrChild;
1243
+ }
1244
+
1245
+ // if searched VC was not found, we don't want to search for configs of child VCs any longer,
1246
+ // and we don't want to rely on lastViewController.
1247
+ // That's because the modal did not find a child VC that has an orientation set,
1248
+ // and it doesn't itself have an orientation set. Hence, we fallback to the standard behavior.
1249
+ // Please keep in mind that this behavior might be wrong and could lead to undiscovered bugs.
1250
+ // For more information, see https://github.com/software-mansion/react-native-screens/pull/2008.
1232
1251
  }
1233
1252
 
1234
1253
  UIViewController *selfOrNil = [self hasTraitSet:trait] ? self : nil;
@@ -1486,7 +1505,7 @@ RCT_EXPORT_VIEW_PROPERTY(sheetCornerRadius, CGFloat);
1486
1505
  RCT_EXPORT_VIEW_PROPERTY(sheetExpandsWhenScrolledToEdge, BOOL);
1487
1506
  #endif
1488
1507
 
1489
- #if !TARGET_OS_TV
1508
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
1490
1509
  // See:
1491
1510
  // 1. https://github.com/software-mansion/react-native-screens/pull/1543
1492
1511
  // 2. https://github.com/software-mansion/react-native-screens/pull/1596
@@ -1509,10 +1528,13 @@ RCT_EXPORT_VIEW_PROPERTY(sheetExpandsWhenScrolledToEdge, BOOL);
1509
1528
  }
1510
1529
  #endif // !TARGET_OS_TV
1511
1530
 
1531
+ #ifdef RCT_NEW_ARCH_ENABLED
1532
+ #else
1512
1533
  - (UIView *)view
1513
1534
  {
1514
1535
  return [[RNSScreenView alloc] initWithBridge:self.bridge];
1515
1536
  }
1537
+ #endif
1516
1538
 
1517
1539
  + (BOOL)requiresMainQueueSetup
1518
1540
  {
@@ -1551,7 +1573,7 @@ RCT_ENUM_CONVERTER(
1551
1573
  @"simple_push" : @(RNSScreenStackAnimationSimplePush),
1552
1574
  @"slide_from_bottom" : @(RNSScreenStackAnimationSlideFromBottom),
1553
1575
  @"slide_from_right" : @(RNSScreenStackAnimationDefault),
1554
- @"slide_from_left" : @(RNSScreenStackAnimationDefault),
1576
+ @"slide_from_left" : @(RNSScreenStackAnimationSlideFromLeft),
1555
1577
  @"ios" : @(RNSScreenStackAnimationDefault),
1556
1578
  }),
1557
1579
  RNSScreenStackAnimationDefault,
@@ -22,6 +22,12 @@ NS_ASSUME_NONNULL_BEGIN
22
22
 
23
23
  - (void)markChildUpdated;
24
24
  - (void)didUpdateChildren;
25
+ - (void)startScreenTransition;
26
+ - (void)updateScreenTransition:(double)progress;
27
+ - (void)finishScreenTransition:(BOOL)canceled;
28
+
29
+ @property (nonatomic) BOOL customAnimation;
30
+ @property (nonatomic) BOOL disableSwipeBack;
25
31
 
26
32
  #ifdef RCT_NEW_ARCH_ENABLED
27
33
  #else
@@ -92,7 +92,7 @@ namespace react = facebook::react;
92
92
 
93
93
  @end
94
94
 
95
- #if !TARGET_OS_TV
95
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
96
96
  @interface RNSScreenEdgeGestureRecognizer : UIScreenEdgePanGestureRecognizer
97
97
  @end
98
98
 
@@ -150,7 +150,7 @@ namespace react = facebook::react;
150
150
  _presentedModals = [NSMutableArray new];
151
151
  _controller = [RNSNavigationController new];
152
152
  _controller.delegate = self;
153
- #if !TARGET_OS_TV
153
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
154
154
  [self setupGestureHandlers];
155
155
  #endif
156
156
  // we have to initialize viewControllers with a non empty array for
@@ -501,15 +501,27 @@ namespace react = facebook::react;
501
501
  }
502
502
  }
503
503
 
504
- // changeRootController does not have presentedViewController but it does not mean that no modals are in presentation,
505
- // so we need to find top-level controller manually
504
+ // changeRootController does not have presentedViewController but it does not mean that no modals are in presentation;
505
+ // modals could be presented by another stack (nested / outer), third-party view controller or they could be using
506
+ // UIModalPresentationCurrentContext / UIModalPresentationOverCurrentContext presentation styles; in the last case
507
+ // for some reason system asks top-level (react root) vc to present instead of our stack, despite the fact that
508
+ // `definesPresentationContext` returns `YES` for UINavigationController.
509
+ // So we first need to find top-level controller manually:
506
510
  UIViewController *reactRootVc = [self findReactRootViewController];
507
511
  UIViewController *topMostVc = [RNSScreenStackView findTopMostPresentedViewControllerFromViewController:reactRootVc];
508
512
 
509
513
  if (topMostVc != reactRootVc) {
510
514
  changeRootController = topMostVc;
515
+
516
+ // Here we handle just the simplest case where the top level VC was dismissed. In any more complex
517
+ // scenario we will still have problems, see: https://github.com/software-mansion/react-native-screens/issues/1813
518
+ if ([_presentedModals containsObject:topMostVc] && ![controllers containsObject:topMostVc]) {
519
+ [changeRootController dismissViewControllerAnimated:YES completion:finish];
520
+ return;
521
+ }
511
522
  }
512
523
 
524
+ // We didn't detect any controllers for dismissal, thus we start presenting new VCs
513
525
  finish();
514
526
  }
515
527
 
@@ -634,6 +646,22 @@ namespace react = facebook::react;
634
646
  {
635
647
  [super layoutSubviews];
636
648
  _controller.view.frame = self.bounds;
649
+
650
+ // We need to update the bounds of the modal views here, since
651
+ // for contained modals they are not updated by modals themselves.
652
+ for (UIViewController *modal in _presentedModals) {
653
+ // Because `layoutSubviews` method is also called on grabbing the modal,
654
+ // we don't want to update the frame when modal is being dismissed.
655
+ // We also want to get the frame in correct position. In the best case, it
656
+ // should be modal's superview (UITransitionView), which frame is being changed correctly.
657
+ // Otherwise, when superview is nil, we will fallback to the bounds of the ScreenStack.
658
+ BOOL isModalBeingDismissed = [modal isKindOfClass:[RNSScreen class]] && ((RNSScreen *)modal).isBeingDismissed;
659
+ CGRect correctFrame = modal.view.superview != nil ? modal.view.superview.frame : self.bounds;
660
+
661
+ if (!CGRectEqualToRect(modal.view.frame, correctFrame) && !isModalBeingDismissed) {
662
+ modal.view.frame = correctFrame;
663
+ }
664
+ }
637
665
  }
638
666
 
639
667
  - (void)dismissOnReload
@@ -669,7 +697,7 @@ namespace react = facebook::react;
669
697
  // Also, we need to return the animator when full width swiping even if the animation is not custom,
670
698
  // otherwise the screen will be just popped immediately due to no animation
671
699
  ((operation == UINavigationControllerOperationPop && shouldCancelDismiss) || _isFullWidthSwiping ||
672
- [RNSScreenStackAnimator isCustomAnimation:screen.stackAnimation])) {
700
+ [RNSScreenStackAnimator isCustomAnimation:screen.stackAnimation] || _customAnimation)) {
673
701
  return [[RNSScreenStackAnimator alloc] initWithOperation:operation];
674
702
  }
675
703
  return nil;
@@ -698,9 +726,12 @@ namespace react = facebook::react;
698
726
 
699
727
  - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
700
728
  {
729
+ if (_disableSwipeBack) {
730
+ return NO;
731
+ }
701
732
  RNSScreenView *topScreen = _reactSubviews.lastObject;
702
733
 
703
- #if TARGET_OS_TV
734
+ #if TARGET_OS_TV || TARGET_OS_VISION
704
735
  [self cancelTouchesInParent];
705
736
  return YES;
706
737
  #else
@@ -718,12 +749,14 @@ namespace react = facebook::react;
718
749
  // Now we're dealing with RNSScreenEdgeGestureRecognizer (or _UIParallaxTransitionPanGestureRecognizer)
719
750
  if (topScreen.customAnimationOnSwipe && [RNSScreenStackAnimator isCustomAnimation:topScreen.stackAnimation]) {
720
751
  if ([gestureRecognizer isKindOfClass:[RNSScreenEdgeGestureRecognizer class]]) {
752
+ UIRectEdge edges = ((RNSScreenEdgeGestureRecognizer *)gestureRecognizer).edges;
753
+ BOOL isRTL = _controller.view.semanticContentAttribute == UISemanticContentAttributeForceRightToLeft;
754
+ BOOL isSlideFromLeft = topScreen.stackAnimation == RNSScreenStackAnimationSlideFromLeft;
721
755
  // if we do not set any explicit `semanticContentAttribute`, it is `UISemanticContentAttributeUnspecified` instead
722
756
  // of `UISemanticContentAttributeForceLeftToRight`, so we just check if it is RTL or not
723
- BOOL isCorrectEdge = (_controller.view.semanticContentAttribute == UISemanticContentAttributeForceRightToLeft &&
724
- ((RNSScreenEdgeGestureRecognizer *)gestureRecognizer).edges == UIRectEdgeRight) ||
725
- (_controller.view.semanticContentAttribute != UISemanticContentAttributeForceRightToLeft &&
726
- ((RNSScreenEdgeGestureRecognizer *)gestureRecognizer).edges == UIRectEdgeLeft);
757
+ BOOL isCorrectEdge = (isRTL && edges == UIRectEdgeRight) ||
758
+ (!isRTL && isSlideFromLeft && edges == UIRectEdgeRight) ||
759
+ (isRTL && isSlideFromLeft && edges == UIRectEdgeLeft) || (!isRTL && edges == UIRectEdgeLeft);
727
760
  if (isCorrectEdge) {
728
761
  [self cancelTouchesInParent];
729
762
  return YES;
@@ -743,7 +776,7 @@ namespace react = facebook::react;
743
776
  #endif // TARGET_OS_TV
744
777
  }
745
778
 
746
- #if !TARGET_OS_TV
779
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
747
780
  - (void)setupGestureHandlers
748
781
  {
749
782
  // gesture recognizers for custom stack animations
@@ -787,7 +820,10 @@ namespace react = facebook::react;
787
820
  }
788
821
  }
789
822
 
823
+ bool isInverted = topScreen.stackAnimation == RNSScreenStackAnimationSlideFromLeft;
824
+
790
825
  float transitionProgress = (translation / distance);
826
+ transitionProgress = isInverted ? transitionProgress * -1 : transitionProgress;
791
827
 
792
828
  switch (gestureRecognizer.state) {
793
829
  case UIGestureRecognizerStateBegan: {
@@ -809,7 +845,10 @@ namespace react = facebook::react;
809
845
  case UIGestureRecognizerStateEnded: {
810
846
  // values taken from
811
847
  // https://github.com/react-navigation/react-navigation/blob/54739828598d7072c1bf7b369659e3682db3edc5/packages/stack/src/views/Stack/Card.tsx#L316
812
- BOOL shouldFinishTransition = (translation + velocity * 0.3) > (distance / 2);
848
+ float snapPoint = distance / 2;
849
+ float gestureDistance = translation + velocity * 0.3;
850
+ gestureDistance = isInverted ? gestureDistance * -1 : gestureDistance;
851
+ BOOL shouldFinishTransition = gestureDistance > snapPoint;
813
852
  if (shouldFinishTransition) {
814
853
  [_interactionController finishInteractiveTransition];
815
854
  } else {
@@ -908,8 +947,8 @@ namespace react = facebook::react;
908
947
  - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
909
948
  {
910
949
  if (CGRectContainsPoint(_controller.navigationBar.frame, point)) {
911
- // headerConfig should be the first subview of the topmost screen
912
- UIView *headerConfig = [[_reactSubviews.lastObject reactSubviews] firstObject];
950
+ RNSScreenView *topMostScreen = (RNSScreenView *)_reactSubviews.lastObject;
951
+ UIView *headerConfig = topMostScreen.findHeaderConfig;
913
952
  if ([headerConfig isKindOfClass:[RNSScreenStackHeaderConfig class]]) {
914
953
  UIView *headerHitTestResult = [headerConfig hitTest:point withEvent:event];
915
954
  if (headerHitTestResult != nil) {
@@ -920,7 +959,7 @@ namespace react = facebook::react;
920
959
  return [super hitTest:point withEvent:event];
921
960
  }
922
961
 
923
- #if !TARGET_OS_TV
962
+ #if !TARGET_OS_TV && !TARGET_OS_VISION
924
963
 
925
964
  - (BOOL)isScrollViewPanGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
926
965
  {
@@ -1021,6 +1060,33 @@ namespace react = facebook::react;
1021
1060
  });
1022
1061
  }
1023
1062
 
1063
+ - (void)startScreenTransition
1064
+ {
1065
+ if (_interactionController == nil) {
1066
+ _customAnimation = YES;
1067
+ _interactionController = [UIPercentDrivenInteractiveTransition new];
1068
+ [_controller popViewControllerAnimated:YES];
1069
+ }
1070
+ }
1071
+
1072
+ - (void)updateScreenTransition:(double)progress
1073
+ {
1074
+ [_interactionController updateInteractiveTransition:progress];
1075
+ }
1076
+
1077
+ - (void)finishScreenTransition:(BOOL)canceled
1078
+ {
1079
+ _customAnimation = NO;
1080
+ if (canceled) {
1081
+ [_interactionController updateInteractiveTransition:0.0];
1082
+ [_interactionController cancelInteractiveTransition];
1083
+ } else {
1084
+ [_interactionController updateInteractiveTransition:1.0];
1085
+ [_interactionController finishInteractiveTransition];
1086
+ }
1087
+ _interactionController = nil;
1088
+ }
1089
+
1024
1090
  #ifdef RCT_NEW_ARCH_ENABLED
1025
1091
  #pragma mark - Fabric specific
1026
1092