Skip to content

Commit 257042f

Browse files
committed
remove all obj-c old arch macros
1 parent 7eb3e54 commit 257042f

13 files changed

+18
-223
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
@@ -72,9 +72,7 @@
7272
@property (nonatomic) BOOL needsPointerData;
7373
@property (nonatomic) BOOL manualActivation;
7474

75-
#if RCT_NEW_ARCH_ENABLED
7675
- (BOOL)isViewParagraphComponent:(nullable RNGHUIView *)view;
77-
#endif
7876
- (nonnull RNGHUIView *)chooseViewForInteraction:(nonnull UIGestureRecognizer *)recognizer;
7977
- (void)bindToView:(nonnull RNGHUIView *)view;
8078
- (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
@@ -581,20 +567,10 @@ - (BOOL)isUIScrollViewPanGestureRecognizer:(NSGestureRecognizer *)gestureRecogni
581567

582568
- (RNGHUIScrollView *)retrieveScrollView:(RNGHUIView *)view
583569
{
584-
#ifdef RCT_NEW_ARCH_ENABLED
585570
if ([view isKindOfClass:[RCTScrollViewComponentView class]]) {
586571
RNGHUIScrollView *scrollView = ((RCTScrollViewComponentView *)view).scrollView;
587572
return scrollView;
588573
}
589-
#else
590-
if ([view isKindOfClass:[RCTScrollView class]]) {
591-
// This part of the code is coupled with RN implementation of ScrollView native wrapper and
592-
// we expect for RCTScrollView component to contain a subclass of UIScrollview as the only
593-
// subview
594-
RNGHUIScrollView *scrollView = [view.subviews objectAtIndex:0];
595-
return scrollView;
596-
}
597-
#endif
598574

599575
return nil;
600576
}

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
@@ -9,13 +9,8 @@
99

1010
@interface RNGestureHandlerManager : NSObject
1111

12-
#ifdef RCT_NEW_ARCH_ENABLED
1312
- (nonnull instancetype)initWithModuleRegistry:(nonnull RCTModuleRegistry *)moduleRegistry
1413
viewRegistry:(nonnull RCTViewRegistry *)viewRegistry;
15-
#else
16-
- (nonnull instancetype)initWithUIManager:(nonnull RCTUIManager *)uiManager
17-
eventDispatcher:(nonnull id<RCTEventDispatcherProtocol>)eventDispatcher;
18-
#endif // RCT_NEW_ARCH_ENABLED
1914

2015
- (void)createGestureHandler:(nonnull NSString *)handlerName
2116
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
- (instancetype)initWithModuleRegistry:(RCTModuleRegistry *)moduleRegistry viewRegistry:(RCTViewRegistry *)viewRegistry
6758
{
6859
if ((self = [super init])) {
@@ -73,18 +64,6 @@ - (instancetype)initWithModuleRegistry:(RCTModuleRegistry *)moduleRegistry viewR
7364
}
7465
return self;
7566
}
76-
#else
77-
- (instancetype)initWithUIManager:(RCTUIManager *)uiManager
78-
eventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher
79-
{
80-
if ((self = [super init])) {
81-
_uiManager = uiManager;
82-
_eventDispatcher = eventDispatcher;
83-
[self initCommonProps];
84-
}
85-
return self;
86-
}
87-
#endif // RCT_NEW_ARCH_ENABLED
8867

8968
- (void)initCommonProps
9069
{
@@ -139,13 +118,8 @@ - (void)attachGestureHandler:(nonnull NSNumber *)handlerTag
139118
toViewWithTag:(nonnull NSNumber *)viewTag
140119
withActionType:(RNGestureHandlerActionType)actionType
141120
{
142-
#ifdef RCT_NEW_ARCH_ENABLED
143121
RNGHUIView *view = [_viewRegistry viewForReactTag:viewTag];
144-
#else
145-
RNGHUIView *view = [_uiManager viewForReactTag:viewTag];
146-
#endif // RCT_NEW_ARCH_ENABLED
147122

148-
#ifdef RCT_NEW_ARCH_ENABLED
149123
if (view == nil || view.superview == nil) {
150124
// There are a few reasons we could end up here:
151125
// - the native view corresponding to the viewtag hasn't yet been created
@@ -192,7 +166,6 @@ - (void)attachGestureHandler:(nonnull NSNumber *)handlerTag
192166

193167
view.reactTag = viewTag; // necessary for RNReanimated eventHash (e.g. "42onGestureHandlerEvent"), also will be
194168
// returned as event.target
195-
#endif // RCT_NEW_ARCH_ENABLED
196169

197170
[_registry attachHandlerWithTag:handlerTag toView:view withActionType:actionType];
198171

@@ -240,7 +213,6 @@ - (id)handlerWithTag:(NSNumber *)handlerTag
240213

241214
- (void)registerViewWithGestureRecognizerAttachedIfNeeded:(RNGHUIView *)childView
242215
{
243-
#ifdef RCT_NEW_ARCH_ENABLED
244216
RNGHUIView *touchHandlerView = childView;
245217

246218
#if !TARGET_OS_OSX
@@ -257,31 +229,6 @@ - (void)registerViewWithGestureRecognizerAttachedIfNeeded:(RNGHUIView *)childVie
257229
}
258230
#endif // !TARGET_OS_OSX
259231

260-
#else
261-
RNGHUIView *touchHandlerView = nil;
262-
263-
#if !TARGET_OS_OSX
264-
if ([[childView reactViewController] isKindOfClass:[RCTModalHostViewController class]]) {
265-
touchHandlerView = [childView reactViewController].view.subviews[0];
266-
} else {
267-
UIView *parent = childView;
268-
while (parent != nil && ![parent respondsToSelector:@selector(touchHandler)]) {
269-
parent = parent.superview;
270-
}
271-
272-
touchHandlerView = [[parent performSelector:@selector(touchHandler)] view];
273-
}
274-
#else
275-
NSView *parent = childView;
276-
while (parent != nil && ![parent respondsToSelector:@selector(touchHandler)]) {
277-
parent = parent.superview;
278-
}
279-
280-
touchHandlerView = [[parent performSelector:@selector(touchHandler)] view];
281-
#endif // !TARGET_OS_OSX
282-
283-
#endif // RCT_NEW_ARCH_ENABLED
284-
285232
if (touchHandlerView == nil) {
286233
return;
287234
}
@@ -332,11 +279,7 @@ - (void)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
332279

333280
// this way we can extract the touch handler on both architectures relatively easily
334281
for (UIGestureRecognizer *recognizer in [viewWithTouchHandler gestureRecognizers]) {
335-
#ifdef RCT_NEW_ARCH_ENABLED
336282
if ([recognizer isKindOfClass:[RCTSurfaceTouchHandler class]]) {
337-
#else
338-
if ([recognizer isKindOfClass:[RCTTouchHandler class]]) {
339-
#endif // RCT_NEW_ARCH_ENABLED
340283
touchHandler = recognizer;
341284
break;
342285
}
@@ -378,18 +321,11 @@ - (void)sendEvent:(RNGestureHandlerStateChange *)event withActionType:(RNGesture
378321
- (void)sendEventForReanimated:(RNGestureHandlerStateChange *)event
379322
{
380323
// Delivers the event to Reanimated.
381-
#ifdef RCT_NEW_ARCH_ENABLED
382-
// Send event directly to Reanimated
383324
if (_reanimatedModule == nil) {
384325
_reanimatedModule = [_moduleRegistry moduleForName:"ReanimatedModule"];
385326
}
386327

387328
[_reanimatedModule eventDispatcherWillDispatchEvent:event];
388-
#else
389-
// In the old architecture, Reanimated overwrites RCTEventDispatcher
390-
// with REAEventDispatcher and intercepts all direct events.
391-
[self sendEventForDirectEvent:event];
392-
#endif // RCT_NEW_ARCH_ENABLED
393329
}
394330

395331
- (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
@@ -404,11 +340,7 @@ - (void)sendEventForNativeAnimatedEvent:(RNGestureHandlerStateChange *)event
404340
- (void)sendEventForJSFunctionOldAPI:(RNGestureHandlerStateChange *)event
405341
{
406342
// Delivers the event to JS (old RNGH API).
407-
#ifdef RCT_NEW_ARCH_ENABLED
408343
[self sendEventForDeviceEvent:event];
409-
#else
410-
[self sendEventForDirectEvent:event];
411-
#endif // RCT_NEW_ARCH_ENABLED
412344
}
413345

414346
- (void)sendEventForJSFunctionNewAPI:(RNGestureHandlerStateChange *)event
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
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

12-
@interface RNGestureHandlerModule : RCTEventEmitter
13-
#ifdef RCT_NEW_ARCH_ENABLED
14-
<NativeRNGestureHandlerModuleSpec, RCTJSDispatcherModule, RCTInitializing>
15-
#else
16-
<RCTBridgeModule>
17-
#endif
7+
@interface RNGestureHandlerModule
8+
: RCTEventEmitter <NativeRNGestureHandlerModuleSpec, RCTJSDispatcherModule, RCTInitializing>
189

1910
@end

0 commit comments

Comments
 (0)