Skip to content

Commit

Permalink
Fix react-native-gesture-handler
Browse files Browse the repository at this point in the history
  • Loading branch information
LcTwisk committed Dec 8, 2020
1 parent 1d234aa commit 800eec8
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
```
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
}
}

0 comments on commit 800eec8

Please sign in to comment.