Skip to content

refactor: remove unused RCTForegroundWindow #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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