mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
LogBox - Revert back to RedBox window strategy
Summary: This diff reverts the iOS LogBox module back to the UIWindow strategy used by Redbox. Reviewed By: sammy-SC Differential Revision: D19941390 fbshipit-source-id: 4aea09137ea9e8bfc166a733272647a79102bf35
This commit is contained in:
committed by
Facebook Github Bot
parent
cebc2c9d3e
commit
cb749f1c52
@@ -29,18 +29,18 @@
|
||||
|
||||
@class RCTLogBoxView;
|
||||
|
||||
@interface RCTLogBoxView : UIView
|
||||
@interface RCTLogBoxView : UIWindow
|
||||
@end
|
||||
|
||||
@implementation RCTLogBoxView
|
||||
{
|
||||
UIViewController *_rootViewController;
|
||||
RCTSurface *_surface;
|
||||
}
|
||||
|
||||
- (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:@{}];
|
||||
@@ -52,31 +52,24 @@
|
||||
RCTLogInfo(@"Failed to mount LogBox within 1s");
|
||||
}
|
||||
|
||||
_rootViewController = [UIViewController new];
|
||||
UIViewController *_rootViewController = [UIViewController new];
|
||||
_rootViewController.view = (UIView *)_surface.view;
|
||||
_rootViewController.view.backgroundColor = [UIColor clearColor];
|
||||
_rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
|
||||
self.rootViewController = _rootViewController;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
// Dismiss by deallocating the window.
|
||||
// This will also handle JS reload, otherwise the LogBox view would be stuck on top.
|
||||
[_rootViewController.view resignFirstResponder];
|
||||
[_rootViewController dismissViewControllerAnimated:NO completion:NULL];
|
||||
[RCTSharedApplication().delegate.window makeKeyWindow];
|
||||
}
|
||||
|
||||
- (void)show
|
||||
{
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
[RCTSharedApplication().delegate.window.rootViewController presentViewController:_rootViewController animated:NO completion:^{
|
||||
__strong __typeof(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
[strongSelf->_rootViewController.view becomeFirstResponder];
|
||||
}
|
||||
}];
|
||||
[self becomeFirstResponder];
|
||||
[self makeKeyAndVisible];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user