From f56f0c354aa374365796bae75005541fdb417d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Thu, 9 Nov 2023 13:44:00 +0100 Subject: [PATCH 1/2] feat(iOS) use currentTraitCollection instead of [UIScreen mainScreen] for FBSnapshotTestController --- .../RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m index 48d51fa52990a2..c4abfcc8e1cecc 100644 --- a/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m +++ b/packages/rn-tester/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m @@ -238,8 +238,10 @@ - (NSString *)_fileNameForSelector:(SEL)selector if (0 < identifier.length) { fileName = [fileName stringByAppendingFormat:@"_%@", identifier]; } - if ([[UIScreen mainScreen] scale] > 1.0) { - fileName = [fileName stringByAppendingFormat:@"@%.fx", [[UIScreen mainScreen] scale]]; + + UITraitCollection *currentTraitCollection = [UITraitCollection currentTraitCollection]; + if (currentTraitCollection.displayScale > 1.0) { + fileName = [fileName stringByAppendingFormat:@"@%.fx", currentTraitCollection.displayScale]; } fileName = [fileName stringByAppendingPathExtension:@"png"]; return fileName; From 5b7160b8413e248828b5f7ce6f3b6822ab23b167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwas=CC=81niewski?= Date: Thu, 9 Nov 2023 13:44:42 +0100 Subject: [PATCH 2/2] feat(iOS) use key window width to assign correct width for RCTDevLoadingView --- .../react-native/React/CoreModules/RCTDevLoadingView.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-native/React/CoreModules/RCTDevLoadingView.mm b/packages/react-native/React/CoreModules/RCTDevLoadingView.mm index ab9c945790e358..40fdbcdec820da 100644 --- a/packages/react-native/React/CoreModules/RCTDevLoadingView.mm +++ b/packages/react-native/React/CoreModules/RCTDevLoadingView.mm @@ -114,13 +114,14 @@ - (void)showMessage:(NSString *)message color:(UIColor *)color backgroundColor:( dispatch_async(dispatch_get_main_queue(), ^{ self->_showDate = [NSDate date]; if (!self->_window && !RCTRunningInTestEnvironment()) { - CGSize screenSize = [UIScreen mainScreen].bounds.size; UIWindow *window = RCTSharedApplication().keyWindow; + CGFloat windowWidth = window.bounds.size.width; + self->_window = - [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, window.safeAreaInsets.top + 10)]; + [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, windowWidth, window.safeAreaInsets.top + 10)]; self->_label = - [[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top - 10, screenSize.width, 20)]; + [[UILabel alloc] initWithFrame:CGRectMake(0, window.safeAreaInsets.top - 10, windowWidth, 20)]; [self->_window addSubview:self->_label]; self->_window.windowLevel = UIWindowLevelStatusBar + 1;