react-native-navigation 7.30.6 → 7.31.0-snapshot.856

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/lib/Mock/Components/LayoutComponent.tsx +7 -0
  2. package/lib/Mock/mocks/NativeCommandsSender.tsx +19 -0
  3. package/lib/android/app/build.gradle +7 -22
  4. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/UiUtils.java +5 -1
  5. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/options/parsers/ColorParser.kt +38 -0
  6. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java +22 -0
  7. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java +22 -0
  8. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/NavigationReactNativeHost.java +65 -0
  9. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/ReactGateway.java +72 -0
  10. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/ReloadHandlerFacade.java +22 -0
  11. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt +87 -0
  12. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxHelper.java +12 -0
  13. package/lib/dist/Mock/Components/LayoutComponent.d.ts +2 -2
  14. package/lib/dist/Mock/Components/LayoutComponent.js +3 -0
  15. package/lib/dist/Mock/mocks/NativeCommandsSender.d.ts +3 -0
  16. package/lib/dist/Mock/mocks/NativeCommandsSender.js +16 -0
  17. package/lib/dist/src/Navigation.js +2 -2
  18. package/lib/dist/src/adapters/Constants.d.ts +3 -2
  19. package/lib/dist/src/adapters/Constants.js +5 -5
  20. package/lib/dist/src/adapters/NativeCommandsSender.d.ts +3 -0
  21. package/lib/dist/src/adapters/NativeCommandsSender.js +6 -0
  22. package/lib/dist/src/commands/Commands.d.ts +4 -4
  23. package/lib/dist/src/commands/OptionsCrawler.d.ts +1 -1
  24. package/lib/dist/src/processors/LayoutProcessor.d.ts +1 -1
  25. package/lib/ios/SharedElementAnimator.m +1 -1
  26. package/lib/src/Navigation.ts +3 -3
  27. package/lib/src/adapters/Constants.ts +6 -5
  28. package/lib/src/adapters/NativeCommandsSender.ts +11 -0
  29. package/lib/src/commands/Commands.ts +4 -4
  30. package/lib/src/commands/OptionsCrawler.ts +1 -1
  31. package/lib/src/processors/LayoutProcessor.ts +1 -1
  32. package/package.json +1 -1
@@ -18,4 +18,11 @@ export const LayoutComponent = class extends Component<ComponentProps> {
18
18
 
19
19
  return <View />;
20
20
  }
21
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
22
+ console.error(
23
+ `Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}`,
24
+ error,
25
+ errorInfo
26
+ );
27
+ }
21
28
  };
@@ -4,6 +4,7 @@ import { LayoutNode } from '../../src/commands/LayoutTreeCrawler';
4
4
  import { events } from '../Stores/EventsStore';
5
5
  import _ from 'lodash';
6
6
  import ComponentNode from '../Layouts/ComponentNode';
7
+ import { Constants } from '../../src/adapters/Constants';
7
8
 
8
9
  export class NativeCommandsSender {
9
10
  constructor() {}
@@ -115,4 +116,22 @@ export class NativeCommandsSender {
115
116
  }
116
117
 
117
118
  getLaunchArgs(_commandId: string) {}
119
+
120
+ getNavigationConstants(): Promise<Constants> {
121
+ return Promise.resolve({
122
+ topBarHeight: 0,
123
+ backButtonId: 'RNN.back',
124
+ bottomTabsHeight: 0,
125
+ statusBarHeight: 0,
126
+ });
127
+ }
128
+
129
+ getNavigationConstantsSync(): Constants {
130
+ return {
131
+ topBarHeight: 0,
132
+ backButtonId: 'RNN.back',
133
+ bottomTabsHeight: 0,
134
+ statusBarHeight: 0,
135
+ };
136
+ }
118
137
  }
@@ -110,6 +110,10 @@ android {
110
110
  dimension "RNN.reactNativeVersion"
111
111
  buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "68")
112
112
  }
113
+ reactNative71 {
114
+ dimension "RNN.reactNativeVersion"
115
+ buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "71")
116
+ }
113
117
  }
114
118
 
115
119
  def flavor = resolveFlavor()
@@ -126,7 +130,9 @@ String resolveFlavor() {
126
130
  Integer reactNativeMinorComponent = reactNativeVersionComponents[1].toInteger()
127
131
  Integer reactNativePatchComponent = reactNativeVersionComponents[2].toInteger()
128
132
 
129
- if (reactNativeMinorComponent >= 68) {
133
+ if (reactNativeMinorComponent >= 71) {
134
+ return "reactNative71"
135
+ } else if (reactNativeMinorComponent >= 68) {
130
136
  return "reactNative68"
131
137
  } else if (reactNativeMinorComponent >= 63) {
132
138
  return "reactNative63"
@@ -167,27 +173,6 @@ List reactNativeVersionComponents(rnPackageJsonFile) {
167
173
  return reactNativeVersion.tokenize('-')[0].tokenize('.')
168
174
  }
169
175
 
170
- task installBuildToolsAndRenameD8IfNeeded {
171
- def buildToolsVersion = android.getBuildToolsVersion()
172
- def sdkDir = android.sdkDirectory
173
- def buildToolsDir = new File(sdkDir, "/build-tools/" + buildToolsVersion)
174
-
175
- if (!buildToolsDir.exists()) {
176
- def command = sdkDir.absolutePath + "/cmdline-tools/latest/bin/sdkmanager build-tools;" + buildToolsVersion
177
- command.execute().waitForProcessOutput(System.out, System.err)
178
- }
179
-
180
- def d8File = new File(buildToolsDir, "d8")
181
- def dxFile = new File(buildToolsDir, "dx")
182
- d8File.renameTo(dxFile)
183
-
184
- def buildToolsLibDir = new File(buildToolsDir, "lib")
185
- d8File = new File(buildToolsLibDir, "d8.jar")
186
- dxFile = new File(buildToolsLibDir, "dx.jar")
187
- d8File.renameTo(dxFile)
188
- }
189
- build.dependsOn installBuildToolsAndRenameD8IfNeeded
190
-
191
176
  dependencies {
192
177
 
193
178
  implementation "androidx.core:core-ktx:1.6.0"
@@ -81,7 +81,11 @@ public class UiUtils {
81
81
  }
82
82
 
83
83
  public static void runOnMainThread(Runnable runnable) {
84
- new Handler(Looper.getMainLooper()).post(runnable);
84
+ if (Looper.myLooper() == Looper.getMainLooper()) {
85
+ new Handler(Looper.getMainLooper()).postAtFrontOfQueue(runnable);
86
+ } else {
87
+ new Handler(Looper.getMainLooper()).post(runnable);
88
+ }
85
89
  }
86
90
 
87
91
  public static float getWindowHeight(Context context) {
@@ -0,0 +1,38 @@
1
+ package com.reactnativenavigation.options.parsers
2
+
3
+ import android.content.Context
4
+ import com.facebook.react.bridge.ColorPropConverter
5
+ import com.reactnativenavigation.options.params.Colour
6
+ import com.reactnativenavigation.options.params.DontApplyColour
7
+ import com.reactnativenavigation.options.params.NullColor
8
+ import com.reactnativenavigation.options.params.ReactPlatformColor
9
+ import org.json.JSONObject
10
+
11
+ object ColorParser {
12
+ private const val KEY_RESOURCE_PATHS = "resource_paths"
13
+ private const val VAL_NO_COLOR = "NoColor"
14
+
15
+ @JvmStatic
16
+ fun parse(context: Context?, json: JSONObject, colorName: String?): Colour {
17
+ if (json.has(KEY_RESOURCE_PATHS)) {
18
+ return ReactPlatformColor(JSONParser.convert(json))
19
+ }
20
+ return when (val color = json.opt(colorName)) {
21
+ null, VAL_NO_COLOR -> {
22
+ DontApplyColour()
23
+ }
24
+ is Int -> {
25
+ Colour(json.optInt(colorName))
26
+ }
27
+ is JSONObject -> {
28
+ ColorPropConverter.getColor(color, context)?.let {
29
+ Colour(it)
30
+ } ?: NullColor()
31
+ }
32
+ else -> {
33
+ NullColor()
34
+ }
35
+ }
36
+
37
+ }
38
+ }
@@ -0,0 +1,22 @@
1
+ package com.reactnativenavigation.react;
2
+
3
+ import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
+
5
+ import javax.annotation.Nullable;
6
+
7
+ public class DevBundleDownloadListenerAdapter implements DevBundleDownloadListener, NavigationDevBundleDownloadListener {
8
+ @Override
9
+ public void onSuccess() {
10
+ onSuccess();
11
+ }
12
+
13
+ @Override
14
+ public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
15
+
16
+ }
17
+
18
+ @Override
19
+ public void onFailure(Exception cause) {
20
+
21
+ }
22
+ }
@@ -0,0 +1,22 @@
1
+ package com.reactnativenavigation.react;
2
+
3
+ import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
+
5
+ import javax.annotation.Nullable;
6
+
7
+ public class JsDevReloadHandlerFacade implements DevBundleDownloadListener, NavigationDevBundleDownloadListener {
8
+ @Override
9
+ public void onSuccess() {
10
+ onSuccess();
11
+ }
12
+
13
+ @Override
14
+ public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
15
+
16
+ }
17
+
18
+ @Override
19
+ public void onFailure(Exception cause) {
20
+
21
+ }
22
+ }
@@ -0,0 +1,65 @@
1
+ package com.reactnativenavigation.react;
2
+
3
+ import com.facebook.infer.annotation.Assertions;
4
+ import com.facebook.react.ReactInstanceManager;
5
+ import com.facebook.react.ReactInstanceManagerBuilder;
6
+ import com.facebook.react.ReactNativeHost;
7
+ import com.facebook.react.ReactPackage;
8
+ import com.facebook.react.common.LifecycleState;
9
+ import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
10
+ import com.reactnativenavigation.NavigationApplication;
11
+
12
+ import androidx.annotation.NonNull;
13
+ import androidx.annotation.Nullable;
14
+
15
+ public abstract class NavigationReactNativeHost extends ReactNativeHost implements BundleDownloadListenerProvider {
16
+
17
+ private @Nullable NavigationDevBundleDownloadListener bundleListener;
18
+ private final DevBundleDownloadListener bundleListenerMediator = new DevBundleDownloadListenerAdapter() {
19
+ @Override
20
+ public void onSuccess() {
21
+ if (bundleListener != null) {
22
+ bundleListener.onSuccess();
23
+ }
24
+ }
25
+ };
26
+
27
+ public NavigationReactNativeHost(NavigationApplication application) {
28
+ super(application);
29
+ }
30
+
31
+ @Override
32
+ public void setBundleLoaderListener(NavigationDevBundleDownloadListener listener) {
33
+ bundleListener = listener;
34
+ }
35
+
36
+ protected ReactInstanceManager createReactInstanceManager() {
37
+ ReactInstanceManagerBuilder builder = ReactInstanceManager.builder()
38
+ .setApplication(getApplication())
39
+ .setJSMainModulePath(getJSMainModuleName())
40
+ .setUseDeveloperSupport(getUseDeveloperSupport())
41
+ .setRedBoxHandler(getRedBoxHandler())
42
+ .setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
43
+ .setInitialLifecycleState(LifecycleState.BEFORE_CREATE)
44
+ .setJSIModulesPackage(getJSIModulePackage())
45
+ .setDevBundleDownloadListener(getDevBundleDownloadListener());
46
+
47
+ for (ReactPackage reactPackage : getPackages()) {
48
+ builder.addPackage(reactPackage);
49
+ }
50
+
51
+ String jsBundleFile = getJSBundleFile();
52
+ if (jsBundleFile != null) {
53
+ builder.setJSBundleFile(jsBundleFile);
54
+ } else {
55
+ builder.setBundleAssetName(Assertions.assertNotNull(getBundleAssetName()));
56
+ }
57
+ return builder.build();
58
+ }
59
+
60
+ @SuppressWarnings("WeakerAccess")
61
+ @NonNull
62
+ protected DevBundleDownloadListener getDevBundleDownloadListener() {
63
+ return bundleListenerMediator;
64
+ }
65
+ }
@@ -0,0 +1,72 @@
1
+ package com.reactnativenavigation.react;
2
+
3
+ import android.app.Activity;
4
+ import android.content.Intent;
5
+ import android.content.res.Configuration;
6
+
7
+ import com.facebook.react.ReactNativeHost;
8
+ import com.reactnativenavigation.NavigationActivity;
9
+
10
+ import androidx.annotation.NonNull;
11
+
12
+ public class ReactGateway {
13
+
14
+ private final ReactNativeHost host;
15
+ private final NavigationReactInitializer initializer;
16
+ private final JsDevReloadHandler jsDevReloadHandler;
17
+
18
+ public ReactGateway(ReactNativeHost host) {
19
+ this.host = host;
20
+ initializer = new NavigationReactInitializer(host.getReactInstanceManager(), host.getUseDeveloperSupport());
21
+ jsDevReloadHandler = new JsDevReloadHandler(host.getReactInstanceManager().getDevSupportManager());
22
+ if (host instanceof BundleDownloadListenerProvider) {
23
+ ((BundleDownloadListenerProvider) host).setBundleLoaderListener(jsDevReloadHandler);
24
+ }
25
+ }
26
+
27
+ public void onActivityCreated(NavigationActivity activity) {
28
+ initializer.onActivityCreated();
29
+ jsDevReloadHandler.setReloadListener(activity);
30
+ }
31
+
32
+ public void onActivityResumed(NavigationActivity activity) {
33
+ initializer.onActivityResumed(activity);
34
+ jsDevReloadHandler.onActivityResumed(activity);
35
+ }
36
+
37
+ public boolean onNewIntent(Intent intent) {
38
+ if (host.hasInstance()) {
39
+ host.getReactInstanceManager().onNewIntent(intent);
40
+ return true;
41
+ }
42
+ return false;
43
+ }
44
+
45
+ public void onConfigurationChanged(NavigationActivity activity, @NonNull Configuration newConfig) {
46
+ if (host.hasInstance()) {
47
+ host.getReactInstanceManager().onConfigurationChanged(activity, newConfig);
48
+ }
49
+ }
50
+
51
+ public void onActivityPaused(NavigationActivity activity) {
52
+ initializer.onActivityPaused(activity);
53
+ jsDevReloadHandler.onActivityPaused(activity);
54
+ }
55
+
56
+ public void onActivityDestroyed(NavigationActivity activity) {
57
+ jsDevReloadHandler.removeReloadListener(activity);
58
+ initializer.onActivityDestroyed(activity);
59
+ }
60
+
61
+ public boolean onKeyUp(Activity activity, int keyCode) {
62
+ return jsDevReloadHandler.onKeyUp(activity, keyCode);
63
+ }
64
+
65
+ public void onBackPressed() {
66
+ host.getReactInstanceManager().onBackPressed();
67
+ }
68
+
69
+ public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
70
+ host.getReactInstanceManager().onActivityResult(activity, requestCode, resultCode, data);
71
+ }
72
+ }
@@ -0,0 +1,22 @@
1
+ package com.reactnativenavigation.react;
2
+
3
+ import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
4
+
5
+ import javax.annotation.Nullable;
6
+
7
+ public abstract class ReloadHandlerFacade implements DevBundleDownloadListener {
8
+ @Override
9
+ public void onSuccess() {
10
+
11
+ }
12
+
13
+ @Override
14
+ public void onProgress(@Nullable String status, @Nullable Integer done, @Nullable Integer total) {
15
+
16
+ }
17
+
18
+ @Override
19
+ public void onFailure(Exception cause) {
20
+
21
+ }
22
+ }
@@ -0,0 +1,87 @@
1
+ package com.reactnativenavigation.react.modal
2
+
3
+ import android.content.Context
4
+ import android.view.MotionEvent
5
+ import android.view.View
6
+ import com.facebook.react.bridge.*
7
+ import com.facebook.react.uimanager.*
8
+ import com.facebook.react.uimanager.events.EventDispatcher
9
+ import com.facebook.react.views.view.ReactViewGroup
10
+
11
+
12
+ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
13
+ private var hasAdjustedSize = false
14
+ private var viewWidth = 0
15
+ private var viewHeight = 0
16
+ private val mJSTouchDispatcher = JSTouchDispatcher(this)
17
+
18
+ override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
19
+ super.onSizeChanged(w, h, oldw, oldh)
20
+ viewWidth = w
21
+ viewHeight = h
22
+ this.updateFirstChildView()
23
+ }
24
+ private fun updateFirstChildView() {
25
+ if (this.childCount > 0) {
26
+ hasAdjustedSize = false
27
+ val viewTag = getChildAt(0).id
28
+ val reactContext: ReactContext = this.getReactContext()
29
+ reactContext.runOnNativeModulesQueueThread(object : GuardedRunnable(reactContext) {
30
+ override fun runGuarded() {
31
+ val uiManager = this@ModalContentLayout.getReactContext().getNativeModule(
32
+ UIManagerModule::class.java
33
+ ) as UIManagerModule
34
+ uiManager.updateNodeSize(
35
+ viewTag,
36
+ this@ModalContentLayout.viewWidth,
37
+ this@ModalContentLayout.viewHeight
38
+ )
39
+ }
40
+ })
41
+ } else {
42
+ hasAdjustedSize = true
43
+ }
44
+ }
45
+
46
+ override fun addView(child: View?, index: Int, params: LayoutParams?) {
47
+ super.addView(child, index, params)
48
+ if (hasAdjustedSize) {
49
+ updateFirstChildView()
50
+ }
51
+ }
52
+ override fun onChildStartedNativeGesture(child: View, androidEvent: MotionEvent?) {
53
+ mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
54
+ }
55
+ override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
56
+ mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
57
+ }
58
+ override fun onChildEndedNativeGesture(child: View, androidEvent: MotionEvent?) {
59
+ mJSTouchDispatcher.onChildEndedNativeGesture(androidEvent, this.getEventDispatcher())
60
+ }
61
+ override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
62
+ private fun getEventDispatcher(): EventDispatcher? {
63
+ val reactContext: ReactContext = this.getReactContext()
64
+ return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
65
+ }
66
+
67
+
68
+ override fun handleException(t: Throwable?) {
69
+ getReactContext().handleException(RuntimeException(t))
70
+ }
71
+
72
+ private fun getReactContext(): ReactContext {
73
+ return this.context as ReactContext
74
+ }
75
+
76
+ override fun onInterceptTouchEvent(event: MotionEvent?): Boolean {
77
+ mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
78
+ return super.onInterceptTouchEvent(event)
79
+ }
80
+
81
+ override fun onTouchEvent(event: MotionEvent?): Boolean {
82
+ mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
83
+ super.onTouchEvent(event)
84
+ return true
85
+ }
86
+
87
+ }
@@ -0,0 +1,12 @@
1
+ package com.reactnativenavigation.viewcontrollers.viewcontroller;
2
+
3
+ import android.view.View;
4
+ import android.view.ViewGroup;
5
+
6
+ public class YellowBoxHelper {
7
+ boolean isYellowBox(View parent, View child) {
8
+ return parent instanceof ViewGroup &&
9
+ child instanceof ViewGroup &&
10
+ ((ViewGroup) parent).indexOfChild(child) >= 1;
11
+ }
12
+ }
@@ -3,6 +3,7 @@ import { ComponentProps } from '../ComponentProps';
3
3
  export declare const LayoutComponent: {
4
4
  new (props: Readonly<ComponentProps>): {
5
5
  render(): JSX.Element;
6
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
6
7
  context: any;
7
8
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<ComponentProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
8
9
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -16,7 +17,6 @@ export declare const LayoutComponent: {
16
17
  componentDidMount?(): void;
17
18
  shouldComponentUpdate?(nextProps: Readonly<ComponentProps>, nextState: Readonly<{}>, nextContext: any): boolean;
18
19
  componentWillUnmount?(): void;
19
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
20
20
  getSnapshotBeforeUpdate?(prevProps: Readonly<ComponentProps>, prevState: Readonly<{}>): any;
21
21
  componentDidUpdate?(prevProps: Readonly<ComponentProps>, prevState: Readonly<{}>, snapshot?: any): void;
22
22
  componentWillMount?(): void;
@@ -28,6 +28,7 @@ export declare const LayoutComponent: {
28
28
  };
29
29
  new (props: ComponentProps, context?: any): {
30
30
  render(): JSX.Element;
31
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
31
32
  context: any;
32
33
  setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<ComponentProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
33
34
  forceUpdate(callback?: (() => void) | undefined): void;
@@ -41,7 +42,6 @@ export declare const LayoutComponent: {
41
42
  componentDidMount?(): void;
42
43
  shouldComponentUpdate?(nextProps: Readonly<ComponentProps>, nextState: Readonly<{}>, nextContext: any): boolean;
43
44
  componentWillUnmount?(): void;
44
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
45
45
  getSnapshotBeforeUpdate?(prevProps: Readonly<ComponentProps>, prevState: Readonly<{}>): any;
46
46
  componentDidUpdate?(prevProps: Readonly<ComponentProps>, prevState: Readonly<{}>, snapshot?: any): void;
47
47
  componentWillMount?(): void;
@@ -19,5 +19,8 @@ const LayoutComponent = class extends react_1.Component {
19
19
  }
20
20
  return react_1.default.createElement(react_native_1.View, null);
21
21
  }
22
+ componentDidCatch(error, errorInfo) {
23
+ console.error(`Error while trying to render layout ${this.props.layoutNode.nodeId} of type ${this.props.layoutNode.type}`, error, errorInfo);
24
+ }
22
25
  };
23
26
  exports.LayoutComponent = LayoutComponent;
@@ -1,4 +1,5 @@
1
1
  import { LayoutNode } from '../../src/commands/LayoutTreeCrawler';
2
+ import { Constants } from '../../src/adapters/Constants';
2
3
  export declare class NativeCommandsSender {
3
4
  constructor();
4
5
  setRoot(_commandId: string, layout: {
@@ -20,4 +21,6 @@ export declare class NativeCommandsSender {
20
21
  dismissOverlay(_commandId: string, componentId: string): void;
21
22
  dismissAllOverlays(_commandId: string): void;
22
23
  getLaunchArgs(_commandId: string): void;
24
+ getNavigationConstants(): Promise<Constants>;
25
+ getNavigationConstantsSync(): Constants;
23
26
  }
@@ -99,5 +99,21 @@ class NativeCommandsSender {
99
99
  LayoutStore_1.LayoutStore.dismissAllOverlays();
100
100
  }
101
101
  getLaunchArgs(_commandId) { }
102
+ getNavigationConstants() {
103
+ return Promise.resolve({
104
+ topBarHeight: 0,
105
+ backButtonId: 'RNN.back',
106
+ bottomTabsHeight: 0,
107
+ statusBarHeight: 0,
108
+ });
109
+ }
110
+ getNavigationConstantsSync() {
111
+ return {
112
+ topBarHeight: 0,
113
+ backButtonId: 'RNN.back',
114
+ bottomTabsHeight: 0,
115
+ statusBarHeight: 0,
116
+ };
117
+ }
102
118
  }
103
119
  exports.NativeCommandsSender = NativeCommandsSender;
@@ -200,13 +200,13 @@ class NavigationRoot {
200
200
  * Constants coming from native
201
201
  */
202
202
  async constants() {
203
- return await Constants_1.Constants.get();
203
+ return await Constants_1.Constants.get(this.nativeCommandsSender);
204
204
  }
205
205
  /**
206
206
  * Constants coming from native (synchronized call)
207
207
  */
208
208
  constantsSync() {
209
- return Constants_1.Constants.getSync();
209
+ return Constants_1.Constants.getSync(this.nativeCommandsSender);
210
210
  }
211
211
  }
212
212
  exports.NavigationRoot = NavigationRoot;
@@ -1,3 +1,4 @@
1
+ import { NativeCommandsSender } from './NativeCommandsSender';
1
2
  export interface NavigationConstants {
2
3
  statusBarHeight: number;
3
4
  backButtonId: string;
@@ -5,8 +6,8 @@ export interface NavigationConstants {
5
6
  bottomTabsHeight: number;
6
7
  }
7
8
  export declare class Constants {
8
- static get(): Promise<NavigationConstants>;
9
- static getSync(): NavigationConstants;
9
+ static get(nativeCommandSender: NativeCommandsSender): Promise<NavigationConstants>;
10
+ static getSync(nativeCommandSender: NativeCommandsSender): NavigationConstants;
10
11
  readonly statusBarHeight: number;
11
12
  readonly backButtonId: string;
12
13
  readonly topBarHeight: number;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Constants = void 0;
4
- const react_native_1 = require("react-native");
5
4
  class Constants {
6
- static async get() {
7
- const constants = await react_native_1.NativeModules.RNNBridgeModule.getNavigationConstants();
5
+ static async get(nativeCommandSender) {
6
+ const constants = await nativeCommandSender.getNavigationConstants();
8
7
  return new Constants(constants);
9
8
  }
10
- static getSync() {
11
- return new Constants(react_native_1.NativeModules.RNNBridgeModule.getNavigationConstantsSync());
9
+ static getSync(nativeCommandSender) {
10
+ const constants = nativeCommandSender.getNavigationConstantsSync();
11
+ return new Constants(constants);
12
12
  }
13
13
  statusBarHeight;
14
14
  backButtonId;
@@ -1,3 +1,4 @@
1
+ import { NavigationConstants } from './Constants';
1
2
  export declare class NativeCommandsSender {
2
3
  private readonly nativeCommandsModule;
3
4
  constructor();
@@ -20,4 +21,6 @@ export declare class NativeCommandsSender {
20
21
  dismissOverlay(commandId: string, componentId: string): Promise<any>;
21
22
  dismissAllOverlays(commandId: string): Promise<any>;
22
23
  getLaunchArgs(commandId: string): Promise<any>;
24
+ getNavigationConstants(): Promise<NavigationConstants>;
25
+ getNavigationConstantsSync(): NavigationConstants;
23
26
  }
@@ -52,5 +52,11 @@ class NativeCommandsSender {
52
52
  getLaunchArgs(commandId) {
53
53
  return this.nativeCommandsModule.getLaunchArgs(commandId);
54
54
  }
55
+ getNavigationConstants() {
56
+ return this.nativeCommandsModule.getNavigationConstants();
57
+ }
58
+ getNavigationConstantsSync() {
59
+ return this.nativeCommandsModule.getNavigationConstantsSync();
60
+ }
55
61
  }
56
62
  exports.NativeCommandsSender = NativeCommandsSender;
@@ -24,15 +24,15 @@ export declare class Commands {
24
24
  setDefaultOptions(options: Options): void;
25
25
  mergeOptions(componentId: string, options: Options): void;
26
26
  updateProps(componentId: string, props: object, callback?: () => void): void;
27
- showModal(layout: Layout): Promise<any>;
27
+ showModal<P>(layout: Layout<P>): Promise<any>;
28
28
  dismissModal(componentId: string, mergeOptions?: Options): Promise<any>;
29
29
  dismissAllModals(mergeOptions?: Options): Promise<any>;
30
- push(componentId: string, simpleApi: Layout): Promise<any>;
30
+ push<P>(componentId: string, simpleApi: Layout<P>): Promise<any>;
31
31
  pop(componentId: string, mergeOptions?: Options): Promise<any>;
32
32
  popTo(componentId: string, mergeOptions?: Options): Promise<any>;
33
33
  popToRoot(componentId: string, mergeOptions?: Options): Promise<any>;
34
- setStackRoot(componentId: string, children: Layout[]): Promise<any>;
35
- showOverlay(simpleApi: Layout): Promise<any>;
34
+ setStackRoot<P>(componentId: string, children: Layout<P>[]): Promise<any>;
35
+ showOverlay<P>(simpleApi: Layout<P>): Promise<any>;
36
36
  dismissOverlay(componentId: string): Promise<any>;
37
37
  dismissAllOverlays(): Promise<any>;
38
38
  getLaunchArgs(): Promise<any>;
@@ -5,7 +5,7 @@ export declare class OptionsCrawler {
5
5
  readonly store: Store;
6
6
  readonly uniqueIdProvider: UniqueIdProvider;
7
7
  constructor(store: Store, uniqueIdProvider: UniqueIdProvider);
8
- crawl(api?: Layout): void;
8
+ crawl(api?: Layout<any>): void;
9
9
  private topTabs;
10
10
  private sideMenu;
11
11
  private bottomTabs;
@@ -4,5 +4,5 @@ import { CommandName } from '../interfaces/CommandName';
4
4
  export declare class LayoutProcessor {
5
5
  private layoutProcessorsStore;
6
6
  constructor(layoutProcessorsStore: LayoutProcessorsStore);
7
- process(layout: Layout, commandName: CommandName): Layout;
7
+ process(layout: Layout<any>, commandName: CommandName): Layout;
8
8
  }
@@ -39,7 +39,7 @@
39
39
  [RNNElementFinder findElementForId:transitionOptions.toId
40
40
  inView:_toVC.presentedComponentViewController.reactView];
41
41
  if (fromView == nil || toView == nil) {
42
- break;
42
+ continue;
43
43
  }
44
44
 
45
45
  SharedElementTransition *sharedElementAnimator =
@@ -248,7 +248,7 @@ export class NavigationRoot {
248
248
  componentId: string,
249
249
  layout: Layout<P> | Array<Layout<P>>
250
250
  ): Promise<string> {
251
- const children: Layout[] = isArray(layout) ? layout : [layout];
251
+ const children: Layout<P | []>[] = isArray(layout) ? layout : [layout];
252
252
  return this.commands.setStackRoot(componentId, children);
253
253
  }
254
254
 
@@ -291,13 +291,13 @@ export class NavigationRoot {
291
291
  * Constants coming from native
292
292
  */
293
293
  public async constants(): Promise<NavigationConstants> {
294
- return await Constants.get();
294
+ return await Constants.get(this.nativeCommandsSender);
295
295
  }
296
296
 
297
297
  /**
298
298
  * Constants coming from native (synchronized call)
299
299
  */
300
300
  public constantsSync(): NavigationConstants {
301
- return Constants.getSync();
301
+ return Constants.getSync(this.nativeCommandsSender);
302
302
  }
303
303
  }
@@ -1,4 +1,4 @@
1
- import { NativeModules } from 'react-native';
1
+ import { NativeCommandsSender } from './NativeCommandsSender';
2
2
 
3
3
  export interface NavigationConstants {
4
4
  statusBarHeight: number;
@@ -8,13 +8,14 @@ export interface NavigationConstants {
8
8
  }
9
9
 
10
10
  export class Constants {
11
- static async get(): Promise<NavigationConstants> {
12
- const constants: NavigationConstants = await NativeModules.RNNBridgeModule.getNavigationConstants();
11
+ static async get(nativeCommandSender: NativeCommandsSender): Promise<NavigationConstants> {
12
+ const constants: NavigationConstants = await nativeCommandSender.getNavigationConstants();
13
13
  return new Constants(constants);
14
14
  }
15
15
 
16
- static getSync(): NavigationConstants {
17
- return new Constants(NativeModules.RNNBridgeModule.getNavigationConstantsSync());
16
+ static getSync(nativeCommandSender: NativeCommandsSender): NavigationConstants {
17
+ const constants: NavigationConstants = nativeCommandSender.getNavigationConstantsSync();
18
+ return new Constants(constants);
18
19
  }
19
20
 
20
21
  public readonly statusBarHeight: number;
@@ -1,4 +1,5 @@
1
1
  import { NativeModules } from 'react-native';
2
+ import { NavigationConstants } from './Constants';
2
3
 
3
4
  interface NativeCommandsModule {
4
5
  setRoot(commandId: string, layout: { root: any; modals: any[]; overlays: any[] }): Promise<any>;
@@ -16,6 +17,8 @@ interface NativeCommandsModule {
16
17
  dismissOverlay(commandId: string, componentId: string): Promise<any>;
17
18
  dismissAllOverlays(commandId: string): Promise<any>;
18
19
  getLaunchArgs(commandId: string): Promise<any>;
20
+ getNavigationConstants(): Promise<NavigationConstants>;
21
+ getNavigationConstantsSync(): NavigationConstants;
19
22
  }
20
23
 
21
24
  export class NativeCommandsSender {
@@ -83,4 +86,12 @@ export class NativeCommandsSender {
83
86
  getLaunchArgs(commandId: string) {
84
87
  return this.nativeCommandsModule.getLaunchArgs(commandId);
85
88
  }
89
+
90
+ getNavigationConstants() {
91
+ return this.nativeCommandsModule.getNavigationConstants();
92
+ }
93
+
94
+ getNavigationConstantsSync() {
95
+ return this.nativeCommandsModule.getNavigationConstantsSync();
96
+ }
86
97
  }
@@ -91,7 +91,7 @@ export class Commands {
91
91
  this.commandsObserver.notify(CommandName.UpdateProps, { componentId, props });
92
92
  }
93
93
 
94
- public showModal(layout: Layout) {
94
+ public showModal<P>(layout: Layout<P>) {
95
95
  const layoutCloned = cloneLayout(layout);
96
96
  this.optionsCrawler.crawl(layoutCloned);
97
97
  const layoutProcessed = this.layoutProcessor.process(layoutCloned, CommandName.ShowModal);
@@ -125,7 +125,7 @@ export class Commands {
125
125
  return result;
126
126
  }
127
127
 
128
- public push(componentId: string, simpleApi: Layout) {
128
+ public push<P>(componentId: string, simpleApi: Layout<P>) {
129
129
  const input = cloneLayout(simpleApi);
130
130
  this.optionsCrawler.crawl(input);
131
131
  const layoutProcessed = this.layoutProcessor.process(input, CommandName.Push);
@@ -163,7 +163,7 @@ export class Commands {
163
163
  return result;
164
164
  }
165
165
 
166
- public setStackRoot(componentId: string, children: Layout[]) {
166
+ public setStackRoot<P>(componentId: string, children: Layout<P>[]) {
167
167
  const input = map(cloneLayout(children), (simpleApi) => {
168
168
  this.optionsCrawler.crawl(simpleApi);
169
169
  const layoutProcessed = this.layoutProcessor.process(simpleApi, CommandName.SetStackRoot);
@@ -185,7 +185,7 @@ export class Commands {
185
185
  return result;
186
186
  }
187
187
 
188
- public showOverlay(simpleApi: Layout) {
188
+ public showOverlay<P>(simpleApi: Layout<P>) {
189
189
  const input = cloneLayout(simpleApi);
190
190
  this.optionsCrawler.crawl(input);
191
191
  const layoutProcessed = this.layoutProcessor.process(input, CommandName.ShowOverlay);
@@ -22,7 +22,7 @@ export class OptionsCrawler {
22
22
  this.crawl = this.crawl.bind(this);
23
23
  }
24
24
 
25
- crawl(api?: Layout): void {
25
+ crawl(api?: Layout<any>): void {
26
26
  if (!api) return;
27
27
  if (api.topTabs) {
28
28
  this.topTabs(api.topTabs);
@@ -6,7 +6,7 @@ import { CommandName } from '../interfaces/CommandName';
6
6
  export class LayoutProcessor {
7
7
  constructor(private layoutProcessorsStore: LayoutProcessorsStore) {}
8
8
 
9
- public process(layout: Layout, commandName: CommandName): Layout {
9
+ public process(layout: Layout<any>, commandName: CommandName): Layout {
10
10
  const processors: ILayoutProcessor[] = this.layoutProcessorsStore.getProcessors();
11
11
  processors.forEach((processor) => {
12
12
  layout = processor(layout, commandName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.30.6",
3
+ "version": "7.31.0-snapshot.856",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,