Skip to content

Commit aa6202c

Browse files
committed
refactor: remove unused RCTForegroundWindow (#94)
1 parent 76998ce commit aa6202c

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

packages/react-native/React/Base/RCTUtils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ RCT_EXTERN UIApplication *__nullable RCTSharedApplication(void);
9292
RCT_EXTERN UIWindow *__nullable RCTKeyWindow(void);
9393

9494
#if TARGET_OS_VISION
95-
// Returns the current active UIWindow based on UIWindowScene
96-
RCT_EXTERN UIWindow *__nullable RCTForegroundWindow(void);
97-
9895
// Returns UIStatusBarManager to get it's configuration info.
9996
RCT_EXTERN UIStatusBarManager *__nullable RCTUIStatusBarManager(void);
10097
#endif

packages/react-native/React/Base/RCTUtils.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,6 @@ BOOL RCTRunningInAppExtension(void)
570570
}
571571

572572
#if TARGET_OS_VISION
573-
UIWindow *__nullable RCTForegroundWindow(void)
574-
{
575-
// React native only supports single scene apps.
576-
NSSet *scenes = RCTSharedApplication().connectedScenes;
577-
UIWindowScene *firstScene = [scenes anyObject];
578-
return [[UIWindow alloc] initWithWindowScene:firstScene];
579-
}
580573

581574
UIStatusBarManager *__nullable RCTUIStatusBarManager(void) {
582575
NSSet *connectedScenes = RCTSharedApplication().connectedScenes;

packages/react-native/React/UIUtils/RCTUIUtils.m

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,26 @@
1111

1212
RCTDimensions RCTGetDimensions(CGFloat fontScale)
1313
{
14-
#if TARGET_OS_VISION
15-
CGSize screenSize = RCTForegroundWindow().bounds.size;
16-
#else
14+
#if !TARGET_OS_VISION
1715
UIScreen *mainScreen = UIScreen.mainScreen;
1816
CGSize screenSize = mainScreen.bounds.size;
1917
#endif
18+
2019
UIView *mainWindow = RCTKeyWindow();
21-
// We fallback to screen size if a key window is not found.
22-
CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
23-
CGFloat scale;
20+
CGFloat screenScale = [UITraitCollection currentTraitCollection].displayScale;
21+
2422
#if TARGET_OS_VISION
25-
scale = [UITraitCollection currentTraitCollection].displayScale;
23+
CGSize windowSize = mainWindow.bounds.size;
24+
CGSize screenSize = mainWindow.bounds.size;
2625
#else
27-
scale = mainScreen.scale;
26+
// We fallback to screen size if a key window is not found.
27+
CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
2828
#endif
29-
3029
RCTDimensions result;
3130
typeof(result.screen) dimsScreen = {
32-
.width = screenSize.width, .height = screenSize.height, .scale = scale, .fontScale = fontScale};
31+
.width = screenSize.width, .height = screenSize.height, .scale = screenScale, .fontScale = fontScale};
3332
typeof(result.window) dimsWindow = {
34-
.width = windowSize.width, .height = windowSize.height, .scale = scale, .fontScale = fontScale};
33+
.width = windowSize.width, .height = windowSize.height, .scale = screenScale, .fontScale = fontScale};
3534
result.screen = dimsScreen;
3635
result.window = dimsWindow;
3736

0 commit comments

Comments
 (0)