Ensure LogBox uses UIWindowScene API for opening its view

Summary: Changelog: [iOS][Internal] Fix: Ensure LogBox uses UIWindowScene API for multi-window Mac Catalyst Apps

Reviewed By: arhelmus

Differential Revision: D35825513

fbshipit-source-id: 3dc5db7c84d2abf7cf4a3ffb3512de723a32f72d
This commit is contained in:
Vincent Riemer 2022-04-25 10:39:26 -07:00 коммит произвёл Facebook GitHub Bot
Родитель c6dc01fac6
Коммит 6855f7405c
3 изменённых файлов: 23 добавлений и 21 удалений

Просмотреть файл

@ -55,12 +55,12 @@ RCT_EXPORT_METHOD(show)
}
if (strongSelf->_bridgelessSurfacePresenter) {
strongSelf->_view = [[RCTLogBoxView alloc] initWithFrame:RCTKeyWindow().frame
surfacePresenter:strongSelf->_bridgelessSurfacePresenter];
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
surfacePresenter:strongSelf->_bridgelessSurfacePresenter];
} else if (strongSelf->_bridge && strongSelf->_bridge.valid) {
if (strongSelf->_bridge.surfacePresenter) {
strongSelf->_view = [[RCTLogBoxView alloc] initWithFrame:RCTKeyWindow().frame
surfacePresenter:strongSelf->_bridge.surfacePresenter];
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
surfacePresenter:strongSelf->_bridge.surfacePresenter];
} else {
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow() bridge:strongSelf->_bridge];
}

Просмотреть файл

@ -16,9 +16,8 @@
- (void)createRootViewController:(UIView *)view;
- (instancetype)initWithFrame:(CGRect)frame surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter;
- (instancetype)initWithWindow:(UIWindow *)window bridge:(RCTBridge *)bridge;
- (instancetype)initWithWindow:(UIWindow *)window surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter;
- (void)show;

Просмотреть файл

@ -33,21 +33,6 @@
self.rootViewController = _rootViewController;
}
- (instancetype)initWithFrame:(CGRect)frame surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
{
if (self = [super initWithFrame:frame]) {
id<RCTSurfaceProtocol> surface = [surfacePresenter createFabricSurfaceForModuleName:@"LogBox"
initialProperties:@{}];
[surface start];
RCTSurfaceHostingView *rootView = [[RCTSurfaceHostingView alloc]
initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
[self createRootViewController:rootView];
}
return self;
}
- (instancetype)initWithWindow:(UIWindow *)window bridge:(RCTBridge *)bridge
{
RCTErrorNewArchitectureValidation(RCTNotAllowedInAppWideFabric, @"RCTLogBoxView", nil);
@ -72,6 +57,24 @@
return self;
}
- (instancetype)initWithWindow:(UIWindow *)window surfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
{
if (@available(iOS 13.0, *)) {
self = [super initWithWindowScene:window.windowScene];
} else {
self = [super initWithFrame:window.frame];
}
id<RCTSurfaceProtocol> surface = [surfacePresenter createFabricSurfaceForModuleName:@"LogBox" initialProperties:@{}];
[surface start];
RCTSurfaceHostingView *rootView = [[RCTSurfaceHostingView alloc]
initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
[self createRootViewController:rootView];
return self;
}
- (void)layoutSubviews
{
[super layoutSubviews];