Skip to content

Commit

Permalink
refactor: remove unused RCTForegroundWindow (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski authored Feb 6, 2024
1 parent c127c51 commit 9fbe761
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
3 changes: 0 additions & 3 deletions packages/react-native/React/Base/RCTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ RCT_EXTERN UIApplication *__nullable RCTSharedApplication(void);
RCT_EXTERN UIWindow *__nullable RCTKeyWindow(void);

#if TARGET_OS_VISION
// Returns the current active UIWindow based on UIWindowScene
RCT_EXTERN UIWindow *__nullable RCTForegroundWindow(void);

// Returns UIStatusBarManager to get it's configuration info.
RCT_EXTERN UIStatusBarManager *__nullable RCTUIStatusBarManager(void);
#endif
Expand Down
7 changes: 0 additions & 7 deletions packages/react-native/React/Base/RCTUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,6 @@ BOOL RCTRunningInAppExtension(void)
}

#if TARGET_OS_VISION
UIWindow *__nullable RCTForegroundWindow(void)
{
// React native only supports single scene apps.
NSSet *scenes = RCTSharedApplication().connectedScenes;
UIWindowScene *firstScene = [scenes anyObject];
return [[UIWindow alloc] initWithWindowScene:firstScene];
}

UIStatusBarManager *__nullable RCTUIStatusBarManager(void) {
NSSet *connectedScenes = RCTSharedApplication().connectedScenes;
Expand Down
21 changes: 10 additions & 11 deletions packages/react-native/React/UIUtils/RCTUIUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@

RCTDimensions RCTGetDimensions(CGFloat fontScale)
{
#if TARGET_OS_VISION
CGSize screenSize = RCTForegroundWindow().bounds.size;
#else
#if !TARGET_OS_VISION
UIScreen *mainScreen = UIScreen.mainScreen;
CGSize screenSize = mainScreen.bounds.size;
#endif

UIView *mainWindow = RCTKeyWindow();
// We fallback to screen size if a key window is not found.
CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
CGFloat scale;
CGFloat screenScale = [UITraitCollection currentTraitCollection].displayScale;

#if TARGET_OS_VISION
scale = [UITraitCollection currentTraitCollection].displayScale;
CGSize windowSize = mainWindow.bounds.size;
CGSize screenSize = mainWindow.bounds.size;
#else
scale = mainScreen.scale;
// We fallback to screen size if a key window is not found.
CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize;
#endif

RCTDimensions result;
typeof(result.screen) dimsScreen = {
.width = screenSize.width, .height = screenSize.height, .scale = scale, .fontScale = fontScale};
.width = screenSize.width, .height = screenSize.height, .scale = screenScale, .fontScale = fontScale};
typeof(result.window) dimsWindow = {
.width = windowSize.width, .height = windowSize.height, .scale = scale, .fontScale = fontScale};
.width = windowSize.width, .height = windowSize.height, .scale = screenScale, .fontScale = fontScale};
result.screen = dimsScreen;
result.window = dimsWindow;

Expand Down

0 comments on commit 9fbe761

Please sign in to comment.