Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove paper support #3238

Draft
wants to merge 2 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions apple/Handlers/RNNativeViewHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
#import <React/RCTConvert.h>
#import <React/UIView+React.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTScrollViewComponentView.h>
#else
#import <React/RCTScrollView.h>
#endif // RCT_NEW_ARCH_ENABLED

#pragma mark RNDummyGestureRecognizer

Expand Down
14 changes: 0 additions & 14 deletions apple/RNGestureHandler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@

#import <React/UIView+React.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTScrollViewComponentView.h>
#else
#import <React/RCTScrollView.h>
#endif

@interface UIGestureRecognizer (GestureHandler)
@property (nonatomic, readonly) RNGestureHandler *gestureHandler;
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 2 additions & 5 deletions apple/RNGestureHandlerButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,22 @@

#if TARGET_OS_OSX

#if RCT_NEW_ARCH_ENABLED

#include <react/renderer/core/LayoutMetrics.h>

@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<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
- (void)unmountChildComponentView:(RNGHUIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
- (void)updateLayoutMetrics:(const facebook::react::LayoutMetrics &)layoutMetrics
Expand Down
8 changes: 1 addition & 7 deletions apple/RNGestureHandlerButton.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
#import <React/RCTUIKit.h>
#endif

#if RCT_NEW_ARCH_ENABLED

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>

#endif

/**
* Gesture Handler Button components overrides standard mechanism used by RN
* to determine touch target, which normally would reurn the UIView that is placed
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions apple/RNGestureHandlerButtonComponentView.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef RCT_NEW_ARCH_ENABLED

#if !TARGET_OS_OSX
#import <UIKit/UIKit.h>
#else
Expand All @@ -17,5 +15,3 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

#endif // RCT_NEW_ARCH_ENABLED
6 changes: 1 addition & 5 deletions apple/RNGestureHandlerButtonComponentView.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef RCT_NEW_ARCH_ENABLED

#import "RNGestureHandlerButtonComponentView.h"

#import <React/RCTConversions.h>
Expand Down Expand Up @@ -119,6 +117,4 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
Class<RCTComponentViewProtocol> RNGestureHandlerButtonCls(void)
{
return RNGestureHandlerButtonComponentView.class;
}

#endif // RCT_NEW_ARCH_ENABLED
}
5 changes: 0 additions & 5 deletions apple/RNGestureHandlerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<RCTEventDispatcherProtocol>)eventDispatcher;
#endif // RCT_NEW_ARCH_ENABLED

- (void)createGestureHandler:(nonnull NSString *)handlerName
tag:(nonnull NSNumber *)handlerTag
Expand Down
68 changes: 1 addition & 67 deletions apple/RNGestureHandlerManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@
#import "RNGestureHandlerState.h"
#import "RNRootViewGestureRecognizer.h"

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTFabricModalHostViewController.h>
#import <React/RCTSurfaceTouchHandler.h>
#import <React/RCTSurfaceView.h>
#import <React/RCTViewComponentView.h>
#else
#import <React/RCTTouchHandler.h>
#endif // RCT_NEW_ARCH_ENABLED

#import "Handlers/RNFlingHandler.h"
#import "Handlers/RNForceTouchHandler.h"
Expand Down Expand Up @@ -51,17 +47,12 @@ @implementation RNGestureHandlerManager {
RNGestureHandlerRegistry *_registry;
NSHashTable<RNRootViewGestureRecognizer *> *_rootViewGestureRecognizers;
NSMutableDictionary<NSNumber *, NSNumber *> *_attachRetryCounter;
#ifdef RCT_NEW_ARCH_ENABLED
RCTModuleRegistry *_moduleRegistry;
RCTViewRegistry *_viewRegistry;
#else
RCTUIManager *_uiManager;
#endif // RCT_NEW_ARCH_ENABLED
id<RCTEventDispatcherProtocol> _eventDispatcher;
id _reanimatedModule;
}

#ifdef RCT_NEW_ARCH_ENABLED
- (instancetype)initWithModuleRegistry:(RCTModuleRegistry *)moduleRegistry viewRegistry:(RCTViewRegistry *)viewRegistry
{
if ((self = [super init])) {
Expand All @@ -72,18 +63,6 @@ - (instancetype)initWithModuleRegistry:(RCTModuleRegistry *)moduleRegistry viewR
}
return self;
}
#else
- (instancetype)initWithUIManager:(RCTUIManager *)uiManager
eventDispatcher:(id<RCTEventDispatcherProtocol>)eventDispatcher
{
if ((self = [super init])) {
_uiManager = uiManager;
_eventDispatcher = eventDispatcher;
[self initCommonProps];
}
return self;
}
#endif // RCT_NEW_ARCH_ENABLED

- (void)initCommonProps
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -235,7 +208,6 @@ - (id)handlerWithTag:(NSNumber *)handlerTag

- (void)registerViewWithGestureRecognizerAttachedIfNeeded:(RNGHUIView *)childView
{
#ifdef RCT_NEW_ARCH_ENABLED
RNGHUIView *touchHandlerView = childView;

#if !TARGET_OS_OSX
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
11 changes: 1 addition & 10 deletions apple/RNGestureHandlerModule.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
#import <React/RCTEventEmitter.h>
#import <React/RCTUIManager.h>

#ifdef RCT_NEW_ARCH_ENABLED
#import <React/RCTEventDispatcherProtocol.h>
#import <React/RCTInitializing.h>
#import <rngesturehandler_codegen/rngesturehandler_codegen.h>
#else
#import <React/RCTBridgeModule.h>
#endif

@interface RNGestureHandlerModule : RCTEventEmitter
#ifdef RCT_NEW_ARCH_ENABLED
<NativeRNGestureHandlerModuleSpec, RCTJSDispatcherModule, RCTInitializing>
#else
<RCTBridgeModule>
#endif
@interface RNGestureHandlerModule : RCTEventEmitter <NativeRNGestureHandlerModuleSpec, RCTJSDispatcherModule, RCTInitializing>

@end
Loading
Loading