Skip to content

Commit 063430d

Browse files
committed
refactor: remove unused RCTForegroundWindow (#94)
1 parent a7b9f83 commit 063430d

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
@@ -600,16 +600,6 @@ BOOL RCTRunningInAppExtension(void)
600600
return RCTKeyWindow().windowScene.statusBarManager;
601601
}
602602

603-
#if TARGET_OS_VISION
604-
UIWindow *__nullable RCTForegroundWindow(void)
605-
{
606-
// React native only supports single scene apps.
607-
NSSet *scenes = RCTSharedApplication().connectedScenes;
608-
UIWindowScene *firstScene = [scenes anyObject];
609-
return [[UIWindow alloc] initWithWindowScene:firstScene];
610-
}
611-
#endif
612-
613603
UIViewController *__nullable RCTPresentedViewController(void)
614604
{
615605
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)