From a6f1ef0952d9173d1834749ee4e1237635882f55 Mon Sep 17 00:00:00 2001 From: Harry Yu Date: Mon, 13 Oct 2025 15:57:30 -0700 Subject: [PATCH] Ensure modal size changes correctly when orientation changes --- .../components/multiplemodals/RNTModalViewUtils.mm | 12 +----------- .../RNTModalViewController/RNTModalViewController.h | 1 - .../RNTModalViewController/RNTModalViewController.m | 10 +--------- ios/RNTModalShadowView.m | 13 +------------ 4 files changed, 3 insertions(+), 33 deletions(-) diff --git a/common/cpp/react/renderer/components/multiplemodals/RNTModalViewUtils.mm b/common/cpp/react/renderer/components/multiplemodals/RNTModalViewUtils.mm index 9219b36..9565bbe 100644 --- a/common/cpp/react/renderer/components/multiplemodals/RNTModalViewUtils.mm +++ b/common/cpp/react/renderer/components/multiplemodals/RNTModalViewUtils.mm @@ -9,17 +9,7 @@ Size RNTModalViewSize(void) { - __block CGSize screenSize = RCTScreenSize(); - - dispatch_sync(dispatch_get_main_queue(), ^{ - RNTModalWindowHelper *windowHelper = [[RNTModalWindowHelper alloc] init]; - UIInterfaceOrientation orientation = [windowHelper getWindowOrientation]; - - if (UIInterfaceOrientationIsLandscape(orientation)) { - screenSize = CGSizeMake(screenSize.height, screenSize.width); - } - }); - + CGSize screenSize = RCTScreenSize(); return { screenSize.width, screenSize.height }; } diff --git a/ios/Library/RNTModalViewController/RNTModalViewController.h b/ios/Library/RNTModalViewController/RNTModalViewController.h index 4f374f5..4a99f9e 100644 --- a/ios/Library/RNTModalViewController/RNTModalViewController.h +++ b/ios/Library/RNTModalViewController/RNTModalViewController.h @@ -28,7 +28,6 @@ @property(nonatomic, strong) ModalAnimation *inAnimation; @property(nonatomic, strong) ModalAnimation *outAnimation; @property(nonatomic, assign) CGRect lastBounds; -@property(nonatomic, assign) BOOL shouldTrackRotationChange; @end diff --git a/ios/Library/RNTModalViewController/RNTModalViewController.m b/ios/Library/RNTModalViewController/RNTModalViewController.m index 8e0b6f6..a695eeb 100644 --- a/ios/Library/RNTModalViewController/RNTModalViewController.m +++ b/ios/Library/RNTModalViewController/RNTModalViewController.m @@ -14,7 +14,6 @@ - (instancetype)initWithDelegate:(id)delegate { if (self) { self.reactSubviewContainer = [[UIView alloc] init]; self.delegate = delegate; - self.shouldTrackRotationChange = NO; } return self; } @@ -38,16 +37,10 @@ - (void)viewDidLoad { [self setupReactSubview:self.reactSubviewContainer]; } -- (void)viewDidAppear:(BOOL)animated { - [self.inAnimation animate:self.reactSubviewContainer completion:^(BOOL finished) { - self.shouldTrackRotationChange = YES; - }]; -} - - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; - if (!CGRectEqualToRect(self.lastBounds, self.view.bounds) && self.shouldTrackRotationChange) { + if (!CGRectEqualToRect(self.lastBounds, self.view.bounds)) { [self.delegate boundsDidChange:self.view.bounds]; self.lastBounds = self.view.bounds; } @@ -67,7 +60,6 @@ - (void)dismiss { self.reactSubviewContainer = [self.reactSubviewContainer snapshotViewAfterScreenUpdates:NO]; [prevReactSubviewContainer removeFromSuperview]; - self.shouldTrackRotationChange = NO; [self setupReactSubview:self.reactSubviewContainer]; [self.outAnimation prepareAnimation:self.reactSubviewContainer]; [self.outAnimation animate:self.reactSubviewContainer completion:^(BOOL finished) { diff --git a/ios/RNTModalShadowView.m b/ios/RNTModalShadowView.m index 2a89743..7bf122c 100644 --- a/ios/RNTModalShadowView.m +++ b/ios/RNTModalShadowView.m @@ -11,18 +11,7 @@ - (void)insertReactSubview:(id)subview atIndex:(NSInteger)atIndex { [super insertReactSubview:subview atIndex:atIndex]; if ([subview isKindOfClass:[RCTShadowView class]]) { - dispatch_sync(dispatch_get_main_queue(), ^{ - RNTModalWindowHelper *windowHelper = [[RNTModalWindowHelper alloc] init]; - UIInterfaceOrientation orientation = [windowHelper getWindowOrientation]; - - CGSize screenSize = RCTScreenSize(); - - if (UIInterfaceOrientationIsPortrait(orientation)) { - ((RCTShadowView *)subview).size = screenSize; - } else { - ((RCTShadowView *)subview).size = CGSizeMake(screenSize.height, screenSize.width); - } - }); + ((RCTShadowView *)subview).size = RCTScreenSize(); } }