Skip to content

Commit 08d4262

Browse files
committed
refactor: remove unused RCTForegroundWindow (#94)
1 parent 954db43 commit 08d4262

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ RCT_EXTERN UIApplication *__nullable RCTSharedApplication(void);
9595
// or view controller
9696
RCT_EXTERN UIWindow *__nullable RCTKeyWindow(void);
9797

98-
#if TARGET_OS_VISION
99-
// Returns the current active UIWindow based on UIWindowScene
100-
RCT_EXTERN UIWindow *__nullable RCTForegroundWindow(void);
101-
#endif
102-
10398
// Returns the presented view controller, useful if you need
10499
// e.g. to present a modal view controller or alert over it
105100
RCT_EXTERN UIViewController *__nullable RCTPresentedViewController(void);

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -596,16 +596,6 @@ BOOL RCTRunningInAppExtension(void)
596596
return RCTKeyWindow().windowScene.statusBarManager;
597597
}
598598

599-
#if TARGET_OS_VISION
600-
UIWindow *__nullable RCTForegroundWindow(void)
601-
{
602-
// React native only supports single scene apps.
603-
NSSet *scenes = RCTSharedApplication().connectedScenes;
604-
UIWindowScene *firstScene = [scenes anyObject];
605-
return [[UIWindow alloc] initWithWindowScene:firstScene];
606-
}
607-
#endif
608-
609599
UIViewController *__nullable RCTPresentedViewController(void)
610600
{
611601
if ([RCTUtilsUIOverride hasPresentedViewController]) {

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)