Skip to content

Remove paper support #3238

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

Draft
wants to merge 8 commits into
base: main
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
8 changes: 0 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,6 @@ android {
srcDirs += 'noreanimated/src/main/java'
}

if (isNewArchitectureEnabled()) {
srcDirs += 'fabric/src/main/java'
} else {
// this folder also includes files from codegen so the library can compile with
// codegen turned off
srcDirs += 'paper/src/main/java'
}

if (REACT_NATIVE_MINOR_VERSION >= 77) {
// With RN 0.77, ViewManager related functions in the package has different signatures as they
// are no longer nullable
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
const val DIRECTION_DOWN = 8
const val ACTION_TYPE_REANIMATED_WORKLET = 1
const val ACTION_TYPE_NATIVE_ANIMATED_EVENT = 2
const val ACTION_TYPE_JS_FUNCTION_OLD_API = 3
const val ACTION_TYPE_JS_FUNCTION_OLD_API = 3 // %% remove?
const val ACTION_TYPE_JS_FUNCTION_NEW_API = 4
const val POINTER_TYPE_TOUCH = 0
const val POINTER_TYPE_STYLUS = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,6 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
useTopPrefixedName = BuildConfig.REACT_NATIVE_MINOR_VERSION >= 71
)
sendEventForNativeAnimatedEvent(event)
} else if (handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_OLD_API) {
// JS function, Animated.event with useNativeDriver: false using old API
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
val data = RNGestureHandlerEvent.createEventData(handlerFactory.createEventBuilder(handler))
sendEventForDeviceEvent(RNGestureHandlerEvent.EVENT_NAME, data)
} else {
val event = RNGestureHandlerEvent.obtain(handler, handlerFactory.createEventBuilder(handler))
sendEventForDirectEvent(event)
}
} else if (handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_NEW_API) {
// JS function, Animated.event with useNativeDriver: false using new API
val data = RNGestureHandlerEvent.createEventData(handlerFactory.createEventBuilder(handler))
Expand All @@ -581,17 +572,10 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
// Reanimated worklet
val event = RNGestureHandlerStateChangeEvent.obtain(handler, newState, oldState, handlerFactory.createEventBuilder(handler))
sendEventForReanimated(event)
} else if (handler.actionType == GestureHandler.ACTION_TYPE_NATIVE_ANIMATED_EVENT ||
handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_OLD_API
} else if (handler.actionType == GestureHandler.ACTION_TYPE_NATIVE_ANIMATED_EVENT
) {
// JS function or Animated.event with useNativeDriver: false with old API
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
val data = RNGestureHandlerStateChangeEvent.createEventData(handlerFactory.createEventBuilder(handler), newState, oldState)
sendEventForDeviceEvent(RNGestureHandlerStateChangeEvent.EVENT_NAME, data)
} else {
val event = RNGestureHandlerStateChangeEvent.obtain(handler, newState, oldState, handlerFactory.createEventBuilder(handler))
sendEventForDirectEvent(event)
}
val data = RNGestureHandlerStateChangeEvent.createEventData(handlerFactory.createEventBuilder(handler), newState, oldState)
sendEventForDeviceEvent(RNGestureHandlerStateChangeEvent.EVENT_NAME, data)
} else if (handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_NEW_API) {
// JS function or Animated.event with useNativeDriver: false with new API
val data = RNGestureHandlerStateChangeEvent.createEventData(handlerFactory.createEventBuilder(handler), newState, oldState)
Expand Down Expand Up @@ -623,13 +607,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :

private fun <T : Event<T>>sendEventForReanimated(event: T) {
// Delivers the event to Reanimated.
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// Send event directly to Reanimated
reanimatedEventDispatcher.sendEvent(event, reactApplicationContext)
} else {
// In the old architecture, Reanimated subscribes for specific direct events.
sendEventForDirectEvent(event)
}
reanimatedEventDispatcher.sendEvent(event, reactApplicationContext)
}

private fun sendEventForNativeAnimatedEvent(event: RNGestureHandlerEvent) {
Expand All @@ -640,11 +618,6 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
reactApplicationContext.dispatchEvent(event)
}

private fun <T : Event<T>>sendEventForDirectEvent(event: T) {
// Delivers the event to JS as a direct event. This method is called only on Paper.
reactApplicationContext.dispatchEvent(event)
}

private fun sendEventForDeviceEvent(eventName: String, data: WritableMap) {
// Delivers the event to JS as a device event.
reactApplicationContext.deviceEventEmitter.emit(eventName, data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
jsGestureHandler = RootViewGestureHandler().apply { tag = -wrappedViewTag }
with(registry) {
registerHandler(jsGestureHandler)
// %% is this also called on NEW API? Can this be changed?
attachHandlerToView(jsGestureHandler.tag, wrappedViewTag, GestureHandler.ACTION_TYPE_JS_FUNCTION_OLD_API)
}
module.registerRootHelper(this)
Expand Down
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 @@ -546,20 +542,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,26 +10,23 @@

#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, assign) CGFloat borderRadius;
@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
Loading
Loading