diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index 88e6369c26..417ccdab3e 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -34,9 +34,9 @@ @interface RNSScreenView () @implementation RNSScreenView { __weak RCTBridge *_bridge; #ifdef RN_FABRIC_ENABLED -// we recreate the behavior of `reactSetFrame` on new architecture - facebook::react::LayoutMetrics _oldLayoutMetrics; - facebook::react::LayoutMetrics _newLayoutMetrics; + // we recreate the behavior of `reactSetFrame` on new architecture + facebook::react::LayoutMetrics _oldLayoutMetrics; + facebook::react::LayoutMetrics _newLayoutMetrics; RCTSurfaceTouchHandler *_touchHandler; facebook::react::RNSScreenShadowNode::ConcreteState::Shared _state; #else @@ -291,7 +291,7 @@ - (void)notifyWillAppear std::dynamic_pointer_cast(_eventEmitter) ->onWillAppear(facebook::react::RNSScreenEventEmitter::OnWillAppear{}); } - [self updateLayoutMetrics:_layoutMetrics oldLayoutMetrics:_oldLayoutMetrics]; + [self updateLayoutMetrics:_layoutMetrics oldLayoutMetrics:_oldLayoutMetrics]; #else if (self.onWillAppear) { self.onWillAppear(nil); @@ -527,23 +527,23 @@ - (void)updateState:(facebook::react::State::Shared const &)state _state = std::static_pointer_cast(state); } - - (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics - oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics - { - _layoutMetrics = layoutMetrics; - _oldLayoutMetrics = oldLayoutMetrics; - UIViewController *parentVC = self.reactViewController.parentViewController; - if (parentVC != nil && ![parentVC isKindOfClass:[RNScreensNavigationController class]]) { - [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics]; - } - // when screen is mounted under RNScreensNavigationController it's size is controller - // by the navigation controller itself. That is, it is set to fill space of - // the controller. In that case we ignore react layout system from managing - // the screen dimensions and we wait for the screen VC to update and then we - // pass the dimensions to ui view manager to take into account when laying out - // subviews - // Explanation taken from `reactSetFrame`, which is old arch equivalent of this code. - } +- (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics + oldLayoutMetrics:(const facebook::react::LayoutMetrics &)oldLayoutMetrics +{ + _layoutMetrics = layoutMetrics; + _oldLayoutMetrics = oldLayoutMetrics; + UIViewController *parentVC = self.reactViewController.parentViewController; + if (parentVC != nil && ![parentVC isKindOfClass:[RNScreensNavigationController class]]) { + [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics]; + } + // when screen is mounted under RNScreensNavigationController it's size is controller + // by the navigation controller itself. That is, it is set to fill space of + // the controller. In that case we ignore react layout system from managing + // the screen dimensions and we wait for the screen VC to update and then we + // pass the dimensions to ui view manager to take into account when laying out + // subviews + // Explanation taken from `reactSetFrame`, which is old arch equivalent of this code. +} #pragma mark - Paper specific #else @@ -672,7 +672,7 @@ - (void)viewWillAppear:(BOOL)animated [super viewWillAppear:animated]; if (!_isSwiping) { #ifdef RN_FABRIC_ENABLED - [_initialView notifyWillAppear]; + [_initialView notifyWillAppear]; #else [((RNSScreenView *)self.view) notifyWillAppear]; #endif @@ -725,7 +725,7 @@ - (void)viewWillDisappear:(BOOL)animated // same flow as in viewWillAppear if (!_isSwiping) { #ifdef RN_FABRIC_ENABLED - [_initialView notifyWillDisappear]; + [_initialView notifyWillDisappear]; #else [((RNSScreenView *)self.view) notifyWillDisappear]; #endif @@ -753,9 +753,8 @@ - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (!_isSwiping || _shouldNotify) { - #ifdef RN_FABRIC_ENABLED - [_initialView notifyAppear]; + [_initialView notifyAppear]; #else // we are going forward or dismissing without swipe // or successfully swiped back @@ -792,7 +791,7 @@ - (void)viewDidDisappear:(BOOL)animated // same flow as in viewDidAppear if (!_isSwiping || _shouldNotify) { #ifdef RN_FABRIC_ENABLED - [_initialView notifyDisappear]; + [_initialView notifyDisappear]; #else [((RNSScreenView *)self.view) notifyDisappear]; [self notifyTransitionProgress:1.0 closing:YES goingForward:_goingForward];