mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
84f8c9ad55
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
72 lines
1.7 KiB
Plaintext
72 lines
1.7 KiB
Plaintext
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#import "RCTLogBoxView.h"
|
|
|
|
#import <React/RCTLog.h>
|
|
#import <React/RCTSurface.h>
|
|
|
|
@implementation RCTLogBoxView {
|
|
RCTSurface *_surface;
|
|
}
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
if ((self = [super initWithFrame:frame])) {
|
|
self.windowLevel = UIWindowLevelStatusBar - 1;
|
|
self.backgroundColor = [UIColor clearColor];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)createRootViewController:(UIView *)view
|
|
{
|
|
UIViewController *_rootViewController = [UIViewController new];
|
|
_rootViewController.view = view;
|
|
_rootViewController.view.backgroundColor = [UIColor clearColor];
|
|
_rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
self.rootViewController = _rootViewController;
|
|
}
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge
|
|
{
|
|
if ((self = [super initWithFrame:frame])) {
|
|
self.windowLevel = UIWindowLevelStatusBar - 1;
|
|
self.backgroundColor = [UIColor clearColor];
|
|
|
|
_surface = [[RCTSurface alloc] initWithBridge:bridge moduleName:@"LogBox" initialProperties:@{}];
|
|
[_surface setSize:frame.size];
|
|
[_surface start];
|
|
|
|
if (![_surface synchronouslyWaitForStage:RCTSurfaceStageSurfaceDidInitialMounting timeout:1]) {
|
|
RCTLogInfo(@"Failed to mount LogBox within 1s");
|
|
}
|
|
|
|
[self createRootViewController:(UIView *)_surface.view];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)layoutSubviews
|
|
{
|
|
[super layoutSubviews];
|
|
[_surface setSize:self.frame.size];
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
[RCTSharedApplication().delegate.window makeKeyWindow];
|
|
}
|
|
|
|
- (void)show
|
|
{
|
|
[self becomeFirstResponder];
|
|
[self makeKeyAndVisible];
|
|
}
|
|
|
|
@end
|