Skip to content

Commit 0acfea0

Browse files
committed
remove all obj-c old arch macros
1 parent 4298e09 commit 0acfea0

13 files changed

+14
-215
lines changed

packages/react-native-gesture-handler/apple/Handlers/RNNativeViewHandler.mm

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
#endif
1414

1515
#import <React/RCTConvert.h>
16-
#import <React/UIView+React.h>
17-
18-
#ifdef RCT_NEW_ARCH_ENABLED
1916
#import <React/RCTScrollViewComponentView.h>
20-
#else
21-
#import <React/RCTScrollView.h>
22-
#endif // RCT_NEW_ARCH_ENABLED
17+
#import <React/UIView+React.h>
2318

2419
#pragma mark RNDummyGestureRecognizer
2520

packages/react-native-gesture-handler/apple/RNGestureHandler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@
7676
@property (nonatomic) BOOL needsPointerData;
7777
@property (nonatomic) BOOL manualActivation;
7878

79-
#if RCT_NEW_ARCH_ENABLED
8079
- (BOOL)isViewParagraphComponent:(nullable RNGHUIView *)view;
81-
#endif
8280
- (nonnull RNGHUIView *)chooseViewForInteraction:(nonnull UIGestureRecognizer *)recognizer;
8381
- (void)bindToView:(nonnull RNGHUIView *)view;
8482
- (void)unbindFromView;

packages/react-native-gesture-handler/apple/RNGestureHandler.mm

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010

1111
#import <React/UIView+React.h>
1212

13-
#ifdef RCT_NEW_ARCH_ENABLED
1413
#import <React/RCTParagraphComponentView.h>
1514
#import <React/RCTScrollViewComponentView.h>
16-
#else
17-
#import <React/RCTScrollView.h>
18-
#endif
1915

2016
@interface UIGestureRecognizer (GestureHandler)
2117
@property (nonatomic, readonly) RNGestureHandler *gestureHandler;
@@ -216,25 +212,19 @@ - (UITouchType)getPointerType
216212
return (UITouchType)_pointerType;
217213
}
218214

219-
#if RCT_NEW_ARCH_ENABLED
220215
- (BOOL)isViewParagraphComponent:(RNGHUIView *)view
221216
{
222217
return [view isKindOfClass:[RCTParagraphComponentView class]];
223218
}
224-
#endif
225219

226220
- (void)bindToView:(RNGHUIView *)view
227221
{
228222
self.recognizer.delegate = self;
229223

230-
#if RCT_NEW_ARCH_ENABLED
231-
// Starting from react-native 0.79 `RCTParagraphTextView` overrides `hitTest` method to return `nil`. This results in
232-
// native `UIGestureRecognizer` not responding to gestures. To fix this issue, we attach recognizer to its parent,
233-
// i.e. `RCTParagraphComponentView`.
224+
// Starting from react-native 0.79 `RCTParagraphTextView` overrides `hitTest` method to return `nil`.
225+
// This results in native `UIGestureRecognizer` not responding to gestures.
226+
// To fix this issue, we attach recognizer to its parent, i.e. `RCTParagraphComponentView`.
234227
RNGHUIView *recognizerView = [self isViewParagraphComponent:view.superview] ? view.superview : view;
235-
#else
236-
RNGHUIView *recognizerView = view;
237-
#endif
238228

239229
#if !TARGET_OS_OSX
240230
recognizerView.userInteractionEnabled = YES;
@@ -273,11 +263,7 @@ - (RNGestureHandlerEventExtraData *)eventExtraData:(UIGestureRecognizer *)recogn
273263
*/
274264
- (RNGHUIView *)chooseViewForInteraction:(UIGestureRecognizer *)recognizer
275265
{
276-
#if RCT_NEW_ARCH_ENABLED
277266
return [self isViewParagraphComponent:recognizer.view] ? recognizer.view.subviews[0] : recognizer.view;
278-
#else
279-
return recognizer.view;
280-
#endif
281267
}
282268

283269
- (void)handleGesture:(UIGestureRecognizer *)recognizer
@@ -595,20 +581,10 @@ - (BOOL)isUIScrollViewPanGestureRecognizer:(NSGestureRecognizer *)gestureRecogni
595581

596582
- (RNGHUIScrollView *)retrieveScrollView:(RNGHUIView *)view
597583
{
598-
#ifdef RCT_NEW_ARCH_ENABLED
599584
if ([view isKindOfClass:[RCTScrollViewComponentView class]]) {
600585
RNGHUIScrollView *scrollView = ((RCTScrollViewComponentView *)view).scrollView;
601586
return scrollView;
602587
}
603-
#else
604-
if ([view isKindOfClass:[RCTScrollView class]]) {
605-
// This part of the code is coupled with RN implementation of ScrollView native wrapper and
606-
// we expect for RCTScrollView component to contain a subclass of UIScrollview as the only
607-
// subview
608-
RNGHUIScrollView *scrollView = [view.subviews objectAtIndex:0];
609-
return scrollView;
610-
}
611-
#endif
612588

613589
return nil;
614590
}

packages/react-native-gesture-handler/apple/RNGestureHandlerButton.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,24 @@
1010

1111
#if TARGET_OS_OSX
1212

13-
#if RCT_NEW_ARCH_ENABLED
14-
1513
#include <react/renderer/core/LayoutMetrics.h>
1614

1715
@protocol RCTComponentViewProtocol;
1816

19-
#endif // RCT_NEW_ARCH_ENABLED
20-
2117
@interface RNGestureHandlerButton : NSControl
18+
2219
#else
2320
@interface RNGestureHandlerButton : UIControl
2421
#endif // TARGET_OS_OSX
22+
2523
/**
2624
* Insets used when hit testing inside this view.
2725
*/
2826
@property (nonatomic, assign) UIEdgeInsets hitTestEdgeInsets;
2927
@property (nonatomic, assign) CGFloat borderRadius;
3028
@property (nonatomic) BOOL userEnabled;
3129

32-
#if TARGET_OS_OSX && RCT_NEW_ARCH_ENABLED
30+
#if TARGET_OS_OSX
3331
- (void)mountChildComponentView:(RNGHUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
3432
- (void)unmountChildComponentView:(RNGHUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
3533
- (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics

packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414
#import <React/RCTUIKit.h>
1515
#endif
1616

17-
#if RCT_NEW_ARCH_ENABLED
18-
1917
#import <React/RCTConversions.h>
2018
#import <React/RCTFabricComponentsPlugins.h>
2119

22-
#endif
23-
2420
/**
2521
* Gesture Handler Button components overrides standard mechanism used by RN
2622
* to determine touch target, which normally would reurn the UIView that is placed
@@ -156,7 +152,9 @@ - (NSString *)accessibilityLabel
156152
}
157153
#endif
158154

159-
#if TARGET_OS_OSX && RCT_NEW_ARCH_ENABLED
155+
// TODO: Combine all "if TARGET_OS_OSX" macros in this file
156+
157+
#if TARGET_OS_OSX
160158
- (void)mountChildComponentView:(RNGHUIView *)childComponentView index:(NSInteger)index
161159
{
162160
if (childComponentView.superview != nil) {

packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#ifdef RCT_NEW_ARCH_ENABLED
2-
31
#if !TARGET_OS_OSX
42
#import <UIKit/UIKit.h>
53
#else
@@ -18,5 +16,3 @@ NS_ASSUME_NONNULL_BEGIN
1816
@end
1917

2018
NS_ASSUME_NONNULL_END
21-
22-
#endif // RCT_NEW_ARCH_ENABLED

packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#ifdef RCT_NEW_ARCH_ENABLED
2-
31
#import "RNGestureHandlerButtonComponentView.h"
42

53
#import <React/RCTConversions.h>
@@ -215,5 +213,3 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
215213
{
216214
return RNGestureHandlerButtonComponentView.class;
217215
}
218-
219-
#endif // RCT_NEW_ARCH_ENABLED

packages/react-native-gesture-handler/apple/RNGestureHandlerManager.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,10 @@
1111

1212
@interface RNGestureHandlerManager : NSObject
1313

14-
#ifdef RCT_NEW_ARCH_ENABLED
1514
@property (nonatomic, strong, readonly, nonnull) RNGestureHandlerRegistry *registry;
1615

1716
- (nonnull instancetype)initWithModuleRegistry:(nonnull RCTModuleRegistry *)moduleRegistry
1817
viewRegistry:(nonnull RCTViewRegistry *)viewRegistry;
19-
#else
20-
- (nonnull instancetype)initWithUIManager:(nonnull RCTUIManager *)uiManager
21-
eventDispatcher:(nonnull id<RCTEventDispatcherProtocol>)eventDispatcher;
22-
#endif // RCT_NEW_ARCH_ENABLED
2318

2419
- (void)createGestureHandler:(nonnull NSString *)handlerName
2520
tag:(nonnull NSNumber *)handlerTag

packages/react-native-gesture-handler/apple/RNGestureHandlerManager.mm

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@
1515
#import "RNGestureHandlerState.h"
1616
#import "RNRootViewGestureRecognizer.h"
1717

18-
#ifdef RCT_NEW_ARCH_ENABLED
1918
#import <React/RCTFabricModalHostViewController.h>
2019
#import <React/RCTSurfaceTouchHandler.h>
2120
#import <React/RCTSurfaceView.h>
2221
#import <React/RCTViewComponentView.h>
23-
#else
24-
#import <React/RCTTouchHandler.h>
25-
#endif // RCT_NEW_ARCH_ENABLED
2622

2723
#import "Handlers/RNFlingHandler.h"
2824
#import "Handlers/RNForceTouchHandler.h"
@@ -52,17 +48,12 @@ @implementation RNGestureHandlerManager {
5248
NSHashTable<RNRootViewGestureRecognizer *> *_rootViewGestureRecognizers;
5349
NSMutableDictionary<NSNumber *, NSNumber *> *_attachRetryCounter;
5450
NSMutableSet *_droppedHandlers;
55-
#ifdef RCT_NEW_ARCH_ENABLED
5651
RCTModuleRegistry *_moduleRegistry;
5752
RCTViewRegistry *_viewRegistry;
58-
#else
59-
RCTUIManager *_uiManager;
60-
#endif // RCT_NEW_ARCH_ENABLED
6153
id<RCTEventDispatcherProtocol> _eventDispatcher;
6254
id _reanimatedModule;
6355
}
6456

65-
#ifdef RCT_NEW_ARCH_ENABLED
6657
- (RNGestureHandlerRegistry *)registry
6758
{
6859
return _registry;
@@ -78,18 +69,6 @@ - (instancetype)initWithModuleRegistry:(RCTModuleRegistry *)moduleRegistry viewR
7869
}
7970
return self;
8071
}
81-
#else
82-
- (instancetype)initWithUIManager:(RCTUIManager *)uiManager
83-
eventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher
84-
{
85-
if ((self = [super init])) {
86-
_uiManager = uiManager;
87-
_eventDispatcher = eventDispatcher;
88-
[self initCommonProps];
89-
}
90-
return self;
91-
}
92-
#endif // RCT_NEW_ARCH_ENABLED
9372

9473
- (void)initCommonProps
9574
{
@@ -144,13 +123,8 @@ - (void)attachGestureHandler:(nonnull NSNumber *)handlerTag
144123
toViewWithTag:(nonnull NSNumber *)viewTag
145124
withActionType:(RNGestureHandlerActionType)actionType
146125
{
147-
#ifdef RCT_NEW_ARCH_ENABLED
148126
RNGHUIView *view = [_viewRegistry viewForReactTag:viewTag];
149-
#else
150-
RNGHUIView *view = [_uiManager viewForReactTag:viewTag];
151-
#endif // RCT_NEW_ARCH_ENABLED
152127

153-
#ifdef RCT_NEW_ARCH_ENABLED
154128
if (view == nil || view.superview == nil) {
155129
// There are a few reasons we could end up here:
156130
// - the native view corresponding to the viewtag hasn't yet been created
@@ -197,7 +171,6 @@ - (void)attachGestureHandler:(nonnull NSNumber *)handlerTag
197171

198172
view.reactTag = viewTag; // necessary for RNReanimated eventHash (e.g. "42onGestureHandlerEvent"), also will be
199173
// returned as event.target
200-
#endif // RCT_NEW_ARCH_ENABLED
201174

202175
[_registry attachHandlerWithTag:handlerTag toView:view withActionType:actionType];
203176

@@ -245,7 +218,6 @@ - (id)handlerWithTag:(NSNumber *)handlerTag
245218

246219
- (void)registerViewWithGestureRecognizerAttachedIfNeeded:(RNGHUIView *)childView
247220
{
248-
#ifdef RCT_NEW_ARCH_ENABLED
249221
RNGHUIView *touchHandlerView = childView;
250222

251223
#if !TARGET_OS_OSX
@@ -262,31 +234,6 @@ - (void)registerViewWithGestureRecognizerAttachedIfNeeded:(RNGHUIView *)childVie
262234
}
263235
#endif // !TARGET_OS_OSX
264236

265-
#else
266-
RNGHUIView *touchHandlerView = nil;
267-
268-
#if !TARGET_OS_OSX
269-
if ([[childView reactViewController] isKindOfClass:[RCTModalHostViewController class]]) {
270-
touchHandlerView = [childView reactViewController].view.subviews[0];
271-
} else {
272-
UIView *parent = childView;
273-
while (parent != nil && ![parent respondsToSelector:@selector(touchHandler)]) {
274-
parent = parent.superview;
275-
}
276-
277-
touchHandlerView = [[parent performSelector:@selector(touchHandler)] view];
278-
}
279-
#else
280-
NSView *parent = childView;
281-
while (parent != nil && ![parent respondsToSelector:@selector(touchHandler)]) {
282-
parent = parent.superview;
283-
}
284-
285-
touchHandlerView = [[parent performSelector:@selector(touchHandler)] view];
286-
#endif // !TARGET_OS_OSX
287-
288-
#endif // RCT_NEW_ARCH_ENABLED
289-
290237
if (touchHandlerView == nil) {
291238
return;
292239
}
@@ -337,11 +284,7 @@ - (void)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
337284

338285
// this way we can extract the touch handler on both architectures relatively easily
339286
for (UIGestureRecognizer *recognizer in [viewWithTouchHandler gestureRecognizers]) {
340-
#ifdef RCT_NEW_ARCH_ENABLED
341287
if ([recognizer isKindOfClass:[RCTSurfaceTouchHandler class]]) {
342-
#else
343-
if ([recognizer isKindOfClass:[RCTTouchHandler class]]) {
344-
#endif // RCT_NEW_ARCH_ENABLED
345288
touchHandler = recognizer;
346289
break;
347290
}
@@ -439,18 +382,11 @@ - (void)sendNativeTouchEventForGestureHandler:(RNGestureHandler *)handler withPo
439382
- (void)sendEventForReanimated:(RNGestureHandlerStateChange *)event
440383
{
441384
// Delivers the event to Reanimated.
442-
#ifdef RCT_NEW_ARCH_ENABLED
443-
// Send event directly to Reanimated
444385
if (_reanimatedModule == nil) {
445386
_reanimatedModule = [_moduleRegistry moduleForName:"ReanimatedModule"];
446387
}
447388

448389
[_reanimatedModule eventDispatcherWillDispatchEvent:event];
449-
#else
450-
// In the old architecture, Reanimated overwrites RCTEventDispatcher
451-
// with REAEventDispatcher and intercepts all direct events.
452-
[self sendEventForDirectEvent:event];
453-
#endif // RCT_NEW_ARCH_ENABLED
454390
}
455391

456392
- (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
@@ -465,11 +401,7 @@ - (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
465401
- (void)sendEventForJSFunctionOldAPI:(RNGestureHandlerStateChange *)event
466402
{
467403
// Delivers the event to JS (old RNGH API).
468-
#ifdef RCT_NEW_ARCH_ENABLED
469404
[self sendEventForDeviceEvent:event];
470-
#else
471-
[self sendEventForDirectEvent:event];
472-
#endif // RCT_NEW_ARCH_ENABLED
473405
}
474406

475407
- (void)sendEventForJSFunctionNewAPI:(RNGestureHandlerStateChange *)event
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
#import <React/RCTEventEmitter.h>
2-
#import <React/RCTUIManager.h>
3-
4-
#ifdef RCT_NEW_ARCH_ENABLED
51
#import <React/RCTEventDispatcherProtocol.h>
2+
#import <React/RCTEventEmitter.h>
63
#import <React/RCTInitializing.h>
4+
#import <React/RCTUIManager.h>
75
#import <rngesturehandler_codegen/rngesturehandler_codegen.h>
8-
#else
9-
#import <React/RCTBridgeModule.h>
10-
#endif
116

127
#import "RNGestureHandlerManager.h"
138

14-
@interface RNGestureHandlerModule : RCTEventEmitter
15-
#ifdef RCT_NEW_ARCH_ENABLED
16-
<NativeRNGestureHandlerModuleSpec, RCTJSDispatcherModule, RCTInitializing>
9+
@interface RNGestureHandlerModule : RCTEventEmitter<NativeRNGestureHandlerModuleSpec, RCTJSDispatcherModule, RCTInitializing>
1710

1811
+ (RNGestureHandlerManager *)handlerManagerForModuleId:(int)moduleId;
19-
#else
20-
<RCTBridgeModule>
21-
#endif
2212

2313
@end

0 commit comments

Comments
 (0)