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

Fix react-native-gesture-handler #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ElectrodeReactFragmentActivityDelegate is deprecated. Please use ElectrodeNavigationActivityDelegate instead.


```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"
}
]
}
]
}
}
}