Skip to content

Commit

Permalink
Add source sets for generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bert committed Feb 19, 2025
1 parent 8b338fb commit a698648
Show file tree
Hide file tree
Showing 9 changed files with 219 additions and 4 deletions.
9 changes: 7 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ android {
if (isNewArchitectureEnabled()) {
srcDirs += 'fabric/src/main/java'
} else {
// this folder also includes files from codegen so the library can compile with
// 'paper/src/main/java' includes files from codegen so the library can compile with
// codegen turned off
srcDirs += 'paper/src/main/java'

if (REACT_NATIVE_MINOR_VERSION > 77){
srcDirs += 'paper/src/main/java'
} else {
srcDirs += 'paper77/src/main/java'
}
}

if (REACT_NATIVE_MINOR_VERSION >= 77) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;

public interface RNGestureHandlerButtonManagerInterface<T extends View> {
public interface RNGestureHandlerButtonManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
void setExclusive(T view, boolean value);
void setForeground(T view, boolean value);
void setBorderless(T view, boolean value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
package com.facebook.react.viewmanagers;

import android.view.View;
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;

public interface RNGestureHandlerRootViewManagerInterface<T extends View> {
public interface RNGestureHandlerRootViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
// No props
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/

package com.facebook.react.viewmanagers;

import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.ColorPropConverter;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNGestureHandlerButtonManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNGestureHandlerButtonManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNGestureHandlerButtonManagerDelegate(U viewManager) {
super(viewManager);
}
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
switch (propName) {
case "exclusive":
mViewManager.setExclusive(view, value == null ? true : (boolean) value);
break;
case "foreground":
mViewManager.setForeground(view, value == null ? false : (boolean) value);
break;
case "borderless":
mViewManager.setBorderless(view, value == null ? false : (boolean) value);
break;
case "enabled":
mViewManager.setEnabled(view, value == null ? true : (boolean) value);
break;
case "rippleColor":
mViewManager.setRippleColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "rippleRadius":
mViewManager.setRippleRadius(view, value == null ? 0 : ((Double) value).intValue());
break;
case "touchSoundDisabled":
mViewManager.setTouchSoundDisabled(view, value == null ? false : (boolean) value);
break;
case "borderWidth":
mViewManager.setBorderWidth(view, value == null ? 0f : ((Double) value).floatValue());
break;
case "borderColor":
mViewManager.setBorderColor(view, ColorPropConverter.getColor(value, view.getContext()));
break;
case "borderStyle":
mViewManager.setBorderStyle(view, value == null ? "solid" : (String) value);
break;
default:
super.setProperty(view, propName, value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaInterface.js
*/

package com.facebook.react.viewmanagers;

import android.view.View;
import androidx.annotation.Nullable;

public interface RNGestureHandlerButtonManagerInterface<T extends View> {
void setExclusive(T view, boolean value);
void setForeground(T view, boolean value);
void setBorderless(T view, boolean value);
void setEnabled(T view, boolean value);
void setRippleColor(T view, @Nullable Integer value);
void setRippleRadius(T view, int value);
void setTouchSoundDisabled(T view, boolean value);
void setBorderWidth(T view, float value);
void setBorderColor(T view, @Nullable Integer value);
void setBorderStyle(T view, @Nullable String value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/

package com.facebook.react.viewmanagers;

import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;

public class RNGestureHandlerRootViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & RNGestureHandlerRootViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNGestureHandlerRootViewManagerDelegate(U viewManager) {
super(viewManager);
}
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
super.setProperty(view, propName, value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaInterface.js
*/

package com.facebook.react.viewmanagers;

import android.view.View;

public interface RNGestureHandlerRootViewManagerInterface<T extends View> {
// No props
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleJavaSpec.js
*
* @nolint
*/

package com.swmansion.gesturehandler;

import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReactModuleWithSpec;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import javax.annotation.Nonnull;

public abstract class NativeRNGestureHandlerModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
public static final String NAME = "RNGestureHandlerModule";

public NativeRNGestureHandlerModuleSpec(ReactApplicationContext reactContext) {
super(reactContext);
}

@Override
public @Nonnull String getName() {
return NAME;
}

@ReactMethod
@DoNotStrip
public abstract void handleSetJSResponder(double tag, boolean blockNativeResponder);

@ReactMethod
@DoNotStrip
public abstract void handleClearJSResponder();

@ReactMethod
@DoNotStrip
public abstract void createGestureHandler(String handlerName, double handlerTag, ReadableMap config);

@ReactMethod
@DoNotStrip
public abstract void attachGestureHandler(double handlerTag, double newView, double actionType);

@ReactMethod
@DoNotStrip
public abstract void updateGestureHandler(double handlerTag, ReadableMap newConfig);

@ReactMethod
@DoNotStrip
public abstract void dropGestureHandler(double handlerTag);

@ReactMethod(isBlockingSynchronousMethod = true)
@DoNotStrip
public abstract boolean install();

@ReactMethod
@DoNotStrip
public abstract void flushOperations();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.swmansion.gesturehandler

import com.facebook.react.bridge.ReactContext
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.events.Event

fun ReactContext.dispatchEvent(event: Event<*>) {
try {
this.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher.dispatchEvent(event)
} catch (e: NullPointerException) {
throw Exception("Couldn't get an instance of UIManagerModule. Gesture Handler is unable to send an event.", e)
}
}

0 comments on commit a698648

Please sign in to comment.