From 3ab377cff5e95a9141f2686a04d4bfc46683cfb3 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Sun, 13 Nov 2022 22:35:19 +0100 Subject: [PATCH] Unfork RCTLogBox These files have some 'unnecessary' changes which make it hard(er) to merge in recent changes as: https://github.com/facebook/react-native/commit/37e5fa3a6ce Hence unforking them were possible --- React/CoreModules/RCTLogBox.h | 2 +- React/CoreModules/RCTLogBox.mm | 20 ++++++++++---------- React/CoreModules/RCTLogBoxView.h | 8 +++----- React/CoreModules/RCTLogBoxView.mm | 21 +++++++++------------ 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/React/CoreModules/RCTLogBox.h b/React/CoreModules/RCTLogBox.h index f297638b7b05c2..11711661209a88 100644 --- a/React/CoreModules/RCTLogBox.h +++ b/React/CoreModules/RCTLogBox.h @@ -12,7 +12,7 @@ #if RCT_DEV_MENU -- (void)setRCTLogBoxWindow:(RCTLogBoxWindow *)window; // TODO(macOS GH#774) Renamed from _view to _window +- (void)setRCTLogBoxView:(RCTLogBoxView *)view; #endif diff --git a/React/CoreModules/RCTLogBox.mm b/React/CoreModules/RCTLogBox.mm index da8850d29a499a..34b4e7162f3659 100644 --- a/React/CoreModules/RCTLogBox.mm +++ b/React/CoreModules/RCTLogBox.mm @@ -22,7 +22,7 @@ @interface RCTLogBox () @end @implementation RCTLogBox { - RCTLogBoxWindow *_window; // TODO(macOS GH#774) Renamed from _view to _window + RCTLogBoxView *_view; } @synthesize bridge = _bridge; @@ -44,20 +44,20 @@ + (BOOL)requiresMainQueueSetup return; } - if (strongSelf->_window) { // TODO(macOS GH#774) Renamed from _view to _window - [strongSelf->_window show]; // TODO(macOS GH#774) Renamed from _view to _window + if (strongSelf->_view) { + [strongSelf->_view show]; return; } if (strongSelf->_bridge) { if (strongSelf->_bridge.valid) { #if !TARGET_OS_OSX // TODO(macOS GH#774) - strongSelf->_window = [[RCTLogBoxWindow alloc] initWithFrame:[UIScreen mainScreen].bounds // TODO(macOS GH#774) Renamed from _view to _window + strongSelf->_view = [[RCTLogBoxView alloc] initWithFrame:[UIScreen mainScreen].bounds bridge:strongSelf->_bridge]; #else // [TODO(macOS GH#774) - strongSelf->_window = [[RCTLogBoxWindow alloc] initWithBridge:self->_bridge]; // TODO(macOS GH#774) Renamed from _view to _window + strongSelf->_view = [[RCTLogBoxView alloc] initWithBridge:self->_bridge]; // TODO(macOS GH#774) #endif // ]TODO(macOS GH#774) - [strongSelf->_window show]; // TODO(macOS GH#774) Renamed from _view to _window + [strongSelf->_view show]; } } else { NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:strongSelf, @"logbox", nil]; @@ -76,8 +76,8 @@ + (BOOL)requiresMainQueueSetup if (!strongSelf) { return; } - [strongSelf->_window hide]; // TODO(macOS GH#774) setHidden: -> hide - strongSelf->_window = nil; + [strongSelf->_view setHidden:YES]; + strongSelf->_view = nil; }); } } @@ -88,9 +88,9 @@ + (BOOL)requiresMainQueueSetup return std::make_shared(params); } -- (void)setRCTLogBoxWindow:(RCTLogBoxWindow *)window // TODO(macOS GH#774) Renamed from _view to _window +- (void)setRCTLogBoxView:(RCTLogBoxView *)view { - self->_window = window; + self->_view = view; } @end diff --git a/React/CoreModules/RCTLogBoxView.h b/React/CoreModules/RCTLogBoxView.h index 94284139ca8234..dba82aea7d238f 100644 --- a/React/CoreModules/RCTLogBoxView.h +++ b/React/CoreModules/RCTLogBoxView.h @@ -11,7 +11,7 @@ #if !TARGET_OS_OSX // TODO(macOS GH#774) -@interface RCTLogBoxWindow : UIWindow // TODO(macOS GH#774) Renamed from _view to _window +@interface RCTLogBoxView : UIWindow - (instancetype)initWithFrame:(CGRect)frame; @@ -19,19 +19,17 @@ - (instancetype)initWithFrame:(CGRect)frame bridge:(RCTBridge *)bridge; -- (void)hide; // TODO(macOS GH#774) - - (void)show; @end #else // [TODO(macOS GH#774) -@interface RCTLogBoxWindow : NSWindow // TODO(macOS GH#774) Renamed from _view to _window +@interface RCTLogBoxView : NSWindow // TODO(macOS GH#774) - (instancetype)initWithBridge:(RCTBridge *)bridge; -- (void)hide; +- (void)setHidden:(BOOL)hidden; - (void)show; diff --git a/React/CoreModules/RCTLogBoxView.mm b/React/CoreModules/RCTLogBoxView.mm index 31ba8f29623d83..fd155143264737 100644 --- a/React/CoreModules/RCTLogBoxView.mm +++ b/React/CoreModules/RCTLogBoxView.mm @@ -12,7 +12,7 @@ #if !TARGET_OS_OSX // TODO(macOS GH#774) -@implementation RCTLogBoxWindow { // TODO(macOS GH#774) Renamed from _view to _window +@implementation RCTLogBoxView { RCTSurface *_surface; } @@ -59,11 +59,6 @@ - (void)dealloc [RCTSharedApplication().delegate.window makeKeyWindow]; } -- (void)hide // [TODO(macOS GH#774) -{ - [self setHidden:YES]; -} // ]TODO(macOS GH#774) - - (void)show { [self becomeFirstResponder]; @@ -74,7 +69,7 @@ - (void)show #else // [TODO(macOS GH#774) -@implementation RCTLogBoxWindow { // TODO(macOS GH#774) Renamed from _view to _window +@implementation RCTLogBoxView { RCTSurface *_surface; } @@ -100,13 +95,15 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge return self; } -- (void)hide +- (void)setHidden:(BOOL)hidden // [TODO(macOS GH#774) { - if (NSApp.modalWindow == self) { - [NSApp stopModal]; + if (hidden) { + if (NSApp.modalWindow == self) { + [NSApp stopModal]; + } + [self orderOut:nil]; } - [self orderOut:nil]; -} +} // ]TODO(macOS GH#774) - (void)show {