diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index a432b151a8..8854ec2560 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -28,8 +28,10 @@ #import #import #import +#import #import "RNSConversions.h" +#import "RNSReactNativeVersionUtils.h" #import "RNSSafeAreaViewNotifications.h" #import "RNSScreenFooter.h" #import "RNSScreenStack.h" @@ -936,16 +938,23 @@ - (BOOL)isTransparentModal - (void)invalidateImpl { - _controller = nil; - [_sheetsScrollView removeObserver:self forKeyPath:@"bounds" context:nil]; + // We want to run after container updates are performed (transitions etc.) + __weak auto weakSelf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + auto strongSelf = weakSelf; + if (strongSelf) { + strongSelf->_controller = nil; + [strongSelf->_sheetsScrollView removeObserver:self forKeyPath:@"bounds" context:nil]; + } + }); } -#ifndef RCT_NEW_ARCH_ENABLED +#if !RCT_NEW_ARCH_ENABLED - (void)invalidate { [self invalidateImpl]; } -#endif +#endif // !RCT_NEW_ARCH_ENABLED #if !TARGET_OS_TV && !TARGET_OS_VISION @@ -1509,6 +1518,15 @@ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask #endif // !TARGET_OS_TV && !TARGET_OS_VISION } +#if REACT_NATIVE_VERSION_MINOR >= 82 +- (void)invalidate +{ + if (!facebook::react::is082PrereleaseOrLower()) { + [self invalidateImpl]; + } +} +#endif // REACT_NATIVE_VERSION_MINOR >= 82 + #pragma mark - Paper specific #else diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index 6d4edacc02..76ce967247 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -20,8 +20,10 @@ #import "RCTTouchHandler+RNSUtility.h" #endif // RCT_NEW_ARCH_ENABLED +#import #import "RNSDefines.h" #import "RNSPercentDrivenInteractiveTransition.h" +#import "RNSReactNativeVersionUtils.h" #import "RNSScreen.h" #import "RNSScreenStack.h" #import "RNSScreenStackAnimator.h" @@ -210,13 +212,13 @@ @implementation RNSScreenStackView { RNSPercentDrivenInteractiveTransition *_interactionController; __weak RNSScreenStackManager *_manager; BOOL _updateScheduled; -#ifdef RCT_NEW_ARCH_ENABLED +#if RCT_NEW_ARCH_ENABLED && REACT_NATIVE_VERSION_MINOR <= 82 /// Screens that are subject of `ShadowViewMutation::Type::Delete` mutation /// in current transaction. This vector should be populated when we receive notification via /// `RCTMountingObserving` protocol, that a transaction will be performed, and should /// be cleaned up when we're notified that the transaction has been completed. std::vector<__strong RNSScreenView *> _toBeDeletedScreens; -#endif // RCT_NEW_ARCH_ENABLED +#endif // RCT_NEW_ARCH_ENABLED && REACT_NATIVE_VERSION_MINOR <= 82 } #ifdef RCT_NEW_ARCH_ENABLED @@ -1369,15 +1371,19 @@ - (void)unmountChildComponentView:(UIView *)childCompo - (void)mountingTransactionWillMount:(const facebook::react::MountingTransaction &)transaction withSurfaceTelemetry:(const facebook::react::SurfaceTelemetry &)surfaceTelemetry { - for (const auto &mutation : transaction.getMutations()) { - if (mutation.type == react::ShadowViewMutation::Delete) { - RNSScreenView *_Nullable toBeRemovedChild = [self childScreenForTag:mutation.oldChildShadowView.tag]; - if (toBeRemovedChild != nil) { - [toBeRemovedChild willBeUnmountedInUpcomingTransaction]; - _toBeDeletedScreens.push_back(toBeRemovedChild); +#if REACT_NATIVE_VERSION_MINOR <= 82 + if (facebook::react::is082PrereleaseOrLower()) { + for (const auto &mutation : transaction.getMutations()) { + if (mutation.type == react::ShadowViewMutation::Delete) { + RNSScreenView *_Nullable toBeRemovedChild = [self childScreenForTag:mutation.oldChildShadowView.tag]; + if (toBeRemovedChild != nil) { + [toBeRemovedChild willBeUnmountedInUpcomingTransaction]; + _toBeDeletedScreens.push_back(toBeRemovedChild); + } } } } +#endif // REACT_NATIVE_VERSION_MINOR <= 82 } - (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction &)transaction @@ -1400,24 +1406,28 @@ - (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction } } - if (!self->_toBeDeletedScreens.empty()) { - __weak RNSScreenStackView *weakSelf = self; - // We want to run after container updates are performed (transitions etc.) - dispatch_async(dispatch_get_main_queue(), ^{ - RNSScreenStackView *_Nullable strongSelf = weakSelf; - if (strongSelf == nil) { - return; - } - for (RNSScreenView *screenRef : strongSelf->_toBeDeletedScreens) { -#ifdef RCT_NEW_ARCH_ENABLED - [screenRef invalidateImpl]; -#else - [screenRef invalidate]; -#endif - } - strongSelf->_toBeDeletedScreens.clear(); - }); +#if REACT_NATIVE_VERSION_MINOR <= 82 + if (facebook::react::is082PrereleaseOrLower()) { + if (!self->_toBeDeletedScreens.empty()) { + __weak RNSScreenStackView *weakSelf = self; + // We want to run after container updates are performed (transitions etc.) + dispatch_async(dispatch_get_main_queue(), ^{ + RNSScreenStackView *_Nullable strongSelf = weakSelf; + if (strongSelf == nil) { + return; + } + for (RNSScreenView *screenRef : strongSelf->_toBeDeletedScreens) { +#if RCT_NEW_ARCH_ENABLED + [screenRef invalidateImpl]; +#else // RCT_NEW_ARCH_ENABLED + [screenRef invalidate]; +#endif // RCT_NEW_ARCH_ENABLED + } + strongSelf->_toBeDeletedScreens.clear(); + }); + } } +#endif // REACT_NATIVE_VERSION_MINOR <= 82 } - (void)prepareForRecycle diff --git a/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h b/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h index c8d4fb0552..e0d4227b2e 100644 --- a/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h +++ b/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h @@ -14,7 +14,7 @@ #if REACT_NATIVE_VERSION_MINOR <= 82 #import "RNSViewControllerInvalidating.h" #endif // REACT_NATIVE_VERSION_MINOR <= 82 -#else // RCT_NEW_ARCH_ENABLED +#else // RCT_NEW_ARCH_ENABLED #import #endif // RCT_NEW_ARCH_ENABLED