hybrid-navigation 2.13.0-beta.2 → 2.13.0-beta.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/ios/HybridNavigation/HBDUtils.h +3 -6
- package/ios/HybridNavigation/HBDUtils.m +10 -0
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +7 -2
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +1 -1
- package/ios/HybridNavigation/View/HBDRootView.m +9 -3
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +0 -30
- package/ios/HybridNavigation/ViewController/HBDViewController.m +7 -3
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -3
- package/lib/Event.d.ts +22 -0
- package/lib/Event.js +117 -0
- package/lib/Garden.d.ts +2 -64
- package/lib/Garden.js +9 -47
- package/lib/GardenModule.d.ts +20 -0
- package/lib/GardenModule.js +3 -0
- package/lib/NavigationModule.d.ts +33 -22
- package/lib/NavigationModule.js +79 -22
- package/lib/Navigator.d.ts +33 -17
- package/lib/Navigator.js +106 -170
- package/lib/{typing.d.ts → Options.d.ts} +46 -50
- package/lib/{typing.js → Options.js} +0 -0
- package/lib/ReactRegistry.d.ts +2 -3
- package/lib/ReactRegistry.js +8 -28
- package/lib/Route.d.ts +74 -0
- package/lib/{router/typing.js → Route.js} +0 -0
- package/lib/hooks.d.ts +0 -1
- package/lib/hooks.js +18 -24
- package/lib/index.d.ts +3 -2
- package/lib/index.js +4 -2
- package/lib/router/drawer.d.ts +1 -1
- package/lib/router/index.d.ts +4 -7
- package/lib/router/index.js +1 -6
- package/lib/router/screen.d.ts +1 -1
- package/lib/router/stack.d.ts +1 -1
- package/lib/router/tabs.d.ts +1 -1
- package/lib/store.d.ts +0 -9
- package/lib/store.js +0 -22
- package/package.json +1 -1
- package/src/Event.ts +188 -0
- package/src/Garden.ts +18 -122
- package/src/GardenModule.ts +24 -0
- package/src/NavigationModule.ts +118 -29
- package/src/Navigator.ts +164 -209
- package/src/{typing.ts → Options.ts} +51 -57
- package/src/ReactRegistry.tsx +17 -40
- package/src/Route.ts +88 -0
- package/src/hooks.ts +23 -32
- package/src/index.ts +5 -2
- package/src/router/drawer.ts +1 -1
- package/src/router/index.ts +21 -12
- package/src/router/screen.ts +1 -1
- package/src/router/stack.ts +1 -1
- package/src/router/tabs.ts +1 -1
- package/src/store.ts +0 -28
- package/lib/router/typing.d.ts +0 -37
- package/lib/utils.d.ts +0 -9
- package/lib/utils.js +0 -50
- package/src/router/typing.ts +0 -45
- package/src/utils.ts +0 -83
package/lib/NavigationModule.js
CHANGED
|
@@ -1,23 +1,80 @@
|
|
|
1
|
-
import { NativeModules
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
2
|
const NavigationModule = NativeModules.NavigationModule;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
function getConstants() {
|
|
4
|
+
return NavigationModule.getConstants();
|
|
5
|
+
}
|
|
6
|
+
function startRegisterReactComponent() {
|
|
7
|
+
NavigationModule.startRegisterReactComponent();
|
|
8
|
+
}
|
|
9
|
+
function endRegisterReactComponent() {
|
|
10
|
+
NavigationModule.endRegisterReactComponent();
|
|
11
|
+
}
|
|
12
|
+
function registerReactComponent(appKey, options) {
|
|
13
|
+
NavigationModule.registerReactComponent(appKey, options);
|
|
14
|
+
}
|
|
15
|
+
function signalFirstRenderComplete(sceneId) {
|
|
16
|
+
NavigationModule.signalFirstRenderComplete(sceneId);
|
|
17
|
+
}
|
|
18
|
+
function setResult(sceneId, resultCode, data) {
|
|
19
|
+
NavigationModule.setResult(sceneId, resultCode, data);
|
|
20
|
+
}
|
|
21
|
+
function setRoot(layout, sticky, tag) {
|
|
22
|
+
NavigationModule.setRoot(layout, sticky, tag);
|
|
23
|
+
}
|
|
24
|
+
function dispatch(sceneId, action, params) {
|
|
25
|
+
return new Promise(resolve => {
|
|
26
|
+
NavigationModule.dispatch(sceneId, action, params, (_, result) => {
|
|
27
|
+
resolve(result);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function currentTab(sceneId) {
|
|
32
|
+
return new Promise(resolve => {
|
|
33
|
+
NavigationModule.currentTab(sceneId, (_, result) => {
|
|
34
|
+
resolve(result);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function isStackRoot(sceneId) {
|
|
39
|
+
return new Promise(resolve => {
|
|
40
|
+
NavigationModule.isStackRoot(sceneId, (_, result) => {
|
|
41
|
+
resolve(result);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function findSceneIdByModuleName(moduleName) {
|
|
46
|
+
return new Promise(resolve => {
|
|
47
|
+
NavigationModule.findSceneIdByModuleName(moduleName, (_, result) => {
|
|
48
|
+
resolve(result);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function currentRoute() {
|
|
53
|
+
return new Promise(resolve => {
|
|
54
|
+
NavigationModule.currentRoute((_, result) => {
|
|
55
|
+
resolve(result);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function routeGraph() {
|
|
60
|
+
return new Promise(resolve => {
|
|
61
|
+
NavigationModule.routeGraph((_, result) => {
|
|
62
|
+
resolve(result);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export default {
|
|
67
|
+
getConstants,
|
|
68
|
+
startRegisterReactComponent,
|
|
69
|
+
endRegisterReactComponent,
|
|
70
|
+
registerReactComponent,
|
|
71
|
+
signalFirstRenderComplete,
|
|
72
|
+
setResult,
|
|
73
|
+
setRoot,
|
|
74
|
+
dispatch,
|
|
75
|
+
currentTab,
|
|
76
|
+
isStackRoot,
|
|
77
|
+
findSceneIdByModuleName,
|
|
78
|
+
currentRoute,
|
|
79
|
+
routeGraph,
|
|
80
|
+
};
|
package/lib/Navigator.d.ts
CHANGED
|
@@ -1,22 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import { Visibility } from './
|
|
3
|
-
import {
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Visibility, Layout, BuildInLayout, Route, RouteGraph } from './Route';
|
|
3
|
+
import { NavigationItem } from './Options';
|
|
4
4
|
import { Garden } from './Garden';
|
|
5
|
-
|
|
5
|
+
export declare const NavigationContext: import("react").Context<any>;
|
|
6
|
+
interface NavigationState {
|
|
7
|
+
params: {
|
|
8
|
+
readonly [index: string]: any;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface IndexType {
|
|
12
|
+
[index: string]: any;
|
|
13
|
+
}
|
|
14
|
+
interface PropsType {
|
|
15
|
+
[index: string]: any;
|
|
16
|
+
}
|
|
17
|
+
interface DispatchParams {
|
|
6
18
|
animated?: boolean;
|
|
7
19
|
moduleName?: string;
|
|
8
20
|
layout?: BuildInLayout | Layout;
|
|
9
21
|
popToRoot?: boolean;
|
|
10
22
|
requestCode?: number;
|
|
11
|
-
props?:
|
|
23
|
+
props?: object;
|
|
12
24
|
options?: NavigationItem;
|
|
13
25
|
[index: string]: any;
|
|
14
26
|
}
|
|
15
|
-
interface
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
interface InterceptParams {
|
|
28
|
+
sceneId: string;
|
|
29
|
+
from?: number | string;
|
|
30
|
+
to?: number | string;
|
|
31
|
+
}
|
|
32
|
+
export interface NavigationInterceptor {
|
|
33
|
+
(action: string, params: InterceptParams): boolean | Promise<boolean>;
|
|
19
34
|
}
|
|
35
|
+
declare type ResultType = IndexType | null;
|
|
20
36
|
export declare class Navigator {
|
|
21
37
|
sceneId: string;
|
|
22
38
|
moduleName?: string | undefined;
|
|
@@ -27,32 +43,32 @@ export declare class Navigator {
|
|
|
27
43
|
static routeGraph(): Promise<RouteGraph[]>;
|
|
28
44
|
static setRoot(layout: BuildInLayout | Layout, sticky?: boolean): Promise<void>;
|
|
29
45
|
static setRootLayoutUpdateListener(willSetRoot?: () => void, didSetRoot?: () => void): void;
|
|
30
|
-
static dispatch(sceneId: string, action: string, params?:
|
|
46
|
+
static dispatch(sceneId: string, action: string, params?: DispatchParams): Promise<boolean>;
|
|
31
47
|
static setInterceptor(interceptFn: NavigationInterceptor): void;
|
|
32
48
|
constructor(sceneId: string, moduleName?: string | undefined);
|
|
49
|
+
private _garden?;
|
|
50
|
+
get garden(): Garden;
|
|
33
51
|
visibility: Visibility;
|
|
34
52
|
readonly state: NavigationState;
|
|
35
53
|
setParams: (params: {
|
|
36
54
|
[index: string]: any;
|
|
37
55
|
}) => void;
|
|
38
|
-
dispatch: (action: string, params?:
|
|
56
|
+
dispatch: (action: string, params?: DispatchParams) => Promise<boolean>;
|
|
39
57
|
result: (resultCode: number, data: ResultType) => void;
|
|
40
58
|
unmount: () => void;
|
|
41
|
-
private _garden?;
|
|
42
|
-
get garden(): Garden;
|
|
43
59
|
private resultListener;
|
|
44
60
|
private waitResult;
|
|
45
|
-
push: <T extends ResultType, P extends PropsType =
|
|
61
|
+
push: <T extends ResultType, P extends PropsType = {}>(moduleName: string, props?: P, options?: NavigationItem) => Promise<[number, T]>;
|
|
46
62
|
pushLayout: <T extends ResultType>(layout: BuildInLayout | Layout) => Promise<[number, T]>;
|
|
47
63
|
pop: () => Promise<boolean>;
|
|
48
64
|
popTo: (moduleName: string, inclusive?: boolean) => Promise<boolean>;
|
|
49
65
|
popToRoot: () => Promise<boolean>;
|
|
50
|
-
redirectTo: <P extends PropsType
|
|
66
|
+
redirectTo: <P extends PropsType>(moduleName: string, props?: P, options?: NavigationItem) => Promise<boolean>;
|
|
51
67
|
isStackRoot: () => Promise<boolean>;
|
|
52
|
-
present: <T extends ResultType, P extends PropsType =
|
|
68
|
+
present: <T extends ResultType, P extends PropsType = {}>(moduleName: string, props?: P, options?: NavigationItem) => Promise<[number, T]>;
|
|
53
69
|
presentLayout: <T extends ResultType>(layout: BuildInLayout | Layout) => Promise<[number, T]>;
|
|
54
70
|
dismiss: () => Promise<boolean>;
|
|
55
|
-
showModal: <T extends ResultType, P extends PropsType =
|
|
71
|
+
showModal: <T extends ResultType, P extends PropsType = {}>(moduleName: string, props?: P, options?: NavigationItem) => Promise<[number, T]>;
|
|
56
72
|
showModalLayout: <T extends ResultType>(layout: BuildInLayout | Layout) => Promise<[number, T]>;
|
|
57
73
|
hideModal: () => Promise<boolean>;
|
|
58
74
|
setResult: <T extends ResultType>(resultCode: number, data?: T) => void;
|
package/lib/Navigator.js
CHANGED
|
@@ -1,48 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import NavigationModule from './NavigationModule';
|
|
3
|
+
import Event from './Event';
|
|
3
4
|
import store from './store';
|
|
4
5
|
import { Garden } from './Garden';
|
|
6
|
+
const { RESULT_CANCEL } = NavigationModule.getConstants();
|
|
7
|
+
export const NavigationContext = createContext(null);
|
|
5
8
|
let interceptor;
|
|
6
9
|
let shouldCallWillSetRootCallback = 0;
|
|
7
10
|
let willSetRootCallback;
|
|
8
11
|
let didSetRootCallback;
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
didSetRootCallback && didSetRootCallback();
|
|
12
|
-
shouldCallWillSetRootCallback = 0;
|
|
13
|
-
});
|
|
14
|
-
EventEmitter.addListener(EVENT_WILL_SET_ROOT, _ => {
|
|
12
|
+
let tagGenerator = 0;
|
|
13
|
+
Event.listenSetRoot(() => {
|
|
15
14
|
if (shouldCallWillSetRootCallback === 0 && willSetRootCallback) {
|
|
16
15
|
willSetRootCallback();
|
|
17
16
|
}
|
|
17
|
+
}, () => {
|
|
18
|
+
didSetRootCallback && didSetRootCallback();
|
|
19
|
+
shouldCallWillSetRootCallback = 0;
|
|
18
20
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const [from, to] = index.split('-');
|
|
22
|
-
Navigator.dispatch(event[KEY_SCENE_ID], 'switchTab', {
|
|
23
|
-
from: Number(from),
|
|
24
|
-
to: Number(to),
|
|
25
|
-
});
|
|
21
|
+
Event.listenSwitchTab((sceneId, from, to) => {
|
|
22
|
+
Navigator.dispatch(sceneId, 'switchTab', { from, to });
|
|
26
23
|
});
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (requestCode < 0) {
|
|
35
|
-
const listener = resultListeners.get(requestCode);
|
|
36
|
-
if (listener) {
|
|
37
|
-
resultListeners.delete(requestCode);
|
|
38
|
-
listener(resultCode, resultData);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
const navigator = Navigator.of(sceneId);
|
|
43
|
-
navigator.result(resultCode, resultData);
|
|
24
|
+
const globalResultListeners = new Map();
|
|
25
|
+
Event.listenComponentResult((sceneId, requestCode, resultCode, data) => {
|
|
26
|
+
if (requestCode < 0) {
|
|
27
|
+
const listener = globalResultListeners.get(requestCode);
|
|
28
|
+
if (listener) {
|
|
29
|
+
globalResultListeners.delete(requestCode);
|
|
30
|
+
listener(resultCode, data);
|
|
44
31
|
}
|
|
45
32
|
}
|
|
33
|
+
else {
|
|
34
|
+
const navigator = Navigator.of(sceneId);
|
|
35
|
+
navigator.result(resultCode, data);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Event.listenComponentVisibility((sceneId) => {
|
|
39
|
+
const navigator = store.getNavigator(sceneId);
|
|
40
|
+
if (navigator) {
|
|
41
|
+
navigator.visibility = 'visible';
|
|
42
|
+
}
|
|
43
|
+
}, (sceneId) => {
|
|
44
|
+
const navigator = store.getNavigator(sceneId);
|
|
45
|
+
if (navigator) {
|
|
46
|
+
navigator.visibility = 'invisible';
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Event.setBarButtonClickHandlerFactory(() => {
|
|
50
|
+
return (sceneId, value) => {
|
|
51
|
+
const navigator = Navigator.of(sceneId);
|
|
52
|
+
value(navigator);
|
|
53
|
+
};
|
|
46
54
|
});
|
|
47
55
|
export class Navigator {
|
|
48
56
|
sceneId;
|
|
@@ -56,16 +64,7 @@ export class Navigator {
|
|
|
56
64
|
return navigator;
|
|
57
65
|
}
|
|
58
66
|
static async find(moduleName) {
|
|
59
|
-
const sceneId = await
|
|
60
|
-
NavigationModule.findSceneIdByModuleName(moduleName, (error, id) => {
|
|
61
|
-
if (error) {
|
|
62
|
-
reject(error);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
resolve(id);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
});
|
|
67
|
+
const sceneId = await NavigationModule.findSceneIdByModuleName(moduleName);
|
|
69
68
|
if (sceneId) {
|
|
70
69
|
return Navigator.of(sceneId);
|
|
71
70
|
}
|
|
@@ -75,45 +74,21 @@ export class Navigator {
|
|
|
75
74
|
return Navigator.of(route.sceneId);
|
|
76
75
|
}
|
|
77
76
|
static currentRoute() {
|
|
78
|
-
return
|
|
79
|
-
NavigationModule.currentRoute((error, route) => {
|
|
80
|
-
if (error) {
|
|
81
|
-
reject(error);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
resolve(route);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
77
|
+
return NavigationModule.currentRoute();
|
|
88
78
|
}
|
|
89
79
|
static routeGraph() {
|
|
90
|
-
return
|
|
91
|
-
NavigationModule.routeGraph((error, result) => {
|
|
92
|
-
if (error) {
|
|
93
|
-
reject(error);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
resolve(result);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
80
|
+
return NavigationModule.routeGraph();
|
|
100
81
|
}
|
|
101
82
|
static setRoot(layout, sticky = false) {
|
|
102
|
-
const pureLayout = bindBarButtonItemClickEvent(layout, {
|
|
103
|
-
inLayout: true,
|
|
104
|
-
navigatorFactory: (sceneId) => {
|
|
105
|
-
return Navigator.of(sceneId);
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
83
|
if (willSetRootCallback) {
|
|
109
84
|
shouldCallWillSetRootCallback++;
|
|
110
85
|
willSetRootCallback();
|
|
111
86
|
}
|
|
112
|
-
const flag = --
|
|
113
|
-
NavigationModule.setRoot(
|
|
87
|
+
const flag = --tagGenerator;
|
|
88
|
+
NavigationModule.setRoot(layout, sticky, flag);
|
|
114
89
|
return new Promise(resolve => {
|
|
115
|
-
const subscription =
|
|
116
|
-
if (
|
|
90
|
+
const subscription = Event.listenSetRoot(() => { }, (tag) => {
|
|
91
|
+
if (tag === flag) {
|
|
117
92
|
subscription.remove();
|
|
118
93
|
resolve();
|
|
119
94
|
}
|
|
@@ -141,16 +116,7 @@ export class Navigator {
|
|
|
141
116
|
}
|
|
142
117
|
}
|
|
143
118
|
if (!intercepted) {
|
|
144
|
-
return
|
|
145
|
-
NavigationModule.dispatch(sceneId, action, params, (error, result) => {
|
|
146
|
-
if (error) {
|
|
147
|
-
reject(error);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
resolve(result);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
119
|
+
return NavigationModule.dispatch(sceneId, action, params);
|
|
154
120
|
}
|
|
155
121
|
return false;
|
|
156
122
|
}
|
|
@@ -161,6 +127,13 @@ export class Navigator {
|
|
|
161
127
|
this.sceneId = sceneId;
|
|
162
128
|
this.moduleName = moduleName;
|
|
163
129
|
}
|
|
130
|
+
_garden;
|
|
131
|
+
get garden() {
|
|
132
|
+
if (!this._garden) {
|
|
133
|
+
this._garden = new Garden(this.sceneId);
|
|
134
|
+
}
|
|
135
|
+
return this._garden;
|
|
136
|
+
}
|
|
164
137
|
visibility = 'pending';
|
|
165
138
|
state = {
|
|
166
139
|
params: {},
|
|
@@ -182,31 +155,23 @@ export class Navigator {
|
|
|
182
155
|
}
|
|
183
156
|
};
|
|
184
157
|
unmount = () => {
|
|
158
|
+
Event.removeBarButtonClickEvent(this.sceneId);
|
|
159
|
+
store.removeNavigator(this.sceneId);
|
|
185
160
|
const codes = [];
|
|
186
|
-
for (const [requestCode, listener] of
|
|
161
|
+
for (const [requestCode, listener] of globalResultListeners) {
|
|
187
162
|
if (listener.sceneId === this.sceneId) {
|
|
188
163
|
codes.push(requestCode);
|
|
189
164
|
listener.cancel();
|
|
190
165
|
}
|
|
191
166
|
}
|
|
192
|
-
codes.forEach(code =>
|
|
167
|
+
codes.forEach(code => globalResultListeners.delete(code));
|
|
193
168
|
if (this.resultListener) {
|
|
194
169
|
this.resultListener.cancel();
|
|
195
170
|
this.resultListener = null;
|
|
196
171
|
}
|
|
197
172
|
};
|
|
198
|
-
_garden;
|
|
199
|
-
get garden() {
|
|
200
|
-
if (!this._garden) {
|
|
201
|
-
this._garden = new Garden(this.sceneId);
|
|
202
|
-
}
|
|
203
|
-
return this._garden;
|
|
204
|
-
}
|
|
205
173
|
resultListener = null;
|
|
206
|
-
waitResult(requestCode
|
|
207
|
-
if (!successful) {
|
|
208
|
-
return Promise.resolve([RESULT_CANCEL, null]);
|
|
209
|
-
}
|
|
174
|
+
waitResult(requestCode) {
|
|
210
175
|
if (this.resultListener) {
|
|
211
176
|
this.resultListener.cancel();
|
|
212
177
|
this.resultListener = null;
|
|
@@ -220,7 +185,7 @@ export class Navigator {
|
|
|
220
185
|
};
|
|
221
186
|
listener.sceneId = this.sceneId;
|
|
222
187
|
if (requestCode < 0) {
|
|
223
|
-
|
|
188
|
+
globalResultListeners.set(requestCode, listener);
|
|
224
189
|
}
|
|
225
190
|
else {
|
|
226
191
|
this.resultListener = listener;
|
|
@@ -229,107 +194,78 @@ export class Navigator {
|
|
|
229
194
|
}
|
|
230
195
|
push = async (moduleName, props = {}, options = {}) => {
|
|
231
196
|
const success = await this.dispatch('push', { moduleName, props, options });
|
|
232
|
-
|
|
233
|
-
|
|
197
|
+
if (!success) {
|
|
198
|
+
return [RESULT_CANCEL];
|
|
199
|
+
}
|
|
200
|
+
return await this.waitResult(0);
|
|
234
201
|
};
|
|
235
202
|
pushLayout = async (layout) => {
|
|
236
203
|
const success = await this.dispatch('pushLayout', { layout });
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
console.log('pop', success);
|
|
242
|
-
return success;
|
|
243
|
-
};
|
|
244
|
-
popTo = (moduleName, inclusive = false) => {
|
|
245
|
-
return this.dispatch('popTo', { moduleName, inclusive });
|
|
246
|
-
};
|
|
247
|
-
popToRoot = () => {
|
|
248
|
-
return this.dispatch('popToRoot');
|
|
249
|
-
};
|
|
250
|
-
redirectTo = async (moduleName, props = {}, options = {}) => {
|
|
251
|
-
const success = await this.dispatch('redirectTo', {
|
|
252
|
-
moduleName,
|
|
253
|
-
props,
|
|
254
|
-
options,
|
|
255
|
-
});
|
|
256
|
-
console.log('redirectTo', success);
|
|
257
|
-
return success;
|
|
258
|
-
};
|
|
259
|
-
isStackRoot = () => {
|
|
260
|
-
return new Promise((resolve, reject) => {
|
|
261
|
-
NavigationModule.isStackRoot(this.sceneId, (error, result) => {
|
|
262
|
-
if (error) {
|
|
263
|
-
reject(error);
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
resolve(result);
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
});
|
|
204
|
+
if (!success) {
|
|
205
|
+
return [RESULT_CANCEL];
|
|
206
|
+
}
|
|
207
|
+
return await this.waitResult(0);
|
|
270
208
|
};
|
|
209
|
+
pop = () => this.dispatch('pop');
|
|
210
|
+
popTo = (moduleName, inclusive = false) => this.dispatch('popTo', { moduleName, inclusive });
|
|
211
|
+
popToRoot = () => this.dispatch('popToRoot');
|
|
212
|
+
redirectTo = (moduleName, props = {}, options = {}) => this.dispatch('redirectTo', {
|
|
213
|
+
moduleName,
|
|
214
|
+
props,
|
|
215
|
+
options,
|
|
216
|
+
});
|
|
217
|
+
isStackRoot = () => NavigationModule.isStackRoot(this.sceneId);
|
|
271
218
|
present = async (moduleName, props = {}, options = {}) => {
|
|
272
|
-
const requestCode = --
|
|
219
|
+
const requestCode = --tagGenerator;
|
|
273
220
|
const success = await this.dispatch('present', {
|
|
274
221
|
moduleName,
|
|
275
222
|
props,
|
|
276
223
|
options,
|
|
277
224
|
requestCode,
|
|
278
225
|
});
|
|
279
|
-
|
|
226
|
+
if (!success) {
|
|
227
|
+
return [RESULT_CANCEL];
|
|
228
|
+
}
|
|
229
|
+
return await this.waitResult(requestCode);
|
|
280
230
|
};
|
|
281
231
|
presentLayout = async (layout) => {
|
|
282
|
-
const requestCode = --
|
|
232
|
+
const requestCode = --tagGenerator;
|
|
283
233
|
const success = await this.dispatch('presentLayout', { layout, requestCode });
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return this.
|
|
234
|
+
if (!success) {
|
|
235
|
+
return [RESULT_CANCEL];
|
|
236
|
+
}
|
|
237
|
+
return await this.waitResult(requestCode);
|
|
288
238
|
};
|
|
239
|
+
dismiss = () => this.dispatch('dismiss');
|
|
289
240
|
showModal = async (moduleName, props = {}, options = {}) => {
|
|
290
|
-
const requestCode = --
|
|
241
|
+
const requestCode = --tagGenerator;
|
|
291
242
|
const success = await this.dispatch('showModal', {
|
|
292
243
|
moduleName,
|
|
293
244
|
props,
|
|
294
245
|
options,
|
|
295
246
|
requestCode,
|
|
296
247
|
});
|
|
297
|
-
|
|
248
|
+
if (!success) {
|
|
249
|
+
return [RESULT_CANCEL];
|
|
250
|
+
}
|
|
251
|
+
return await this.waitResult(requestCode);
|
|
298
252
|
};
|
|
299
253
|
showModalLayout = async (layout) => {
|
|
300
|
-
const requestCode = --
|
|
254
|
+
const requestCode = --tagGenerator;
|
|
301
255
|
const success = await this.dispatch('showModalLayout', { layout, requestCode });
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return this.
|
|
306
|
-
};
|
|
307
|
-
setResult = (resultCode, data = null) => {
|
|
308
|
-
NavigationModule.setResult(this.sceneId, resultCode, data);
|
|
256
|
+
if (!success) {
|
|
257
|
+
return [RESULT_CANCEL];
|
|
258
|
+
}
|
|
259
|
+
return await this.waitResult(requestCode);
|
|
309
260
|
};
|
|
261
|
+
hideModal = () => this.dispatch('hideModal');
|
|
262
|
+
setResult = (resultCode, data = null) => NavigationModule.setResult(this.sceneId, resultCode, data);
|
|
310
263
|
switchTab = async (index, popToRoot = false) => {
|
|
311
|
-
const from = await
|
|
312
|
-
NavigationModule.currentTab(this.sceneId, (error, result) => {
|
|
313
|
-
if (error) {
|
|
314
|
-
reject(error);
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
resolve(result);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
});
|
|
264
|
+
const from = await NavigationModule.currentTab(this.sceneId);
|
|
321
265
|
return this.dispatch('switchTab', { from, to: index, popToRoot });
|
|
322
266
|
};
|
|
323
|
-
toggleMenu = () =>
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return this.dispatch('openMenu');
|
|
328
|
-
};
|
|
329
|
-
closeMenu = () => {
|
|
330
|
-
return this.dispatch('closeMenu');
|
|
331
|
-
};
|
|
332
|
-
signalFirstRenderComplete = () => {
|
|
333
|
-
NavigationModule.signalFirstRenderComplete(this.sceneId);
|
|
334
|
-
};
|
|
267
|
+
toggleMenu = () => this.dispatch('toggleMenu');
|
|
268
|
+
openMenu = () => this.dispatch('openMenu');
|
|
269
|
+
closeMenu = () => this.dispatch('closeMenu');
|
|
270
|
+
signalFirstRenderComplete = () => NavigationModule.signalFirstRenderComplete(this.sceneId);
|
|
335
271
|
}
|