Ensure LogBoxView is sized based on the "window" size instead of the "screen" size
Summary: In iOS, the native LogBox that gets rendered for JS errors/warnings is statically sized once and bases that size off of the entire screen's size. This causes issues when being run in a Mac Catalyst app since 1) the sizing is not static since we can resize the window and 2) the size of the LogBox's root should fill the *window* and not the screen. This diff fixes both of these issues. Changelog: [iOS][Fixed] - Ensure LogBoxView is sized relative to the key window instead of the full screen Reviewed By: appden Differential Revision: D34697076 fbshipit-source-id: 9665fd51bc86ed29837672cec882bac97904b0c8
This commit is contained in:
Родитель
538636440b
Коммит
84f8c9ad55
|
@ -51,8 +51,7 @@ RCT_EXPORT_METHOD(show)
|
|||
|
||||
if (strongSelf->_bridge) {
|
||||
if (strongSelf->_bridge.valid) {
|
||||
strongSelf->_view = [[RCTLogBoxView alloc] initWithFrame:[UIScreen mainScreen].bounds
|
||||
bridge:strongSelf->_bridge];
|
||||
strongSelf->_view = [[RCTLogBoxView alloc] initWithFrame:RCTKeyWindow().frame bridge:strongSelf->_bridge];
|
||||
[strongSelf->_view show];
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -39,9 +39,8 @@
|
|||
self.backgroundColor = [UIColor clearColor];
|
||||
|
||||
_surface = [[RCTSurface alloc] initWithBridge:bridge moduleName:@"LogBox" initialProperties:@{}];
|
||||
|
||||
[_surface start];
|
||||
[_surface setSize:frame.size];
|
||||
[_surface start];
|
||||
|
||||
if (![_surface synchronouslyWaitForStage:RCTSurfaceStageSurfaceDidInitialMounting timeout:1]) {
|
||||
RCTLogInfo(@"Failed to mount LogBox within 1s");
|
||||
|
@ -52,6 +51,12 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
[_surface setSize:self.frame.size];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[RCTSharedApplication().delegate.window makeKeyWindow];
|
||||
|
|
Загрузка…
Ссылка в новой задаче