-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/wordpress-mobile/gutenber…
…g-mobile into issue/167-merge-refresh-android * 'master' of https://github.com/wordpress-mobile/gutenberg-mobile: (35 commits) Point to latest from RecyclerViewList Point to latest react-native-aztec Adding yarn.lock field for `turbo-combine-reducers`. Added turbo-combine-reducers dependency to fix failed builds Update subrepo ref to point to master again Update subrepo ref No need for change of default Jest platform Update subrepo ref Update subrepo ref to point to master again Update subrepo ref Update subrepo ref Update subrepo ref Update subrepo ref Add symlink in symlinked-packages-in-parent for notices Add symlink for notices package to fix the failing CI tests Update subrepo by merging from master Add support for nextpage block Fix lint warnings Mocking `react-native-gutenberg-bridge` to make iOS tests pass. From: jestjs/jest#2208 (comment) rn-gutenberg-bridge: Adding dumb iOS implementation to avoid errors. ...
- Loading branch information
Showing
34 changed files
with
705 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
jest.mock( '../react-native-gutenberg-bridge', () => { | ||
return { | ||
addEventListener: jest.fn(), | ||
removeEventListener: jest.fn(), | ||
subscribeParentGetHtml: jest.fn(), | ||
}; | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pbxproj -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
|
||
# Android/IntelliJ | ||
# | ||
build/ | ||
.idea | ||
.gradle | ||
local.properties | ||
*.iml | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
*.keystore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
# react-native-gutenberg-bridge | ||
|
||
## Getting started | ||
|
||
`$ npm install react-native-gutenberg-bridge --save` | ||
|
||
### Mostly automatic installation | ||
|
||
`$ react-native link react-native-gutenberg-bridge` | ||
|
||
### Manual installation | ||
|
||
|
||
#### iOS | ||
|
||
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` | ||
2. Go to `node_modules` ➜ `react-native-gutenberg-bridge` and add `RNReactNativeGutenbergBridge.xcodeproj` | ||
3. In XCode, in the project navigator, select your project. Add `libRNReactNativeGutenbergBridge.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` | ||
4. Run your project (`Cmd+R`)< | ||
|
||
#### Android | ||
|
||
1. Open up `android/app/src/main/java/[...]/MainActivity.java` | ||
- Add `import com.reactlibrary.RNReactNativeGutenbergBridgePackage;` to the imports at the top of the file | ||
- Add `new RNReactNativeGutenbergBridgePackage()` to the list returned by the `getPackages()` method | ||
2. Append the following lines to `android/settings.gradle`: | ||
``` | ||
include ':react-native-gutenberg-bridge' | ||
project(':react-native-gutenberg-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gutenberg-bridge/android') | ||
``` | ||
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`: | ||
``` | ||
compile project(':react-native-gutenberg-bridge') | ||
``` | ||
|
||
## Usage | ||
```javascript | ||
import RNReactNativeGutenbergBridge from 'react-native-gutenberg-bridge'; | ||
|
||
// TODO: What to do with the module? | ||
RNReactNativeGutenbergBridge; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
google() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.1.4' | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 27 | ||
buildToolsVersion "27.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'com.facebook.react:react-native:+' | ||
} |
5 changes: 5 additions & 0 deletions
5
react-native-gutenberg-bridge/android/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="org.wordpress.mobile.ReactNativeGutenbergBridge"> | ||
|
||
</manifest> |
5 changes: 5 additions & 0 deletions
5
...c/main/java/org/wordpress/mobile/ReactNativeGutenbergBridge/GutenbergBridgeJS2Parent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.wordpress.mobile.ReactNativeGutenbergBridge; | ||
|
||
public interface GutenbergBridgeJS2Parent { | ||
void responseHtml(String html); | ||
} |
39 changes: 39 additions & 0 deletions
39
...a/org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgeModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.wordpress.mobile.ReactNativeGutenbergBridge; | ||
|
||
import android.support.annotation.Nullable; | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
import com.facebook.react.bridge.WritableMap; | ||
import com.facebook.react.modules.core.DeviceEventManagerModule; | ||
|
||
public class RNReactNativeGutenbergBridgeModule extends ReactContextBaseJavaModule { | ||
private final ReactApplicationContext mReactContext; | ||
private final GutenbergBridgeJS2Parent mGutenbergBridgeJS2Parent; | ||
|
||
public RNReactNativeGutenbergBridgeModule(ReactApplicationContext reactContext, | ||
GutenbergBridgeJS2Parent gutenbergBridgeJS2Parent) { | ||
super(reactContext); | ||
mReactContext = reactContext; | ||
mGutenbergBridgeJS2Parent = gutenbergBridgeJS2Parent; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "RNReactNativeGutenbergBridge"; | ||
} | ||
|
||
private void emitToJS(String eventName, @Nullable WritableMap data) { | ||
mReactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data); | ||
} | ||
|
||
public void getHtmlFromJS() { | ||
emitToJS("requestGetHtml", null); | ||
} | ||
|
||
@ReactMethod | ||
public void provideToNative_Html(String html) { | ||
mGutenbergBridgeJS2Parent.responseHtml(html); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
.../org/wordpress/mobile/ReactNativeGutenbergBridge/RNReactNativeGutenbergBridgePackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.wordpress.mobile.ReactNativeGutenbergBridge; | ||
|
||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class RNReactNativeGutenbergBridgePackage implements ReactPackage { | ||
private GutenbergBridgeJS2Parent mGutenbergBridgeJS2Parent; | ||
private RNReactNativeGutenbergBridgeModule mRNReactNativeGutenbergBridgeModule; | ||
|
||
public RNReactNativeGutenbergBridgeModule getRNReactNativeGutenbergBridgeModule() { | ||
return mRNReactNativeGutenbergBridgeModule; | ||
} | ||
|
||
public RNReactNativeGutenbergBridgePackage(GutenbergBridgeJS2Parent gutenbergBridgeJS2Parent) { | ||
mGutenbergBridgeJS2Parent = gutenbergBridgeJS2Parent; | ||
} | ||
|
||
@Override | ||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) { | ||
mRNReactNativeGutenbergBridgeModule = new RNReactNativeGutenbergBridgeModule(reactContext, | ||
mGutenbergBridgeJS2Parent); | ||
return Arrays.<NativeModule>asList(mRNReactNativeGutenbergBridgeModule); | ||
} | ||
|
||
@Override | ||
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { | ||
return Collections.emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** @format */ | ||
|
||
import { NativeModules, NativeEventEmitter } from 'react-native'; | ||
|
||
const { RNReactNativeGutenbergBridge } = NativeModules; | ||
|
||
const gutenbergBridgeEvents = new NativeEventEmitter( RNReactNativeGutenbergBridge ); | ||
|
||
export function subscribeParentGetHtml( callback ) { | ||
return gutenbergBridgeEvents.addListener( 'requestGetHtml', callback ); | ||
} | ||
|
||
export default RNReactNativeGutenbergBridge; |
Oops, something went wrong.