diff --git a/apple/Handlers/RNNativeViewHandler.mm b/apple/Handlers/RNNativeViewHandler.mm index 667d600640..a3171cb9f0 100644 --- a/apple/Handlers/RNNativeViewHandler.mm +++ b/apple/Handlers/RNNativeViewHandler.mm @@ -15,11 +15,7 @@ #import #import -#ifdef RCT_NEW_ARCH_ENABLED #import -#else -#import -#endif // RCT_NEW_ARCH_ENABLED #pragma mark RNDummyGestureRecognizer diff --git a/apple/RNGestureHandler.mm b/apple/RNGestureHandler.mm index 43d11b4bd1..127d1b77f0 100644 --- a/apple/RNGestureHandler.mm +++ b/apple/RNGestureHandler.mm @@ -10,11 +10,7 @@ #import -#ifdef RCT_NEW_ARCH_ENABLED #import -#else -#import -#endif @interface UIGestureRecognizer (GestureHandler) @property (nonatomic, readonly) RNGestureHandler *gestureHandler; @@ -539,20 +535,10 @@ - (BOOL)isUIScrollViewPanGestureRecognizer:(NSGestureRecognizer *)gestureRecogni - (RNGHUIScrollView *)retrieveScrollView:(RNGHUIView *)view { -#ifdef RCT_NEW_ARCH_ENABLED if ([view isKindOfClass:[RCTScrollViewComponentView class]]) { RNGHUIScrollView *scrollView = ((RCTScrollViewComponentView *)view).scrollView; return scrollView; } -#else - if ([view isKindOfClass:[RCTScrollView class]]) { - // This part of the code is coupled with RN implementation of ScrollView native wrapper and - // we expect for RCTScrollView component to contain a subclass of UIScrollview as the only - // subview - RNGHUIScrollView *scrollView = [view.subviews objectAtIndex:0]; - return scrollView; - } -#endif return nil; } diff --git a/apple/RNGestureHandlerButton.h b/apple/RNGestureHandlerButton.h index be5199a23b..5d497c7a03 100644 --- a/apple/RNGestureHandlerButton.h +++ b/apple/RNGestureHandlerButton.h @@ -10,25 +10,22 @@ #if TARGET_OS_OSX -#if RCT_NEW_ARCH_ENABLED - #include @protocol RCTComponentViewProtocol; -#endif // RCT_NEW_ARCH_ENABLED - @interface RNGestureHandlerButton : NSControl #else @interface RNGestureHandlerButton : UIControl #endif // TARGET_OS_OSX + /** * Insets used when hit testing inside this view. */ @property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets; @property (nonatomic) BOOL userEnabled; -#if TARGET_OS_OSX && RCT_NEW_ARCH_ENABLED +#if TARGET_OS_OSX - (void)mountChildComponentView:(RNGHUIView *)childComponentView index:(NSInteger)index; - (void)unmountChildComponentView:(RNGHUIView *)childComponentView index:(NSInteger)index; - (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics diff --git a/apple/RNGestureHandlerButton.mm b/apple/RNGestureHandlerButton.mm index 3729eb18ba..7955210a3d 100644 --- a/apple/RNGestureHandlerButton.mm +++ b/apple/RNGestureHandlerButton.mm @@ -14,13 +14,9 @@ #import #endif -#if RCT_NEW_ARCH_ENABLED - #import #import -#endif - /** * Gesture Handler Button components overrides standard mechanism used by RN * to determine touch target, which normally would reurn the UIView that is placed @@ -89,9 +85,7 @@ - (RNGHUIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event } return inner; } -#endif - -#if TARGET_OS_OSX && RCT_NEW_ARCH_ENABLED +#else - (void)mountChildComponentView:(RNGHUIView *)childComponentView index:(NSInteger)index { if (childComponentView.superview != nil) { diff --git a/apple/RNGestureHandlerButtonComponentView.h b/apple/RNGestureHandlerButtonComponentView.h index 642f3d9f1a..444236a7c6 100644 --- a/apple/RNGestureHandlerButtonComponentView.h +++ b/apple/RNGestureHandlerButtonComponentView.h @@ -1,5 +1,3 @@ -#ifdef RCT_NEW_ARCH_ENABLED - #if !TARGET_OS_OSX #import #else @@ -17,5 +15,3 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END - -#endif // RCT_NEW_ARCH_ENABLED diff --git a/apple/RNGestureHandlerButtonComponentView.mm b/apple/RNGestureHandlerButtonComponentView.mm index 32a8641ac5..9dbea8ae26 100644 --- a/apple/RNGestureHandlerButtonComponentView.mm +++ b/apple/RNGestureHandlerButtonComponentView.mm @@ -1,5 +1,3 @@ -#ifdef RCT_NEW_ARCH_ENABLED - #import "RNGestureHandlerButtonComponentView.h" #import @@ -119,6 +117,4 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & Class RNGestureHandlerButtonCls(void) { return RNGestureHandlerButtonComponentView.class; -} - -#endif // RCT_NEW_ARCH_ENABLED +} \ No newline at end of file diff --git a/apple/RNGestureHandlerManager.h b/apple/RNGestureHandlerManager.h index a191817419..b8b441a4ec 100644 --- a/apple/RNGestureHandlerManager.h +++ b/apple/RNGestureHandlerManager.h @@ -9,13 +9,8 @@ @interface RNGestureHandlerManager : NSObject -#ifdef RCT_NEW_ARCH_ENABLED - (nonnull instancetype)initWithModuleRegistry:(nonnull RCTModuleRegistry *)moduleRegistry viewRegistry:(nonnull RCTViewRegistry *)viewRegistry; -#else -- (nonnull instancetype)initWithUIManager:(nonnull RCTUIManager *)uiManager - eventDispatcher:(nonnull id)eventDispatcher; -#endif // RCT_NEW_ARCH_ENABLED - (void)createGestureHandler:(nonnull NSString *)handlerName tag:(nonnull NSNumber *)handlerTag diff --git a/apple/RNGestureHandlerManager.mm b/apple/RNGestureHandlerManager.mm index 7983c49477..2a609440d2 100644 --- a/apple/RNGestureHandlerManager.mm +++ b/apple/RNGestureHandlerManager.mm @@ -15,14 +15,10 @@ #import "RNGestureHandlerState.h" #import "RNRootViewGestureRecognizer.h" -#ifdef RCT_NEW_ARCH_ENABLED #import #import #import #import -#else -#import -#endif // RCT_NEW_ARCH_ENABLED #import "Handlers/RNFlingHandler.h" #import "Handlers/RNForceTouchHandler.h" @@ -51,17 +47,12 @@ @implementation RNGestureHandlerManager { RNGestureHandlerRegistry *_registry; NSHashTable *_rootViewGestureRecognizers; NSMutableDictionary *_attachRetryCounter; -#ifdef RCT_NEW_ARCH_ENABLED RCTModuleRegistry *_moduleRegistry; RCTViewRegistry *_viewRegistry; -#else - RCTUIManager *_uiManager; -#endif // RCT_NEW_ARCH_ENABLED id _eventDispatcher; id _reanimatedModule; } -#ifdef RCT_NEW_ARCH_ENABLED - (instancetype)initWithModuleRegistry:(RCTModuleRegistry *)moduleRegistry viewRegistry:(RCTViewRegistry *)viewRegistry { if ((self = [super init])) { @@ -72,18 +63,6 @@ - (instancetype)initWithModuleRegistry:(RCTModuleRegistry *)moduleRegistry viewR } return self; } -#else -- (instancetype)initWithUIManager:(RCTUIManager *)uiManager - eventDispatcher:(id)eventDispatcher -{ - if ((self = [super init])) { - _uiManager = uiManager; - _eventDispatcher = eventDispatcher; - [self initCommonProps]; - } - return self; -} -#endif // RCT_NEW_ARCH_ENABLED - (void)initCommonProps { @@ -137,13 +116,8 @@ - (void)attachGestureHandler:(nonnull NSNumber *)handlerTag toViewWithTag:(nonnull NSNumber *)viewTag withActionType:(RNGestureHandlerActionType)actionType { -#ifdef RCT_NEW_ARCH_ENABLED RNGHUIView *view = [_viewRegistry viewForReactTag:viewTag]; -#else - RNGHUIView *view = [_uiManager viewForReactTag:viewTag]; -#endif // RCT_NEW_ARCH_ENABLED -#ifdef RCT_NEW_ARCH_ENABLED if (view == nil || view.superview == nil) { // There are a few reasons we could end up here: // - the native view corresponding to the viewtag hasn't yet been created @@ -188,7 +162,6 @@ - (void)attachGestureHandler:(nonnull NSNumber *)handlerTag view.reactTag = viewTag; // necessary for RNReanimated eventHash (e.g. "42onGestureHandlerEvent"), also will be // returned as event.target -#endif // RCT_NEW_ARCH_ENABLED [_registry attachHandlerWithTag:handlerTag toView:view withActionType:actionType]; @@ -235,7 +208,6 @@ - (id)handlerWithTag:(NSNumber *)handlerTag - (void)registerViewWithGestureRecognizerAttachedIfNeeded:(RNGHUIView *)childView { -#ifdef RCT_NEW_ARCH_ENABLED RNGHUIView *touchHandlerView = childView; #if !TARGET_OS_OSX @@ -252,31 +224,6 @@ - (void)registerViewWithGestureRecognizerAttachedIfNeeded:(RNGHUIView *)childVie } #endif // !TARGET_OS_OSX -#else - RNGHUIView *touchHandlerView = nil; - -#if !TARGET_OS_OSX - if ([[childView reactViewController] isKindOfClass:[RCTModalHostViewController class]]) { - touchHandlerView = [childView reactViewController].view.subviews[0]; - } else { - UIView *parent = childView; - while (parent != nil && ![parent respondsToSelector:@selector(touchHandler)]) { - parent = parent.superview; - } - - touchHandlerView = [[parent performSelector:@selector(touchHandler)] view]; - } -#else - NSView *parent = childView; - while (parent != nil && ![parent respondsToSelector:@selector(touchHandler)]) { - parent = parent.superview; - } - - touchHandlerView = [[parent performSelector:@selector(touchHandler)] view]; -#endif // !TARGET_OS_OSX - -#endif // RCT_NEW_ARCH_ENABLED - if (touchHandlerView == nil) { return; } @@ -327,11 +274,7 @@ - (void)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer // this way we can extract the touch handler on both architectures relatively easily for (UIGestureRecognizer *recognizer in [viewWithTouchHandler gestureRecognizers]) { -#ifdef RCT_NEW_ARCH_ENABLED if ([recognizer isKindOfClass:[RCTSurfaceTouchHandler class]]) { -#else - if ([recognizer isKindOfClass:[RCTTouchHandler class]]) { -#endif // RCT_NEW_ARCH_ENABLED touchHandler = recognizer; break; } @@ -373,18 +316,13 @@ - (void)sendEvent:(RNGestureHandlerStateChange *)event withActionType:(RNGesture - (void)sendEventForReanimated:(RNGestureHandlerStateChange *)event { // Delivers the event to Reanimated. -#ifdef RCT_NEW_ARCH_ENABLED + // Send event directly to Reanimated if (_reanimatedModule == nil) { _reanimatedModule = [_moduleRegistry moduleForName:"ReanimatedModule"]; } [_reanimatedModule eventDispatcherWillDispatchEvent:event]; -#else - // In the old architecture, Reanimated overwrites RCTEventDispatcher - // with REAEventDispatcher and intercepts all direct events. - [self sendEventForDirectEvent:event]; -#endif // RCT_NEW_ARCH_ENABLED } - (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event @@ -399,11 +337,7 @@ - (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event - (void)sendEventForJSFunctionOldAPI:(RNGestureHandlerStateChange *)event { // Delivers the event to JS (old RNGH API). -#ifdef RCT_NEW_ARCH_ENABLED [self sendEventForDeviceEvent:event]; -#else - [self sendEventForDirectEvent:event]; -#endif // RCT_NEW_ARCH_ENABLED } - (void)sendEventForJSFunctionNewAPI:(RNGestureHandlerStateChange *)event diff --git a/apple/RNGestureHandlerModule.h b/apple/RNGestureHandlerModule.h index fc943b78e0..7c04fc9a32 100644 --- a/apple/RNGestureHandlerModule.h +++ b/apple/RNGestureHandlerModule.h @@ -1,19 +1,10 @@ #import #import -#ifdef RCT_NEW_ARCH_ENABLED #import #import #import -#else -#import -#endif -@interface RNGestureHandlerModule : RCTEventEmitter -#ifdef RCT_NEW_ARCH_ENABLED - -#else - -#endif +@interface RNGestureHandlerModule : RCTEventEmitter @end diff --git a/apple/RNGestureHandlerModule.mm b/apple/RNGestureHandlerModule.mm index 4a0ce6939a..5dd6392bdf 100644 --- a/apple/RNGestureHandlerModule.mm +++ b/apple/RNGestureHandlerModule.mm @@ -7,7 +7,6 @@ #import #import -#ifdef RCT_NEW_ARCH_ENABLED #import #import #import @@ -15,7 +14,6 @@ #import #import -#endif // RCT_NEW_ARCH_ENABLED #import "RNGestureHandler.h" #import "RNGestureHandlerDirection.h" @@ -27,20 +25,12 @@ #import -#ifdef RCT_NEW_ARCH_ENABLED using namespace facebook; using namespace react; -#endif // RCT_NEW_ARCH_ENABLED -#ifdef RCT_NEW_ARCH_ENABLED @interface RNGestureHandlerModule () @end -#else -@interface RNGestureHandlerModule () - -@end -#endif // RCT_NEW_ARCH_ENABLED typedef void (^GestureHandlerOperation)(RNGestureHandlerManager *manager); @@ -51,10 +41,8 @@ @implementation RNGestureHandlerModule { NSMutableArray *_operations; } -#ifdef RCT_NEW_ARCH_ENABLED @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED; @synthesize dispatchToJSThread = _dispatchToJSThread; -#endif // RCT_NEW_ARCH_ENABLED RCT_EXPORT_MODULE() @@ -71,10 +59,6 @@ - (void)invalidate }); _manager = nil; - -#ifndef RCT_NEW_ARCH_ENABLED - [self.bridge.uiManager.observerCoordinator removeObserver:self]; -#endif // RCT_NEW_ARCH_ENABLED } - (dispatch_queue_t)methodQueue @@ -88,7 +72,6 @@ - (dispatch_queue_t)methodQueue return RCTGetUIManagerQueue(); } -#ifdef RCT_NEW_ARCH_ENABLED void decorateRuntime(jsi::Runtime &runtime) { auto isFormsStackingContext = jsi::Function::createFromHostFunction( @@ -105,29 +88,14 @@ void decorateRuntime(jsi::Runtime &runtime) }); runtime.global().setProperty(runtime, "isFormsStackingContext", std::move(isFormsStackingContext)); } -#endif // RCT_NEW_ARCH_ENABLED -#ifdef RCT_NEW_ARCH_ENABLED - (void)initialize { _manager = [[RNGestureHandlerManager alloc] initWithModuleRegistry:self.moduleRegistry viewRegistry:_viewRegistry_DEPRECATED]; _operations = [NSMutableArray new]; } -#else -- (void)setBridge:(RCTBridge *)bridge -{ - [super setBridge:bridge]; - _manager = [[RNGestureHandlerManager alloc] initWithUIManager:bridge.uiManager - eventDispatcher:bridge.eventDispatcher]; - _operations = [NSMutableArray new]; - - [bridge.uiManager.observerCoordinator addObserver:self]; -} -#endif // RCT_NEW_ARCH_ENABLED - -#ifdef RCT_NEW_ARCH_ENABLED RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) { dispatch_block_t block = ^{ @@ -143,7 +111,6 @@ - (void)setBridge:(RCTBridge *)bridge return @true; } -#endif // RCT_NEW_ARCH_ENABLED RCT_EXPORT_METHOD(createGestureHandler : (nonnull NSString *)handlerName handlerTag @@ -196,7 +163,6 @@ - (void)setBridge:(RCTBridge *)bridge { // On the new arch we rely on `flushOperations` for scheduling the operations on the UI thread. // On the old arch we rely on `uiManagerWillPerformMounting` -#ifdef RCT_NEW_ARCH_ENABLED if (_operations.count == 0) { return; } @@ -209,7 +175,6 @@ - (void)setBridge:(RCTBridge *)bridge operation(self->_manager); } }]; -#endif // RCT_NEW_ARCH_ENABLED } - (void)setGestureState:(int)state forHandler:(int)handlerTag @@ -250,34 +215,6 @@ - (void)addOperationBlock:(GestureHandlerOperation)operation [_operations addObject:operation]; } -#ifndef RCT_NEW_ARCH_ENABLED - -#pragma mark - RCTUIManagerObserver - -- (void)uiManagerWillFlushUIBlocks:(RCTUIManager *)uiManager -{ - [self uiManagerWillPerformMounting:uiManager]; -} - -- (void)uiManagerWillPerformMounting:(RCTUIManager *)uiManager -{ - if (_operations.count == 0) { - return; - } - - NSArray *operations = _operations; - _operations = [NSMutableArray new]; - - [uiManager - addUIBlock:^(__unused RCTUIManager *manager, __unused NSDictionary *viewRegistry) { - for (GestureHandlerOperation operation in operations) { - operation(self->_manager); - } - }]; -} - -#endif // RCT_NEW_ARCH_ENABLED - #pragma mark Events - (NSArray *)supportedEvents @@ -307,12 +244,10 @@ - (NSDictionary *)constantsToExport }; } -#if RCT_NEW_ARCH_ENABLED - (std::shared_ptr)getTurboModule: (const facebook::react::ObjCTurboModule::InitParams &)params { return std::make_shared(params); } -#endif @end diff --git a/apple/RNGestureHandlerRootViewComponentView.mm b/apple/RNGestureHandlerRootViewComponentView.mm index ef102a529f..7823e3643e 100644 --- a/apple/RNGestureHandlerRootViewComponentView.mm +++ b/apple/RNGestureHandlerRootViewComponentView.mm @@ -1,5 +1,3 @@ -#ifdef RCT_NEW_ARCH_ENABLED - #import Class RNGestureHandlerRootViewCls(void) @@ -17,5 +15,3 @@ // TODO: remove this file once `excludedPlatforms` option properly disables generating ShadowNode return nil; } - -#endif // RCT_NEW_ARCH_ENABLED diff --git a/apple/RNRootViewGestureRecognizer.m b/apple/RNRootViewGestureRecognizer.m index a2a2f182cf..474592d146 100644 --- a/apple/RNRootViewGestureRecognizer.m +++ b/apple/RNRootViewGestureRecognizer.m @@ -12,11 +12,7 @@ #import #endif -#ifdef RCT_NEW_ARCH_ENABLED #import -#else -#import -#endif // RCT_NEW_ARCH_ENABLED @implementation RNRootViewGestureRecognizer { BOOL _active; @@ -51,13 +47,7 @@ - (BOOL)shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGe - (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer { - return ![preventedGestureRecognizer isKindOfClass:[ -#ifdef RCT_NEW_ARCH_ENABLED - RCTSurfaceTouchHandler -#else - RCTTouchHandler -#endif - class]]; + return ![preventedGestureRecognizer isKindOfClass:[RCTSurfaceTouchHandler class]]; } - (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer