From 800eec8801667877cb1a5ce555b814628d461016 Mon Sep 17 00:00:00 2001 From: Lucas Twisk Date: Tue, 8 Dec 2020 23:41:29 +0100 Subject: [PATCH] Fix react-native-gesture-handler --- .../README.md | 28 +++++++++++ .../RNGestureHandlerPackagePlugin.java | 16 ++++++ .../config.json | 49 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/README.md create mode 100644 plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/RNGestureHandlerPackagePlugin.java create mode 100644 plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/config.json diff --git a/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/README.md b/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/README.md new file mode 100644 index 0000000..272eea8 --- /dev/null +++ b/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/README.md @@ -0,0 +1,28 @@ +## [React Native Gesture Handler](https://github.com/kmagiera/react-native-gesture-handler) plugin. + +### Prerequisites +[Electrode Native](https://github.com/electrode-io/electrode-native) >= 0.38.0 + +### To add this plugion to your miniapp + +`ern add react-native-gesture-handler` + +## For Android + +Create a custom delegate(`ReactNativeGestureDelegate.java`) by extending `ElectrodeReactFragmentActivityDelegate.java` and override the following method. + +```java +@Override +protected ReactRootView createRootView() { + return new RNGestureHandlerEnabledRootView(getContext()); +} +``` + +Then use this delegate in your activity. If your activity is extending `ElectrodeBaseActivity.java` then override the following method as below. + +```java +@NonNull +protected ElectrodeReactFragmentActivityDelegate createElectrodeDelegate() { + return new ReactNativeGestureDelegate(this); +} +``` diff --git a/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/RNGestureHandlerPackagePlugin.java b/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/RNGestureHandlerPackagePlugin.java new file mode 100644 index 0000000..c808720 --- /dev/null +++ b/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/RNGestureHandlerPackagePlugin.java @@ -0,0 +1,16 @@ +package com.walmartlabs.ern.container.plugins; + +import android.app.Application; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import com.facebook.react.ReactInstanceManagerBuilder; +import com.facebook.react.ReactPackage; +import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; + +public class RNGestureHandlerPackagePlugin implements ReactPlugin { + public ReactPackage hook(@NonNull Application application, + @Nullable ReactPluginConfig config) { + return new RNGestureHandlerPackage(); + } +} diff --git a/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/config.json b/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/config.json new file mode 100644 index 0000000..0b1ff67 --- /dev/null +++ b/plugins/ern_v0.34.0+/react-native-gesture-handler_v1.4.1+/config.json @@ -0,0 +1,49 @@ +{ + "android": { + "root": "android", + "dependencies": [], + "copy": [ + { + "dest": "lib/src/main/java/com/swmansion/gesturehandler", + "source": "android/lib/*" + } + ], + "replaceInFile": [ + { + "path": "lib/src/main/java/com/walmartlabs/ern/container/ElectrodeReactActivityDelegate.java", + "string": "import com.facebook.react.ReactRootView;", + "replaceWith": "import com.facebook.react.ReactRootView;\nimport com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;" + }, + { + "path": "lib/src/main/java/com/walmartlabs/ern/container/ElectrodeReactActivityDelegate.java", + "string": " }\n}", + "replaceWith": " }\n\n @Override\n protected ReactRootView createRootView() {\n return new RNGestureHandlerEnabledRootView(getContext());\n }\n}" + } + ] + }, + "ios": { + "copy": [ + { + "dest": "{{{projectName}}}/Libraries/RNGestureHandler", + "source": "ios/**" + } + ], + "pbxproj": { + "addHeaderSearchPath": [ + "\"$(SRCROOT)/{{{projectName}}}/Libraries/RNGestureHandler/**\"" + ], + "addProject": [ + { + "group": "Libraries", + "path": "RNGestureHandler/RNGestureHandler.xcodeproj", + "staticLibs": [ + { + "name": "libRNGestureHandler.a", + "target": "RNGestureHandler" + } + ] + } + ] + } + } +}