|
11 | 11 |
|
12 | 12 | RCTDimensions RCTGetDimensions(CGFloat fontScale)
|
13 | 13 | {
|
14 |
| -#if TARGET_OS_VISION |
15 |
| - CGSize screenSize = RCTForegroundWindow().bounds.size; |
16 |
| -#else |
| 14 | +#if !TARGET_OS_VISION |
17 | 15 | UIScreen *mainScreen = UIScreen.mainScreen;
|
18 | 16 | CGSize screenSize = mainScreen.bounds.size;
|
19 | 17 | #endif
|
| 18 | + |
20 | 19 | 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 | + |
24 | 22 | #if TARGET_OS_VISION
|
25 |
| - scale = [UITraitCollection currentTraitCollection].displayScale; |
| 23 | + CGSize windowSize = mainWindow.bounds.size; |
| 24 | + CGSize screenSize = mainWindow.bounds.size; |
26 | 25 | #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; |
28 | 28 | #endif
|
29 |
| - |
30 | 29 | RCTDimensions result;
|
31 | 30 | 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}; |
33 | 32 | 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}; |
35 | 34 | result.screen = dimsScreen;
|
36 | 35 | result.window = dimsWindow;
|
37 | 36 |
|
|
0 commit comments