forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The following PR introduces improved support for Context api and other api's which wrap the root view. ## Context api Navigation.registerComponent('navigation.playground.ContextScreen', () => (props) => ( <TitleContext.Provider value={'Title from Provider'}> <ContextScreen {...props} /> </TitleContext.Provider> ), () => ContextScreen); ## Redux Navigation.registerComponent('navigation.playground.ReduxScreen', () => (props) => ( <Provider store={reduxStore}> <ReduxScreen {...props} /> </Provider> ), () => ReduxScreen); ## Plain Component - not changed Navigation.registerComponent('navigation.playground.MyScreen', () => MyScreen); This PR also upgrades the TypeScript version to 3.2.0 and RN version used in the playground app to 0.57.7 * New Android build flavor - `reactNative57_7` * Unit test coverage is disabled, for some reason it broke after upgrading to RN 0.57.7
- Loading branch information
Showing
33 changed files
with
501 additions
and
163 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = function (api) { | ||
api && api.cache(false); | ||
return { | ||
env: { | ||
test: { | ||
presets: [ | ||
"module:metro-react-native-babel-preset" | ||
], | ||
plugins: [ | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} | ||
} | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
require('./playground/index'); |
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
28 changes: 28 additions & 0 deletions
28
...eactNative57_5/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.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,28 @@ | ||
package com.reactnativenavigation.react; | ||
|
||
import com.facebook.react.bridge.NativeDeltaClient; | ||
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class DevBundleDownloadListenerAdapter implements DevBundleDownloadListener, NavigationDevBundleDownloadListener { | ||
@Override | ||
public void onSuccess(@Nullable NativeDeltaClient nativeDeltaClient) { | ||
onSuccess(); | ||
} | ||
|
||
@Override | ||
public void onSuccess() { | ||
|
||
} | ||
|
||
@Override | ||
public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) { | ||
|
||
} | ||
|
||
@Override | ||
public void onFailure(Exception cause) { | ||
|
||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...pp/src/reactNative57_5/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.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,28 @@ | ||
package com.reactnativenavigation.react; | ||
|
||
import com.facebook.react.bridge.NativeDeltaClient; | ||
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class JsDevReloadHandlerFacade implements DevBundleDownloadListener, NavigationDevBundleDownloadListener { | ||
@Override | ||
public void onSuccess(@Nullable NativeDeltaClient nativeDeltaClient) { | ||
onSuccess(); | ||
} | ||
|
||
@Override | ||
public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) { | ||
|
||
} | ||
|
||
@Override | ||
public void onFailure(Exception cause) { | ||
|
||
} | ||
|
||
@Override | ||
public void onSuccess() { | ||
|
||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
...p/src/reactNative57_5/java/com/reactnativenavigation/react/NavigationReactNativeHost.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,107 @@ | ||
package com.reactnativenavigation.react; | ||
|
||
import android.app.Application; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
|
||
import com.facebook.infer.annotation.Assertions; | ||
import com.facebook.react.ReactInstanceManager; | ||
import com.facebook.react.ReactInstanceManagerBuilder; | ||
import com.facebook.react.ReactNativeHost; | ||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.common.LifecycleState; | ||
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; | ||
import com.facebook.react.shell.MainReactPackage; | ||
import com.reactnativenavigation.NavigationApplication; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Default implementation of {@link ReactNativeHost} that includes {@link NavigationPackage} | ||
* and user-defined additional packages. | ||
*/ | ||
public class NavigationReactNativeHost extends ReactNativeHost implements BundleDownloadListenerProvider { | ||
|
||
private final boolean isDebug; | ||
private final List<ReactPackage> additionalReactPackages; | ||
private @Nullable NavigationDevBundleDownloadListener bundleListener; | ||
private final DevBundleDownloadListener bundleListenerMediator = new DevBundleDownloadListenerAdapter() { | ||
@Override | ||
public void onSuccess() { | ||
if (bundleListener != null) { | ||
bundleListener.onSuccess(); | ||
} | ||
} | ||
}; | ||
|
||
public NavigationReactNativeHost(NavigationApplication application) { | ||
this(application, application.isDebug(), application.createAdditionalReactPackages()); | ||
} | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
public NavigationReactNativeHost(Application application, boolean isDebug, final List<ReactPackage> additionalReactPackages) { | ||
super(application); | ||
this.isDebug = isDebug; | ||
this.additionalReactPackages = additionalReactPackages; | ||
} | ||
|
||
@Override | ||
public void setBundleLoaderListener(NavigationDevBundleDownloadListener listener) { | ||
bundleListener = listener; | ||
} | ||
|
||
@Override | ||
public boolean getUseDeveloperSupport() { | ||
return isDebug; | ||
} | ||
|
||
@Override | ||
protected List<ReactPackage> getPackages() { | ||
List<ReactPackage> packages = new ArrayList<>(); | ||
boolean hasMainReactPackage = false; | ||
packages.add(new NavigationPackage(this)); | ||
if (additionalReactPackages != null) { | ||
for (ReactPackage p : additionalReactPackages) { | ||
if (!(p instanceof NavigationPackage)) { | ||
packages.add(p); | ||
} | ||
if (p instanceof MainReactPackage) hasMainReactPackage = true; | ||
} | ||
} | ||
if (!hasMainReactPackage) { | ||
packages.add(new MainReactPackage()); | ||
} | ||
return packages; | ||
} | ||
|
||
protected ReactInstanceManager createReactInstanceManager() { | ||
ReactInstanceManagerBuilder builder = ReactInstanceManager.builder() | ||
.setApplication(getApplication()) | ||
.setJSMainModulePath(getJSMainModuleName()) | ||
.setUseDeveloperSupport(getUseDeveloperSupport()) | ||
.setRedBoxHandler(getRedBoxHandler()) | ||
.setJavaScriptExecutorFactory(getJavaScriptExecutorFactory()) | ||
.setUIImplementationProvider(getUIImplementationProvider()) | ||
.setInitialLifecycleState(LifecycleState.BEFORE_CREATE) | ||
.setDevBundleDownloadListener(getDevBundleDownloadListener()); | ||
|
||
for (ReactPackage reactPackage : getPackages()) { | ||
builder.addPackage(reactPackage); | ||
} | ||
|
||
String jsBundleFile = getJSBundleFile(); | ||
if (jsBundleFile != null) { | ||
builder.setJSBundleFile(jsBundleFile); | ||
} else { | ||
builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName())); | ||
} | ||
return builder.build(); | ||
} | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
@NonNull | ||
protected DevBundleDownloadListener getDevBundleDownloadListener() { | ||
return bundleListenerMediator; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...oid/app/src/reactNative57_5/java/com/reactnativenavigation/react/ReloadHandlerFacade.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,25 @@ | ||
package com.reactnativenavigation.react; | ||
|
||
import com.facebook.react.bridge.NativeDeltaClient; | ||
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public abstract class ReloadHandlerFacade implements DevBundleDownloadListener { | ||
@Override | ||
public void onSuccess(@Nullable NativeDeltaClient nativeDeltaClient) { | ||
|
||
} | ||
|
||
@Override | ||
public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) { | ||
|
||
} | ||
|
||
@Override | ||
public void onFailure(Exception cause) { | ||
|
||
} | ||
|
||
protected abstract void onSuccess(); | ||
} |
83 changes: 83 additions & 0 deletions
83
...id/app/src/reactNative57_5/java/com/reactnativenavigation/react/SyncUiImplementation.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,83 @@ | ||
package com.reactnativenavigation.react; | ||
|
||
import android.support.annotation.Nullable; | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReadableArray; | ||
import com.facebook.react.bridge.ReadableMap; | ||
import com.facebook.react.uimanager.ThemedReactContext; | ||
import com.facebook.react.uimanager.UIImplementation; | ||
import com.facebook.react.uimanager.UIImplementationProvider; | ||
import com.facebook.react.uimanager.UIManagerModule; | ||
import com.facebook.react.uimanager.ViewManager; | ||
import com.facebook.react.uimanager.common.MeasureSpecProvider; | ||
import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout; | ||
import com.facebook.react.uimanager.events.EventDispatcher; | ||
|
||
import java.util.List; | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
public class SyncUiImplementation extends UIImplementation { | ||
private static final Object lock = new Object(); | ||
|
||
public static class Provider extends UIImplementationProvider { | ||
@Override | ||
public UIImplementation createUIImplementation(ReactApplicationContext reactContext, List<ViewManager> viewManagerList, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) { | ||
return new SyncUiImplementation(reactContext, viewManagerList, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); | ||
} | ||
|
||
@Override | ||
public UIImplementation createUIImplementation(ReactApplicationContext reactContext, UIManagerModule.ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) { | ||
return new SyncUiImplementation(reactContext, viewManagerResolver, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); | ||
} | ||
} | ||
|
||
public SyncUiImplementation(ReactApplicationContext reactContext, List<ViewManager> viewManagerList, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) { | ||
super(reactContext, viewManagerList, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); | ||
} | ||
|
||
public SyncUiImplementation(ReactApplicationContext reactContext, UIManagerModule.ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) { | ||
super(reactContext, viewManagerResolver, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs); | ||
} | ||
|
||
@Override | ||
public void manageChildren( | ||
int viewTag, | ||
@Nullable ReadableArray moveFrom, | ||
@Nullable ReadableArray moveTo, | ||
@Nullable ReadableArray addChildTags, | ||
@Nullable ReadableArray addAtIndices, | ||
@Nullable ReadableArray removeFrom) { | ||
synchronized (lock) { | ||
super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom); | ||
} | ||
} | ||
|
||
@Override | ||
public void setChildren(int viewTag, ReadableArray childrenTags) { | ||
synchronized (lock) { | ||
super.setChildren(viewTag, childrenTags); | ||
} | ||
} | ||
|
||
@Override | ||
public void createView(int tag, String className, int rootViewTag, ReadableMap props) { | ||
synchronized (lock) { | ||
super.createView(tag, className, rootViewTag, props); | ||
} | ||
} | ||
|
||
@Override | ||
public void removeRootShadowNode(int rootViewTag) { | ||
synchronized (lock) { | ||
super.removeRootShadowNode(rootViewTag); | ||
} | ||
} | ||
|
||
@Override | ||
public <T extends SizeMonitoringFrameLayout & MeasureSpecProvider> void registerRootView(T rootView, int tag, ThemedReactContext context) { | ||
synchronized (lock) { | ||
super.registerRootView(rootView, tag, context); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.