react-native-screens 4.0.0-beta.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/README.md +9 -2
  2. package/android/CMakeLists.txt +28 -19
  3. package/android/src/main/java/com/swmansion/rnscreens/CustomToolbar.kt +13 -3
  4. package/android/src/main/java/com/swmansion/rnscreens/InsetsObserverProxy.kt +2 -4
  5. package/android/src/main/java/com/swmansion/rnscreens/NativeDismissalObserver.kt +12 -0
  6. package/android/src/main/java/com/swmansion/rnscreens/Screen.kt +11 -4
  7. package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +24 -6
  8. package/android/src/main/java/com/swmansion/rnscreens/ScreenStackFragment.kt +64 -68
  9. package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +1 -0
  10. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/BottomSheetBehaviorExt.kt +42 -0
  11. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/DimmingFragment.kt +24 -19
  12. package/android/src/main/java/com/swmansion/rnscreens/bottomsheet/SheetUtils.kt +8 -0
  13. package/android/src/main/java/com/swmansion/rnscreens/ext/ViewExt.kt +24 -0
  14. package/android/src/main/jni/CMakeLists.txt +28 -19
  15. package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerDelegate.java +2 -2
  16. package/ios/RNSConvert.h +13 -4
  17. package/ios/RNSConvert.mm +50 -28
  18. package/ios/RNSEnums.h +47 -0
  19. package/ios/RNSPercentDrivenInteractiveTransition.h +12 -0
  20. package/ios/RNSPercentDrivenInteractiveTransition.mm +69 -0
  21. package/ios/RNSScreen.h +14 -0
  22. package/ios/RNSScreen.mm +30 -5
  23. package/ios/RNSScreenStack.mm +74 -9
  24. package/ios/RNSScreenStackAnimator.h +13 -1
  25. package/ios/RNSScreenStackAnimator.mm +233 -130
  26. package/ios/RNSScreenStackHeaderConfig.h +1 -1
  27. package/ios/RNSScreenStackHeaderConfig.mm +39 -29
  28. package/lib/commonjs/components/DebugContainer.js +40 -0
  29. package/lib/commonjs/components/DebugContainer.js.map +1 -0
  30. package/lib/commonjs/components/DebugContainer.web.js +15 -0
  31. package/lib/commonjs/components/DebugContainer.web.js.map +1 -0
  32. package/lib/commonjs/components/FullWindowOverlay.js +8 -5
  33. package/lib/commonjs/components/FullWindowOverlay.js.map +1 -1
  34. package/lib/commonjs/components/Screen.js +35 -10
  35. package/lib/commonjs/components/Screen.js.map +1 -1
  36. package/lib/commonjs/components/ScreenContainer.js +3 -5
  37. package/lib/commonjs/components/ScreenContainer.js.map +1 -1
  38. package/lib/commonjs/components/ScreenContainer.web.js +3 -4
  39. package/lib/commonjs/components/ScreenContainer.web.js.map +1 -1
  40. package/lib/commonjs/components/ScreenContentWrapper.js +2 -4
  41. package/lib/commonjs/components/ScreenContentWrapper.js.map +1 -1
  42. package/lib/commonjs/components/ScreenContentWrapper.web.js +1 -2
  43. package/lib/commonjs/components/ScreenContentWrapper.web.js.map +1 -1
  44. package/lib/commonjs/components/ScreenFooter.js +2 -8
  45. package/lib/commonjs/components/ScreenFooter.js.map +1 -1
  46. package/lib/commonjs/components/ScreenFooter.web.js +1 -2
  47. package/lib/commonjs/components/ScreenFooter.web.js.map +1 -1
  48. package/lib/commonjs/components/ScreenStack.js +47 -9
  49. package/lib/commonjs/components/ScreenStack.js.map +1 -1
  50. package/lib/commonjs/components/ScreenStack.web.js +2 -1
  51. package/lib/commonjs/components/ScreenStack.web.js.map +1 -1
  52. package/lib/commonjs/components/ScreenStackHeaderConfig.js +14 -10
  53. package/lib/commonjs/components/ScreenStackHeaderConfig.js.map +1 -1
  54. package/lib/commonjs/components/ScreenStackItem.js +99 -0
  55. package/lib/commonjs/components/ScreenStackItem.js.map +1 -0
  56. package/lib/commonjs/components/SearchBar.js +5 -5
  57. package/lib/commonjs/components/SearchBar.js.map +1 -1
  58. package/lib/commonjs/components/SearchBar.web.js +3 -4
  59. package/lib/commonjs/components/SearchBar.web.js.map +1 -1
  60. package/lib/commonjs/components/helpers/usePrevious.js +15 -0
  61. package/lib/commonjs/components/helpers/usePrevious.js.map +1 -0
  62. package/lib/commonjs/contexts.js +11 -0
  63. package/lib/commonjs/contexts.js.map +1 -0
  64. package/lib/commonjs/core.js +0 -3
  65. package/lib/commonjs/core.js.map +1 -1
  66. package/lib/commonjs/fabric/ModalScreenNativeComponent.js.map +1 -1
  67. package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  68. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js +2 -2
  69. package/lib/commonjs/gesture-handler/GestureDetectorProvider.js.map +1 -1
  70. package/lib/commonjs/gesture-handler/ScreenGestureDetector.js +3 -3
  71. package/lib/commonjs/gesture-handler/ScreenGestureDetector.js.map +1 -1
  72. package/lib/commonjs/gesture-handler/fabricUtils.js +54 -18
  73. package/lib/commonjs/gesture-handler/fabricUtils.js.map +1 -1
  74. package/lib/commonjs/index.js +23 -86
  75. package/lib/commonjs/index.js.map +1 -1
  76. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js +4 -0
  77. package/lib/commonjs/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  78. package/lib/commonjs/native-stack/views/FooterComponent.js +2 -2
  79. package/lib/commonjs/native-stack/views/FooterComponent.js.map +1 -1
  80. package/lib/commonjs/native-stack/views/HeaderConfig.js +10 -8
  81. package/lib/commonjs/native-stack/views/HeaderConfig.js.map +1 -1
  82. package/lib/commonjs/native-stack/views/NativeStackView.js +34 -39
  83. package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
  84. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +2 -2
  85. package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  86. package/lib/commonjs/reanimated/ReanimatedScreen.js +2 -2
  87. package/lib/commonjs/reanimated/ReanimatedScreen.js.map +1 -1
  88. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js +2 -2
  89. package/lib/commonjs/reanimated/ReanimatedScreenProvider.js.map +1 -1
  90. package/lib/commonjs/utils.js +28 -6
  91. package/lib/commonjs/utils.js.map +1 -1
  92. package/lib/module/components/DebugContainer.js +31 -0
  93. package/lib/module/components/DebugContainer.js.map +1 -0
  94. package/lib/module/components/DebugContainer.web.js +6 -0
  95. package/lib/module/components/DebugContainer.web.js.map +1 -0
  96. package/lib/module/components/FullWindowOverlay.js +9 -6
  97. package/lib/module/components/FullWindowOverlay.js.map +1 -1
  98. package/lib/module/components/Screen.js +34 -9
  99. package/lib/module/components/Screen.js.map +1 -1
  100. package/lib/module/components/ScreenContainer.js +2 -4
  101. package/lib/module/components/ScreenContainer.js.map +1 -1
  102. package/lib/module/components/ScreenContainer.web.js +2 -3
  103. package/lib/module/components/ScreenContainer.web.js.map +1 -1
  104. package/lib/module/components/ScreenContentWrapper.js +1 -3
  105. package/lib/module/components/ScreenContentWrapper.js.map +1 -1
  106. package/lib/module/components/ScreenContentWrapper.web.js +0 -1
  107. package/lib/module/components/ScreenContentWrapper.web.js.map +1 -1
  108. package/lib/module/components/ScreenFooter.js +1 -7
  109. package/lib/module/components/ScreenFooter.js.map +1 -1
  110. package/lib/module/components/ScreenFooter.web.js +0 -1
  111. package/lib/module/components/ScreenFooter.web.js.map +1 -1
  112. package/lib/module/components/ScreenStack.js +46 -8
  113. package/lib/module/components/ScreenStack.js.map +1 -1
  114. package/lib/module/components/ScreenStack.web.js +2 -1
  115. package/lib/module/components/ScreenStack.web.js.map +1 -1
  116. package/lib/module/components/ScreenStackHeaderConfig.js +14 -8
  117. package/lib/module/components/ScreenStackHeaderConfig.js.map +1 -1
  118. package/lib/module/components/ScreenStackItem.js +90 -0
  119. package/lib/module/components/ScreenStackItem.js.map +1 -0
  120. package/lib/module/components/SearchBar.js +3 -3
  121. package/lib/module/components/SearchBar.js.map +1 -1
  122. package/lib/module/components/SearchBar.web.js +2 -3
  123. package/lib/module/components/SearchBar.web.js.map +1 -1
  124. package/lib/module/components/helpers/usePrevious.js +9 -0
  125. package/lib/module/components/helpers/usePrevious.js.map +1 -0
  126. package/lib/module/contexts.js +4 -0
  127. package/lib/module/contexts.js.map +1 -0
  128. package/lib/module/core.js +0 -3
  129. package/lib/module/core.js.map +1 -1
  130. package/lib/module/fabric/ModalScreenNativeComponent.js.map +1 -1
  131. package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
  132. package/lib/module/gesture-handler/GestureDetectorProvider.js +1 -1
  133. package/lib/module/gesture-handler/GestureDetectorProvider.js.map +1 -1
  134. package/lib/module/gesture-handler/ScreenGestureDetector.js +3 -3
  135. package/lib/module/gesture-handler/ScreenGestureDetector.js.map +1 -1
  136. package/lib/module/gesture-handler/fabricUtils.js +55 -17
  137. package/lib/module/gesture-handler/fabricUtils.js.map +1 -1
  138. package/lib/module/index.js +12 -18
  139. package/lib/module/index.js.map +1 -1
  140. package/lib/module/native-stack/navigators/createNativeStackNavigator.js +4 -0
  141. package/lib/module/native-stack/navigators/createNativeStackNavigator.js.map +1 -1
  142. package/lib/module/native-stack/views/FooterComponent.js +1 -1
  143. package/lib/module/native-stack/views/FooterComponent.js.map +1 -1
  144. package/lib/module/native-stack/views/HeaderConfig.js +3 -1
  145. package/lib/module/native-stack/views/HeaderConfig.js.map +1 -1
  146. package/lib/module/native-stack/views/NativeStackView.js +28 -33
  147. package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
  148. package/lib/module/reanimated/ReanimatedNativeStackScreen.js +1 -2
  149. package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
  150. package/lib/module/reanimated/ReanimatedScreen.js +1 -2
  151. package/lib/module/reanimated/ReanimatedScreen.js.map +1 -1
  152. package/lib/module/reanimated/ReanimatedScreenProvider.js +1 -1
  153. package/lib/module/reanimated/ReanimatedScreenProvider.js.map +1 -1
  154. package/lib/module/utils.js +26 -5
  155. package/lib/module/utils.js.map +1 -1
  156. package/lib/typescript/components/DebugContainer.d.ts +15 -0
  157. package/lib/typescript/components/DebugContainer.d.ts.map +1 -0
  158. package/lib/typescript/components/DebugContainer.web.d.ts +4 -0
  159. package/lib/typescript/components/DebugContainer.web.d.ts.map +1 -0
  160. package/lib/typescript/components/FullWindowOverlay.d.ts.map +1 -1
  161. package/lib/typescript/components/Screen.d.ts +2 -7
  162. package/lib/typescript/components/Screen.d.ts.map +1 -1
  163. package/lib/typescript/components/Screen.web.d.ts +1 -1
  164. package/lib/typescript/components/Screen.web.d.ts.map +1 -1
  165. package/lib/typescript/components/ScreenContainer.d.ts +1 -3
  166. package/lib/typescript/components/ScreenContainer.d.ts.map +1 -1
  167. package/lib/typescript/components/ScreenContainer.web.d.ts +2 -3
  168. package/lib/typescript/components/ScreenContainer.web.d.ts.map +1 -1
  169. package/lib/typescript/components/ScreenContentWrapper.d.ts +0 -1
  170. package/lib/typescript/components/ScreenContentWrapper.d.ts.map +1 -1
  171. package/lib/typescript/components/ScreenContentWrapper.web.d.ts +0 -1
  172. package/lib/typescript/components/ScreenContentWrapper.web.d.ts.map +1 -1
  173. package/lib/typescript/components/ScreenFooter.d.ts +0 -4
  174. package/lib/typescript/components/ScreenFooter.d.ts.map +1 -1
  175. package/lib/typescript/components/ScreenFooter.web.d.ts +0 -1
  176. package/lib/typescript/components/ScreenFooter.web.d.ts.map +1 -1
  177. package/lib/typescript/components/ScreenStack.d.ts +1 -1
  178. package/lib/typescript/components/ScreenStack.d.ts.map +1 -1
  179. package/lib/typescript/components/ScreenStack.web.d.ts +2 -1
  180. package/lib/typescript/components/ScreenStack.web.d.ts.map +1 -1
  181. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts +3 -3
  182. package/lib/typescript/components/ScreenStackHeaderConfig.d.ts.map +1 -1
  183. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts +1 -1
  184. package/lib/typescript/components/ScreenStackHeaderConfig.web.d.ts.map +1 -1
  185. package/lib/typescript/components/ScreenStackItem.d.ts +11 -0
  186. package/lib/typescript/components/ScreenStackItem.d.ts.map +1 -0
  187. package/lib/typescript/components/SearchBar.d.ts +1 -15
  188. package/lib/typescript/components/SearchBar.d.ts.map +1 -1
  189. package/lib/typescript/components/SearchBar.web.d.ts +2 -3
  190. package/lib/typescript/components/SearchBar.web.d.ts.map +1 -1
  191. package/lib/typescript/components/helpers/usePrevious.d.ts +2 -0
  192. package/lib/typescript/components/helpers/usePrevious.d.ts.map +1 -0
  193. package/lib/typescript/contexts.d.ts +5 -0
  194. package/lib/typescript/contexts.d.ts.map +1 -0
  195. package/lib/typescript/core.d.ts +0 -1
  196. package/lib/typescript/core.d.ts.map +1 -1
  197. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts +9 -3
  198. package/lib/typescript/fabric/ModalScreenNativeComponent.d.ts.map +1 -1
  199. package/lib/typescript/fabric/ScreenNativeComponent.d.ts +2 -2
  200. package/lib/typescript/fabric/ScreenNativeComponent.d.ts.map +1 -1
  201. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts +2 -2
  202. package/lib/typescript/fabric/ScreenStackHeaderConfigNativeComponent.d.ts.map +1 -1
  203. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts +1 -1
  204. package/lib/typescript/fabric/ScreenStackNativeComponent.d.ts.map +1 -1
  205. package/lib/typescript/gesture-handler/ScreenGestureDetector.d.ts +2 -2
  206. package/lib/typescript/gesture-handler/ScreenGestureDetector.d.ts.map +1 -1
  207. package/lib/typescript/gesture-handler/fabricUtils.d.ts +7 -5
  208. package/lib/typescript/gesture-handler/fabricUtils.d.ts.map +1 -1
  209. package/lib/typescript/index.d.ts +10 -16
  210. package/lib/typescript/index.d.ts.map +1 -1
  211. package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts +3 -0
  212. package/lib/typescript/native-stack/navigators/createNativeStackNavigator.d.ts.map +1 -1
  213. package/lib/typescript/native-stack/types.d.ts +58 -12
  214. package/lib/typescript/native-stack/types.d.ts.map +1 -1
  215. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -1
  216. package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts.map +1 -1
  217. package/lib/typescript/native-stack/views/HeaderConfig.d.ts.map +1 -1
  218. package/lib/typescript/native-stack/views/NativeStackView.d.ts.map +1 -1
  219. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
  220. package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts.map +1 -1
  221. package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
  222. package/lib/typescript/reanimated/ReanimatedScreen.d.ts.map +1 -1
  223. package/lib/typescript/reanimated/ReanimatedScreenProvider.d.ts.map +1 -1
  224. package/lib/typescript/types.d.ts +52 -16
  225. package/lib/typescript/types.d.ts.map +1 -1
  226. package/lib/typescript/utils.d.ts +26 -1
  227. package/lib/typescript/utils.d.ts.map +1 -1
  228. package/native-stack/README.md +5 -4
  229. package/native-stack/package.json +4 -4
  230. package/package.json +1 -1
  231. package/react-native.config.js +16 -28
  232. package/src/components/DebugContainer.tsx +47 -0
  233. package/src/components/DebugContainer.web.tsx +7 -0
  234. package/src/components/FullWindowOverlay.tsx +10 -2
  235. package/src/components/Screen.tsx +52 -24
  236. package/src/components/Screen.web.tsx +1 -1
  237. package/src/components/ScreenContainer.tsx +4 -11
  238. package/src/components/ScreenContainer.web.tsx +2 -3
  239. package/src/components/ScreenContentWrapper.tsx +2 -5
  240. package/src/components/ScreenContentWrapper.web.tsx +1 -2
  241. package/src/components/ScreenFooter.tsx +2 -8
  242. package/src/components/ScreenFooter.web.tsx +1 -2
  243. package/src/components/ScreenStack.tsx +99 -12
  244. package/src/components/ScreenStack.web.tsx +3 -1
  245. package/src/components/ScreenStackHeaderConfig.tsx +28 -13
  246. package/src/components/ScreenStackHeaderConfig.web.tsx +1 -1
  247. package/src/components/ScreenStackItem.tsx +162 -0
  248. package/src/components/SearchBar.tsx +4 -7
  249. package/src/components/SearchBar.web.tsx +2 -3
  250. package/src/components/helpers/usePrevious.tsx +11 -0
  251. package/src/contexts.tsx +9 -0
  252. package/src/core.ts +0 -3
  253. package/src/fabric/ModalScreenNativeComponent.ts +11 -3
  254. package/src/fabric/ScreenNativeComponent.ts +2 -2
  255. package/src/fabric/ScreenStackHeaderConfigNativeComponent.ts +2 -1
  256. package/src/fabric/ScreenStackNativeComponent.ts +1 -1
  257. package/src/gesture-handler/GestureDetectorProvider.tsx +2 -2
  258. package/src/gesture-handler/ScreenGestureDetector.tsx +4 -4
  259. package/src/gesture-handler/fabricUtils.ts +74 -27
  260. package/src/index.tsx +11 -37
  261. package/src/native-stack/navigators/createNativeStackNavigator.tsx +3 -0
  262. package/src/native-stack/types.tsx +60 -17
  263. package/src/native-stack/utils/getDefaultHeaderHeight.tsx +1 -1
  264. package/src/native-stack/views/FooterComponent.tsx +1 -1
  265. package/src/native-stack/views/HeaderConfig.tsx +7 -5
  266. package/src/native-stack/views/NativeStackView.tsx +48 -67
  267. package/src/reanimated/ReanimatedNativeStackScreen.tsx +2 -2
  268. package/src/reanimated/ReanimatedScreen.tsx +2 -1
  269. package/src/reanimated/ReanimatedScreenProvider.tsx +2 -1
  270. package/src/types.tsx +72 -15
  271. package/src/utils.ts +27 -5
@@ -20,6 +20,7 @@
20
20
  #import "RCTTouchHandler+RNSUtility.h"
21
21
  #endif // RCT_NEW_ARCH_ENABLED
22
22
 
23
+ #import "RNSPercentDrivenInteractiveTransition.h"
23
24
  #import "RNSScreen.h"
24
25
  #import "RNSScreenStack.h"
25
26
  #import "RNSScreenStackAnimator.h"
@@ -149,9 +150,16 @@ namespace react = facebook::react;
149
150
  NSMutableArray<RNSScreenView *> *_reactSubviews;
150
151
  BOOL _invalidated;
151
152
  BOOL _isFullWidthSwiping;
152
- UIPercentDrivenInteractiveTransition *_interactionController;
153
+ RNSPercentDrivenInteractiveTransition *_interactionController;
153
154
  __weak RNSScreenStackManager *_manager;
154
155
  BOOL _updateScheduled;
156
+ #ifdef RCT_NEW_ARCH_ENABLED
157
+ /// Screens that are subject of `ShadowViewMutation::Type::Delete` mutation
158
+ /// in current transaction. This vector should be populated when we receive notification via
159
+ /// `RCTMountingObserving` protocol, that a transaction will be performed, and should
160
+ /// be cleaned up when we're notified that the transaction has been completed.
161
+ std::vector<__strong RNSScreenView *> _toBeDeletedScreens;
162
+ #endif // RCT_NEW_ARCH_ENABLED
155
163
  }
156
164
 
157
165
  #ifdef RCT_NEW_ARCH_ENABLED
@@ -673,7 +681,7 @@ namespace react = facebook::react;
673
681
  NSMutableArray<UIViewController *> *pushControllers = [NSMutableArray new];
674
682
  NSMutableArray<UIViewController *> *modalControllers = [NSMutableArray new];
675
683
  for (RNSScreenView *screen in _reactSubviews) {
676
- if (!screen.dismissed && screen.controller != nil) {
684
+ if (!screen.dismissed && screen.controller != nil && screen.activityState != RNSActivityStateInactive) {
677
685
  if (pushControllers.count == 0) {
678
686
  // first screen on the list needs to be places as "push controller"
679
687
  [pushControllers addObject:screen.controller];
@@ -862,7 +870,7 @@ namespace react = facebook::react;
862
870
 
863
871
  switch (gestureRecognizer.state) {
864
872
  case UIGestureRecognizerStateBegan: {
865
- _interactionController = [UIPercentDrivenInteractiveTransition new];
873
+ _interactionController = [RNSPercentDrivenInteractiveTransition new];
866
874
  [_controller popViewControllerAnimated:YES];
867
875
  break;
868
876
  }
@@ -909,7 +917,7 @@ namespace react = facebook::react;
909
917
  if (_interactionController == nil && fromView.reactSuperview) {
910
918
  BOOL shouldCancelDismiss = [self shouldCancelDismissFromView:fromView toView:toView];
911
919
  if (shouldCancelDismiss) {
912
- _interactionController = [UIPercentDrivenInteractiveTransition new];
920
+ _interactionController = [RNSPercentDrivenInteractiveTransition new];
913
921
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
914
922
  [self->_interactionController cancelInteractiveTransition];
915
923
  self->_interactionController = nil;
@@ -922,6 +930,10 @@ namespace react = facebook::react;
922
930
  });
923
931
  }
924
932
  }
933
+
934
+ if (_interactionController != nil) {
935
+ [_interactionController setAnimationController:animationController];
936
+ }
925
937
  return _interactionController;
926
938
  }
927
939
 
@@ -946,7 +958,8 @@ namespace react = facebook::react;
946
958
 
947
959
  - (void)markChildUpdated
948
960
  {
949
- // do nothing
961
+ // In native stack this should be called only for `preload` purposes.
962
+ [self updateContainer];
950
963
  }
951
964
 
952
965
  - (void)didUpdateChildren
@@ -1103,7 +1116,7 @@ namespace react = facebook::react;
1103
1116
  {
1104
1117
  if (_interactionController == nil) {
1105
1118
  _customAnimation = YES;
1106
- _interactionController = [UIPercentDrivenInteractiveTransition new];
1119
+ _interactionController = [RNSPercentDrivenInteractiveTransition new];
1107
1120
  [_controller popViewControllerAnimated:YES];
1108
1121
  }
1109
1122
  }
@@ -1150,6 +1163,16 @@ namespace react = facebook::react;
1150
1163
  // `- [RNSScreenStackView mountingTransactionDidMount: withSurfaceTelemetry:]`
1151
1164
  }
1152
1165
 
1166
+ - (nullable RNSScreenView *)childScreenForTag:(react::Tag)tag
1167
+ {
1168
+ for (RNSScreenView *child in _reactSubviews) {
1169
+ if (child.tag == tag) {
1170
+ return child;
1171
+ }
1172
+ }
1173
+ return nil;
1174
+ }
1175
+
1153
1176
  - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
1154
1177
  {
1155
1178
  RNSScreenView *screenChildComponent = (RNSScreenView *)childComponentView;
@@ -1183,6 +1206,20 @@ namespace react = facebook::react;
1183
1206
  [screenChildComponent removeFromSuperview];
1184
1207
  }
1185
1208
 
1209
+ - (void)mountingTransactionWillMount:(const facebook::react::MountingTransaction &)transaction
1210
+ withSurfaceTelemetry:(const facebook::react::SurfaceTelemetry &)surfaceTelemetry
1211
+ {
1212
+ for (const auto &mutation : transaction.getMutations()) {
1213
+ if (mutation.type == react::ShadowViewMutation::Delete) {
1214
+ RNSScreenView *_Nullable toBeRemovedChild = [self childScreenForTag:mutation.oldChildShadowView.tag];
1215
+ if (toBeRemovedChild != nil) {
1216
+ [toBeRemovedChild willBeUnmountedInUpcomingTransaction];
1217
+ _toBeDeletedScreens.push_back(toBeRemovedChild);
1218
+ }
1219
+ }
1220
+ }
1221
+ }
1222
+
1186
1223
  - (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction &)transaction
1187
1224
  withSurfaceTelemetry:(const facebook::react::SurfaceTelemetry &)surfaceTelemetry
1188
1225
  {
@@ -1199,6 +1236,21 @@ namespace react = facebook::react;
1199
1236
  break;
1200
1237
  }
1201
1238
  }
1239
+
1240
+ if (!self->_toBeDeletedScreens.empty()) {
1241
+ __weak RNSScreenStackView *weakSelf = self;
1242
+ // We want to run after container updates are performed (transitions etc.)
1243
+ dispatch_async(dispatch_get_main_queue(), ^{
1244
+ RNSScreenStackView *_Nullable strongSelf = weakSelf;
1245
+ if (strongSelf == nil) {
1246
+ return;
1247
+ }
1248
+ for (RNSScreenView *screenRef : strongSelf->_toBeDeletedScreens) {
1249
+ [screenRef invalidate];
1250
+ }
1251
+ strongSelf->_toBeDeletedScreens.clear();
1252
+ });
1253
+ }
1202
1254
  }
1203
1255
 
1204
1256
  - (void)prepareForRecycle
@@ -1226,12 +1278,25 @@ namespace react = facebook::react;
1226
1278
  - (void)invalidate
1227
1279
  {
1228
1280
  _invalidated = YES;
1229
- for (UIViewController *controller in _presentedModals) {
1281
+ [self dismissAllRelatedModals];
1282
+ [_controller willMoveToParentViewController:nil];
1283
+ [_controller removeFromParentViewController];
1284
+ }
1285
+
1286
+ // This method aims to dismiss all modals for which presentation process
1287
+ // has been initiated in this navigation controller, i. e. either a Screen
1288
+ // with modal presentation or foreign modal presented from inside a Screen.
1289
+ - (void)dismissAllRelatedModals
1290
+ {
1291
+ [_controller dismissViewControllerAnimated:NO completion:nil];
1292
+
1293
+ // This loop seems to be excessive. Above message send to `_controller` should
1294
+ // be enough, because system dismisses the controllers recursively,
1295
+ // however better safe than sorry & introduce a regression, thus it is left here.
1296
+ for (UIViewController *controller in [_presentedModals reverseObjectEnumerator]) {
1230
1297
  [controller dismissViewControllerAnimated:NO completion:nil];
1231
1298
  }
1232
1299
  [_presentedModals removeAllObjects];
1233
- [_controller willMoveToParentViewController:nil];
1234
- [_controller removeFromParentViewController];
1235
1300
  }
1236
1301
 
1237
1302
  #endif // RCT_NEW_ARCH_ENABLED
@@ -2,7 +2,19 @@
2
2
 
3
3
  @interface RNSScreenStackAnimator : NSObject <UIViewControllerAnimatedTransitioning>
4
4
 
5
- - (instancetype)initWithOperation:(UINavigationControllerOperation)operation;
5
+ /// This property is filled whenever there is an ongoing animation and cleared on animation end.
6
+ @property (nonatomic, strong, nullable, readonly) UIViewPropertyAnimator *inFlightAnimator;
7
+
8
+ - (nonnull instancetype)initWithOperation:(UINavigationControllerOperation)operation;
9
+
10
+ /// In case of interactive / interruptible transition (e.g. swipe back gesture) this method should return
11
+ /// timing parameters expected by animator to be used for animation completion (e.g. when user's
12
+ /// gesture had ended).
13
+ ///
14
+ /// @return timing curve provider expected to be used for animation completion or nil,
15
+ /// when there is no interactive transition running.
16
+ - (nullable id<UITimingCurveProvider>)timingParamsForAnimationCompletion;
17
+
6
18
  + (BOOL)isCustomAnimation:(RNSScreenStackAnimation)animation;
7
19
 
8
20
  @end