|
14 | 14 | #import <React/RCTEventDispatcherProtocol.h> |
15 | 15 | #import <React/RCTInitializing.h> |
16 | 16 | #import <React/RCTInvalidating.h> |
17 | | -#import <React/RCTUIUtils.h> |
18 | 17 | #import <React/RCTUtils.h> |
19 | 18 | #import <atomic> |
20 | 19 |
|
@@ -175,20 +174,25 @@ static BOOL RCTIsIPhoneNotched() |
175 | 174 | static NSDictionary *RCTExportedDimensions(CGFloat fontScale) |
176 | 175 | { |
177 | 176 | RCTAssertMainQueue(); |
178 | | - RCTDimensions dimensions = RCTGetDimensions(fontScale); |
179 | | - __typeof(dimensions.window) window = dimensions.window; |
| 177 | + UIScreen *mainScreen = UIScreen.mainScreen; |
| 178 | + CGSize screenSize = mainScreen.bounds.size; |
| 179 | + UIView *mainWindow = RCTKeyWindow(); |
| 180 | + |
| 181 | + // We fallback to screen size if a key window is not found. |
| 182 | + CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize; |
| 183 | + |
180 | 184 | NSDictionary<NSString *, NSNumber *> *dimsWindow = @{ |
181 | | - @"width" : @(window.width), |
182 | | - @"height" : @(window.height), |
183 | | - @"scale" : @(window.scale), |
184 | | - @"fontScale" : @(window.fontScale) |
| 185 | + @"width" : @(windowSize.width), |
| 186 | + @"height" : @(windowSize.height), |
| 187 | + @"scale" : @(mainScreen.scale), |
| 188 | + @"fontScale" : @(fontScale) |
185 | 189 | }; |
186 | | - __typeof(dimensions.screen) screen = dimensions.screen; |
| 190 | + |
187 | 191 | NSDictionary<NSString *, NSNumber *> *dimsScreen = @{ |
188 | | - @"width" : @(screen.width), |
189 | | - @"height" : @(screen.height), |
190 | | - @"scale" : @(screen.scale), |
191 | | - @"fontScale" : @(screen.fontScale) |
| 192 | + @"width" : @(screenSize.width), |
| 193 | + @"height" : @(screenSize.height), |
| 194 | + @"scale" : @(mainScreen.scale), |
| 195 | + @"fontScale" : @(fontScale) |
192 | 196 | }; |
193 | 197 | return @{@"window" : dimsWindow, @"screen" : dimsScreen}; |
194 | 198 | } |
|
0 commit comments