Skip to content

Commit 9fbe761

Browse files
authored
refactor: remove unused RCTForegroundWindow (#94)
1 parent c127c51 commit 9fbe761

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
@@ -96,9 +96,6 @@ RCT_EXTERN UIApplication *__nullable RCTSharedApplication(void);
9696
RCT_EXTERN UIWindow *__nullable RCTKeyWindow(void);
9797

9898
#if TARGET_OS_VISION
99-
// Returns the current active UIWindow based on UIWindowScene
100-
RCT_EXTERN UIWindow *__nullable RCTForegroundWindow(void);
101-
10299
// Returns UIStatusBarManager to get it's configuration info.
103100
RCT_EXTERN UIStatusBarManager *__nullable RCTUIStatusBarManager(void);
104101
#endif

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

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

594594
#if TARGET_OS_VISION
595-
UIWindow *__nullable RCTForegroundWindow(void)
596-
{
597-
// React native only supports single scene apps.
598-
NSSet *scenes = RCTSharedApplication().connectedScenes;
599-
UIWindowScene *firstScene = [scenes anyObject];
600-
return [[UIWindow alloc] initWithWindowScene:firstScene];
601-
}
602595

603596
UIStatusBarManager *__nullable RCTUIStatusBarManager(void) {
604597
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)