hybrid-navigation 2.18.2 → 2.18.3
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.
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +1 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +2 -1
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.h +1 -0
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.m +1 -0
- package/lib/Navigation.d.ts +1 -1
- package/lib/Navigation.js +7 -2
- package/lib/NavigationModule.d.ts +1 -0
- package/lib/Navigator.js +7 -7
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/Navigation.ts +9 -2
- package/src/NavigationModule.ts +1 -0
- package/src/Navigator.ts +7 -7
- package/src/index.ts +1 -1
|
@@ -66,6 +66,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
66
66
|
HashMap<String, Object> constants = new HashMap<>();
|
|
67
67
|
constants.put("RESULT_OK", Activity.RESULT_OK);
|
|
68
68
|
constants.put("RESULT_CANCEL", Activity.RESULT_CANCELED);
|
|
69
|
+
constants.put("RESULT_BLOCK", -2);
|
|
69
70
|
return constants;
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
NSString *const ReactModuleRegistryDidCompletedNotification = @"ReactModuleRegistryDidCompletedNotification";
|
|
11
11
|
const NSInteger ResultOK = -1;
|
|
12
12
|
const NSInteger ResultCancel = 0;
|
|
13
|
+
const NSInteger ResultBlock = -2;
|
|
13
14
|
|
|
14
15
|
@interface HBDReactBridgeManager ()
|
|
15
16
|
|
package/lib/Navigation.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ type BarButtonClickEventListener = (sceneId: string, value: Function) => void;
|
|
|
11
11
|
type Nullable<T> = {
|
|
12
12
|
[P in keyof T]: T[P] extends T[P] | undefined ? T[P] | null : T[P];
|
|
13
13
|
};
|
|
14
|
-
export declare const RESULT_CANCEL: number, RESULT_OK: number;
|
|
14
|
+
export declare const RESULT_CANCEL: number, RESULT_OK: number, RESULT_BLOCK: number;
|
|
15
15
|
export type NavigationSubscription = {
|
|
16
16
|
remove: () => void;
|
|
17
17
|
};
|
package/lib/Navigation.js
CHANGED
|
@@ -7,7 +7,7 @@ import VisibilityEventHandler from './handler/VisibilityEventHandler';
|
|
|
7
7
|
import Event from './Event';
|
|
8
8
|
import GardenModule from './GardenModule';
|
|
9
9
|
import NavigationModule from './NavigationModule';
|
|
10
|
-
export const { RESULT_CANCEL, RESULT_OK } = NavigationModule.getConstants();
|
|
10
|
+
export const { RESULT_CANCEL, RESULT_OK, RESULT_BLOCK } = NavigationModule.getConstants();
|
|
11
11
|
class NavigationImpl {
|
|
12
12
|
dispatchHandler = new DispatchCommandHandler();
|
|
13
13
|
resultHandler = new ResultEventHandler();
|
|
@@ -83,7 +83,12 @@ class NavigationImpl {
|
|
|
83
83
|
setInterceptor(interceptor) {
|
|
84
84
|
this.dispatchHandler.setInterceptor(interceptor);
|
|
85
85
|
}
|
|
86
|
-
setResult = (sceneId, resultCode, data = null) =>
|
|
86
|
+
setResult = (sceneId, resultCode, data = null) => {
|
|
87
|
+
if (resultCode < RESULT_OK) {
|
|
88
|
+
console.warn('`resultCode` can only be `RESULT_OK`, `RESULT_CANCEL` or an integer greater than 0.');
|
|
89
|
+
}
|
|
90
|
+
NavigationModule.setResult(sceneId, resultCode, data);
|
|
91
|
+
};
|
|
87
92
|
result(sceneId, resultCode) {
|
|
88
93
|
return this.resultHandler.waitResult(sceneId, resultCode);
|
|
89
94
|
}
|
package/lib/Navigator.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
import store from './store';
|
|
3
|
-
import Navigation, {
|
|
3
|
+
import Navigation, { RESULT_BLOCK } from './Navigation';
|
|
4
4
|
export const NavigationContext = createContext(null);
|
|
5
5
|
let tagGenerator = 0;
|
|
6
6
|
Navigation.addGlobalVisibilityEventListener((sceneId, visibility) => {
|
|
@@ -58,7 +58,7 @@ export class Navigator {
|
|
|
58
58
|
options,
|
|
59
59
|
});
|
|
60
60
|
if (!success) {
|
|
61
|
-
return [
|
|
61
|
+
return [RESULT_BLOCK, null];
|
|
62
62
|
}
|
|
63
63
|
return Navigation.result(this.sceneId, 0);
|
|
64
64
|
};
|
|
@@ -68,7 +68,7 @@ export class Navigator {
|
|
|
68
68
|
layout,
|
|
69
69
|
});
|
|
70
70
|
if (!success) {
|
|
71
|
-
return [
|
|
71
|
+
return [RESULT_BLOCK, null];
|
|
72
72
|
}
|
|
73
73
|
return Navigation.result(this.sceneId, 0);
|
|
74
74
|
};
|
|
@@ -94,7 +94,7 @@ export class Navigator {
|
|
|
94
94
|
});
|
|
95
95
|
if (!success) {
|
|
96
96
|
console.warn(`present from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
97
|
-
return [
|
|
97
|
+
return [RESULT_BLOCK, null];
|
|
98
98
|
}
|
|
99
99
|
return Navigation.result(this.sceneId, requestCode);
|
|
100
100
|
};
|
|
@@ -107,7 +107,7 @@ export class Navigator {
|
|
|
107
107
|
});
|
|
108
108
|
if (!success) {
|
|
109
109
|
console.warn(`presentLayout from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
110
|
-
return [
|
|
110
|
+
return [RESULT_BLOCK, null];
|
|
111
111
|
}
|
|
112
112
|
return Navigation.result(this.sceneId, requestCode);
|
|
113
113
|
};
|
|
@@ -124,7 +124,7 @@ export class Navigator {
|
|
|
124
124
|
});
|
|
125
125
|
if (!success) {
|
|
126
126
|
console.warn(`showModal from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
127
|
-
return [
|
|
127
|
+
return [RESULT_BLOCK, null];
|
|
128
128
|
}
|
|
129
129
|
return Navigation.result(this.sceneId, requestCode);
|
|
130
130
|
};
|
|
@@ -137,7 +137,7 @@ export class Navigator {
|
|
|
137
137
|
});
|
|
138
138
|
if (!success) {
|
|
139
139
|
console.warn(`showModal from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`);
|
|
140
|
-
return [
|
|
140
|
+
return [RESULT_BLOCK, null];
|
|
141
141
|
}
|
|
142
142
|
return Navigation.result(this.sceneId, requestCode);
|
|
143
143
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const Navigation: import("./Navigation").Navigation;
|
|
2
2
|
export default Navigation;
|
|
3
|
-
export { RESULT_OK, RESULT_CANCEL } from './Navigation';
|
|
3
|
+
export { RESULT_OK, RESULT_CANCEL, RESULT_BLOCK } from './Navigation';
|
|
4
4
|
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule';
|
|
5
5
|
export { withNavigationItem } from './NavigationComponentWrap';
|
|
6
6
|
export type { NavigationProps } from './NavigationComponentWrap';
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import navigation from './Navigation';
|
|
|
3
3
|
navigation.setNavigationComponentWrap(withNavigation);
|
|
4
4
|
const Navigation = navigation;
|
|
5
5
|
export default Navigation;
|
|
6
|
-
export { RESULT_OK, RESULT_CANCEL } from './Navigation';
|
|
6
|
+
export { RESULT_OK, RESULT_CANCEL, RESULT_BLOCK } from './Navigation';
|
|
7
7
|
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule';
|
|
8
8
|
export { withNavigationItem } from './NavigationComponentWrap';
|
|
9
9
|
export * from './Navigator';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hybrid-navigation",
|
|
3
3
|
"description": "React Native Navigation that supports seamless navigation between Native and React.",
|
|
4
|
-
"version": "2.18.
|
|
4
|
+
"version": "2.18.3",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
package/src/Navigation.ts
CHANGED
|
@@ -34,7 +34,7 @@ type Nullable<T> = {
|
|
|
34
34
|
[P in keyof T]: T[P] extends T[P] | undefined ? T[P] | null : T[P]
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export const { RESULT_CANCEL, RESULT_OK } = NavigationModule.getConstants()
|
|
37
|
+
export const { RESULT_CANCEL, RESULT_OK, RESULT_BLOCK } = NavigationModule.getConstants()
|
|
38
38
|
|
|
39
39
|
export type NavigationSubscription = {
|
|
40
40
|
remove: () => void
|
|
@@ -191,7 +191,14 @@ class NavigationImpl implements Navigation {
|
|
|
191
191
|
sceneId: string,
|
|
192
192
|
resultCode: number,
|
|
193
193
|
data: T = null as T,
|
|
194
|
-
): void =>
|
|
194
|
+
): void => {
|
|
195
|
+
if (resultCode < RESULT_OK) {
|
|
196
|
+
console.warn(
|
|
197
|
+
'`resultCode` can only be `RESULT_OK`, `RESULT_CANCEL` or an integer greater than 0.',
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
NavigationModule.setResult(sceneId, resultCode, data)
|
|
201
|
+
}
|
|
195
202
|
|
|
196
203
|
result<T extends ResultType>(sceneId: string, resultCode: number) {
|
|
197
204
|
return this.resultHandler.waitResult<T>(sceneId, resultCode)
|
package/src/NavigationModule.ts
CHANGED
package/src/Navigator.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { createContext } from 'react'
|
|
|
3
3
|
import store from './store'
|
|
4
4
|
import type { Visibility, Layout, BuildInLayout } from './Route'
|
|
5
5
|
import type { NavigationItem } from './Options'
|
|
6
|
-
import Navigation, { ResultType,
|
|
6
|
+
import Navigation, { ResultType, RESULT_BLOCK } from './Navigation'
|
|
7
7
|
|
|
8
8
|
export const NavigationContext = createContext<any>(null)
|
|
9
9
|
|
|
@@ -83,7 +83,7 @@ export class Navigator implements Navigator {
|
|
|
83
83
|
options,
|
|
84
84
|
})
|
|
85
85
|
if (!success) {
|
|
86
|
-
return [
|
|
86
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
87
87
|
}
|
|
88
88
|
return Navigation.result<T>(this.sceneId, 0)
|
|
89
89
|
}
|
|
@@ -94,7 +94,7 @@ export class Navigator implements Navigator {
|
|
|
94
94
|
layout,
|
|
95
95
|
})
|
|
96
96
|
if (!success) {
|
|
97
|
-
return [
|
|
97
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
98
98
|
}
|
|
99
99
|
return Navigation.result<T>(this.sceneId, 0)
|
|
100
100
|
}
|
|
@@ -137,7 +137,7 @@ export class Navigator implements Navigator {
|
|
|
137
137
|
console.warn(
|
|
138
138
|
`present from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
139
139
|
)
|
|
140
|
-
return [
|
|
140
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
141
141
|
}
|
|
142
142
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
143
143
|
}
|
|
@@ -153,7 +153,7 @@ export class Navigator implements Navigator {
|
|
|
153
153
|
console.warn(
|
|
154
154
|
`presentLayout from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
155
155
|
)
|
|
156
|
-
return [
|
|
156
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
157
157
|
}
|
|
158
158
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
159
159
|
}
|
|
@@ -178,7 +178,7 @@ export class Navigator implements Navigator {
|
|
|
178
178
|
console.warn(
|
|
179
179
|
`showModal from:${this.moduleName} to:${moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
180
180
|
)
|
|
181
|
-
return [
|
|
181
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
182
182
|
}
|
|
183
183
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
184
184
|
}
|
|
@@ -194,7 +194,7 @@ export class Navigator implements Navigator {
|
|
|
194
194
|
console.warn(
|
|
195
195
|
`showModal from:${this.moduleName} failed. Maybe the screen (${this.moduleName}) already shows or present another screen.`,
|
|
196
196
|
)
|
|
197
|
-
return [
|
|
197
|
+
return [RESULT_BLOCK, null] as [number, T]
|
|
198
198
|
}
|
|
199
199
|
return Navigation.result<T>(this.sceneId, requestCode)
|
|
200
200
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import navigation from './Navigation'
|
|
|
3
3
|
navigation.setNavigationComponentWrap(withNavigation)
|
|
4
4
|
const Navigation = navigation
|
|
5
5
|
export default Navigation
|
|
6
|
-
export { RESULT_OK, RESULT_CANCEL } from './Navigation'
|
|
6
|
+
export { RESULT_OK, RESULT_CANCEL, RESULT_BLOCK } from './Navigation'
|
|
7
7
|
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule'
|
|
8
8
|
export { withNavigationItem } from './NavigationComponentWrap'
|
|
9
9
|
export type { NavigationProps } from './NavigationComponentWrap'
|