hybrid-navigation 2.13.0-beta.2 → 2.13.0
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/ReactFragment.java +3 -20
- 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 +18 -0
- package/lib/Event.js +71 -0
- package/lib/Garden.d.ts +46 -68
- package/lib/Garden.js +53 -70
- package/lib/GardenModule.d.ts +20 -0
- package/lib/GardenModule.js +3 -0
- package/lib/Navigation.d.ts +74 -0
- package/lib/Navigation.js +182 -0
- package/lib/NavigationComponentWrap.d.ts +19 -0
- package/lib/NavigationComponentWrap.js +46 -0
- package/lib/NavigationModule.d.ts +33 -22
- package/lib/NavigationModule.js +79 -22
- package/lib/Navigator.d.ts +55 -28
- package/lib/Navigator.js +122 -263
- package/lib/{typing.d.ts → Options.d.ts} +46 -50
- package/lib/{typing.js → Options.js} +0 -0
- package/lib/ReactRegistry.d.ts +16 -14
- package/lib/ReactRegistry.js +18 -93
- package/lib/Route.d.ts +74 -0
- package/lib/{router/typing.js → Route.js} +0 -0
- package/lib/handler/BarButtonEventHandler.d.ts +10 -0
- package/lib/handler/BarButtonEventHandler.js +38 -0
- package/lib/handler/DispatchCommandHandler.d.ts +24 -0
- package/lib/handler/DispatchCommandHandler.js +28 -0
- package/lib/handler/LayoutCommandHandler.d.ts +11 -0
- package/lib/handler/LayoutCommandHandler.js +39 -0
- package/lib/handler/ResultEventHandler.d.ts +15 -0
- package/lib/handler/ResultEventHandler.js +47 -0
- package/lib/handler/VisibilityEventHandler.d.ts +13 -0
- package/lib/handler/VisibilityEventHandler.js +32 -0
- package/lib/hooks.d.ts +0 -1
- package/lib/hooks.js +14 -29
- package/lib/index.d.ts +10 -2
- package/lib/index.js +17 -2
- package/lib/router/drawer.d.ts +1 -1
- package/lib/router/index.d.ts +4 -7
- package/lib/router/index.js +13 -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 +123 -0
- package/src/Garden.ts +63 -149
- package/src/GardenModule.ts +24 -0
- package/src/Navigation.ts +278 -0
- package/src/NavigationComponentWrap.tsx +73 -0
- package/src/NavigationModule.ts +118 -29
- package/src/Navigator.ts +147 -319
- package/src/{typing.ts → Options.ts} +51 -57
- package/src/ReactRegistry.tsx +25 -127
- package/src/Route.ts +88 -0
- package/src/handler/BarButtonEventHandler.ts +50 -0
- package/src/handler/DispatchCommandHandler.ts +56 -0
- package/src/handler/LayoutCommandHandler.ts +49 -0
- package/src/handler/ResultEventHandler.ts +67 -0
- package/src/handler/VisibilityEventHandler.ts +44 -0
- package/src/hooks.ts +13 -38
- package/src/index.ts +38 -3
- package/src/router/drawer.ts +1 -1
- package/src/router/index.ts +36 -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/Navigator.js
CHANGED
|
@@ -1,48 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { bindBarButtonItemClickEvent } from './utils';
|
|
1
|
+
import { createContext } from 'react';
|
|
3
2
|
import store from './store';
|
|
4
3
|
import { Garden } from './Garden';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
shouldCallWillSetRootCallback = 0;
|
|
13
|
-
});
|
|
14
|
-
EventEmitter.addListener(EVENT_WILL_SET_ROOT, _ => {
|
|
15
|
-
if (shouldCallWillSetRootCallback === 0 && willSetRootCallback) {
|
|
16
|
-
willSetRootCallback();
|
|
4
|
+
import Navigation, { RESULT_CANCEL, } from './Navigation';
|
|
5
|
+
export const NavigationContext = createContext(null);
|
|
6
|
+
let tagGenerator = 0;
|
|
7
|
+
Navigation.addGlobalVisibilityEventListener((sceneId, visibility) => {
|
|
8
|
+
const navigator = store.getNavigator(sceneId);
|
|
9
|
+
if (navigator) {
|
|
10
|
+
navigator.visibility = visibility;
|
|
17
11
|
}
|
|
18
12
|
});
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
Navigator.dispatch(event[KEY_SCENE_ID], 'switchTab', {
|
|
23
|
-
from: Number(from),
|
|
24
|
-
to: Number(to),
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
const resultListeners = new Map();
|
|
28
|
-
EventEmitter.addListener(EVENT_NAVIGATION, data => {
|
|
29
|
-
if (data[KEY_ON] === ON_COMPONENT_RESULT) {
|
|
30
|
-
const requestCode = data[KEY_REQUEST_CODE];
|
|
31
|
-
const resultCode = data[KEY_RESULT_CODE];
|
|
32
|
-
const resultData = data[KEY_RESULT_DATA];
|
|
33
|
-
const sceneId = data[KEY_SCENE_ID];
|
|
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);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
13
|
+
Navigation.setBarButtonClickEventListener((sceneId, value) => {
|
|
14
|
+
const navigator = Navigator.of(sceneId);
|
|
15
|
+
value(navigator);
|
|
46
16
|
});
|
|
47
17
|
export class Navigator {
|
|
48
18
|
sceneId;
|
|
@@ -55,17 +25,13 @@ export class Navigator {
|
|
|
55
25
|
}
|
|
56
26
|
return navigator;
|
|
57
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use Navigation.findSceneIdByModuleName() instead.
|
|
30
|
+
* @param moduleName
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
58
33
|
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
|
-
});
|
|
34
|
+
const sceneId = await Navigation.findSceneIdByModuleName(moduleName);
|
|
69
35
|
if (sceneId) {
|
|
70
36
|
return Navigator.of(sceneId);
|
|
71
37
|
}
|
|
@@ -74,93 +40,64 @@ export class Navigator {
|
|
|
74
40
|
const route = await Navigator.currentRoute();
|
|
75
41
|
return Navigator.of(route.sceneId);
|
|
76
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Use Navigation.currentRoute() instead
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
77
47
|
static currentRoute() {
|
|
78
|
-
return
|
|
79
|
-
NavigationModule.currentRoute((error, route) => {
|
|
80
|
-
if (error) {
|
|
81
|
-
reject(error);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
resolve(route);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
48
|
+
return Navigation.currentRoute();
|
|
88
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Use Navigation.routeGraph() instead
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
89
54
|
static routeGraph() {
|
|
90
|
-
return
|
|
91
|
-
NavigationModule.routeGraph((error, result) => {
|
|
92
|
-
if (error) {
|
|
93
|
-
reject(error);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
resolve(result);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
55
|
+
return Navigation.routeGraph();
|
|
100
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use Navigation.setRoot() instead
|
|
59
|
+
* @param layout
|
|
60
|
+
* @param sticky
|
|
61
|
+
*/
|
|
101
62
|
static setRoot(layout, sticky = false) {
|
|
102
|
-
|
|
103
|
-
inLayout: true,
|
|
104
|
-
navigatorFactory: (sceneId) => {
|
|
105
|
-
return Navigator.of(sceneId);
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
if (willSetRootCallback) {
|
|
109
|
-
shouldCallWillSetRootCallback++;
|
|
110
|
-
willSetRootCallback();
|
|
111
|
-
}
|
|
112
|
-
const flag = --tag;
|
|
113
|
-
NavigationModule.setRoot(pureLayout, sticky, flag);
|
|
114
|
-
return new Promise(resolve => {
|
|
115
|
-
const subscription = EventEmitter.addListener(EVENT_DID_SET_ROOT, (data) => {
|
|
116
|
-
if (data.tag === flag) {
|
|
117
|
-
subscription.remove();
|
|
118
|
-
resolve();
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
63
|
+
Navigation.setRoot(layout, sticky);
|
|
122
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Use Navigation.setRootLayoutUpdateListener() instead
|
|
67
|
+
* @param willSetRoot
|
|
68
|
+
* @param didSetRoot
|
|
69
|
+
*/
|
|
123
70
|
static setRootLayoutUpdateListener(willSetRoot = () => { }, didSetRoot = () => { }) {
|
|
124
|
-
|
|
125
|
-
didSetRootCallback = didSetRoot;
|
|
71
|
+
Navigation.setRootLayoutUpdateListener(willSetRoot, didSetRoot);
|
|
126
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use Navigation.dispatch() instead
|
|
75
|
+
* @param sceneId
|
|
76
|
+
* @param action
|
|
77
|
+
* @param params
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
127
80
|
static async dispatch(sceneId, action, params = {}) {
|
|
128
|
-
|
|
129
|
-
const { from, to } = params;
|
|
130
|
-
if (interceptor) {
|
|
131
|
-
const result = interceptor(action, {
|
|
132
|
-
sceneId,
|
|
133
|
-
from,
|
|
134
|
-
to,
|
|
135
|
-
});
|
|
136
|
-
if (result instanceof Promise) {
|
|
137
|
-
intercepted = await result;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
intercepted = result;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (!intercepted) {
|
|
144
|
-
return new Promise((resolve, reject) => {
|
|
145
|
-
NavigationModule.dispatch(sceneId, action, params, (error, result) => {
|
|
146
|
-
if (error) {
|
|
147
|
-
reject(error);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
resolve(result);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return false;
|
|
81
|
+
return Navigation.dispatch(sceneId, action, params);
|
|
156
82
|
}
|
|
157
|
-
|
|
158
|
-
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Use Navigation.setInterceptor() instead
|
|
85
|
+
* @param interceptor
|
|
86
|
+
*/
|
|
87
|
+
static setInterceptor(interceptor) {
|
|
88
|
+
Navigation.setInterceptor(interceptor);
|
|
159
89
|
}
|
|
160
90
|
constructor(sceneId, moduleName) {
|
|
161
91
|
this.sceneId = sceneId;
|
|
162
92
|
this.moduleName = moduleName;
|
|
163
93
|
}
|
|
94
|
+
_garden;
|
|
95
|
+
get garden() {
|
|
96
|
+
if (!this._garden) {
|
|
97
|
+
this._garden = new Garden(this.sceneId);
|
|
98
|
+
}
|
|
99
|
+
return this._garden;
|
|
100
|
+
}
|
|
164
101
|
visibility = 'pending';
|
|
165
102
|
state = {
|
|
166
103
|
params: {},
|
|
@@ -168,168 +105,90 @@ export class Navigator {
|
|
|
168
105
|
setParams = (params) => {
|
|
169
106
|
this.state.params = { ...this.state.params, ...params };
|
|
170
107
|
};
|
|
171
|
-
dispatch = (action, params = {}) => {
|
|
172
|
-
return Navigator.dispatch(this.sceneId, action, {
|
|
173
|
-
from: this.moduleName,
|
|
174
|
-
to: params.moduleName,
|
|
175
|
-
...params,
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
result = (resultCode, data) => {
|
|
179
|
-
if (this.resultListener) {
|
|
180
|
-
this.resultListener(resultCode, data);
|
|
181
|
-
this.resultListener = null;
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
108
|
unmount = () => {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (listener.sceneId === this.sceneId) {
|
|
188
|
-
codes.push(requestCode);
|
|
189
|
-
listener.cancel();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
codes.forEach(code => resultListeners.delete(code));
|
|
193
|
-
if (this.resultListener) {
|
|
194
|
-
this.resultListener.cancel();
|
|
195
|
-
this.resultListener = null;
|
|
196
|
-
}
|
|
109
|
+
store.removeNavigator(this.sceneId);
|
|
110
|
+
Navigation.unmount(this.sceneId);
|
|
197
111
|
};
|
|
198
|
-
_garden;
|
|
199
|
-
get garden() {
|
|
200
|
-
if (!this._garden) {
|
|
201
|
-
this._garden = new Garden(this.sceneId);
|
|
202
|
-
}
|
|
203
|
-
return this._garden;
|
|
204
|
-
}
|
|
205
|
-
resultListener = null;
|
|
206
|
-
waitResult(requestCode, successful) {
|
|
207
|
-
if (!successful) {
|
|
208
|
-
return Promise.resolve([RESULT_CANCEL, null]);
|
|
209
|
-
}
|
|
210
|
-
if (this.resultListener) {
|
|
211
|
-
this.resultListener.cancel();
|
|
212
|
-
this.resultListener = null;
|
|
213
|
-
}
|
|
214
|
-
return new Promise(resolve => {
|
|
215
|
-
const listener = (resultCode, data) => {
|
|
216
|
-
resolve([resultCode, data]);
|
|
217
|
-
};
|
|
218
|
-
listener.cancel = () => {
|
|
219
|
-
resolve([RESULT_CANCEL, null]);
|
|
220
|
-
};
|
|
221
|
-
listener.sceneId = this.sceneId;
|
|
222
|
-
if (requestCode < 0) {
|
|
223
|
-
resultListeners.set(requestCode, listener);
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
this.resultListener = listener;
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
112
|
push = async (moduleName, props = {}, options = {}) => {
|
|
231
|
-
const success = await
|
|
232
|
-
|
|
233
|
-
|
|
113
|
+
const success = await Navigation.dispatch(this.sceneId, 'push', { moduleName, props, options });
|
|
114
|
+
if (!success) {
|
|
115
|
+
return [RESULT_CANCEL, null];
|
|
116
|
+
}
|
|
117
|
+
return await Navigation.result(this.sceneId, 0);
|
|
234
118
|
};
|
|
235
119
|
pushLayout = async (layout) => {
|
|
236
|
-
const success = await
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
});
|
|
270
|
-
};
|
|
120
|
+
const success = await Navigation.dispatch(this.sceneId, 'pushLayout', { layout });
|
|
121
|
+
if (!success) {
|
|
122
|
+
return [RESULT_CANCEL, null];
|
|
123
|
+
}
|
|
124
|
+
return await Navigation.result(this.sceneId, 0);
|
|
125
|
+
};
|
|
126
|
+
pop = () => Navigation.dispatch(this.sceneId, 'pop');
|
|
127
|
+
popTo = (moduleName, inclusive = false) => Navigation.dispatch(this.sceneId, 'popTo', { moduleName, inclusive });
|
|
128
|
+
popToRoot = () => Navigation.dispatch(this.sceneId, 'popToRoot');
|
|
129
|
+
redirectTo = (moduleName, props = {}, options = {}) => Navigation.dispatch(this.sceneId, 'redirectTo', {
|
|
130
|
+
moduleName,
|
|
131
|
+
props,
|
|
132
|
+
options,
|
|
133
|
+
});
|
|
271
134
|
present = async (moduleName, props = {}, options = {}) => {
|
|
272
|
-
const requestCode = --
|
|
273
|
-
const success = await
|
|
135
|
+
const requestCode = --tagGenerator;
|
|
136
|
+
const success = await Navigation.dispatch(this.sceneId, 'present', {
|
|
274
137
|
moduleName,
|
|
275
138
|
props,
|
|
276
139
|
options,
|
|
277
140
|
requestCode,
|
|
278
141
|
});
|
|
279
|
-
|
|
142
|
+
if (!success) {
|
|
143
|
+
return [RESULT_CANCEL, null];
|
|
144
|
+
}
|
|
145
|
+
return await Navigation.result(this.sceneId, requestCode);
|
|
280
146
|
};
|
|
281
147
|
presentLayout = async (layout) => {
|
|
282
|
-
const requestCode = --
|
|
283
|
-
const success = await
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
148
|
+
const requestCode = --tagGenerator;
|
|
149
|
+
const success = await Navigation.dispatch(this.sceneId, 'presentLayout', {
|
|
150
|
+
layout,
|
|
151
|
+
requestCode,
|
|
152
|
+
});
|
|
153
|
+
if (!success) {
|
|
154
|
+
return [RESULT_CANCEL, null];
|
|
155
|
+
}
|
|
156
|
+
return await Navigation.result(this.sceneId, requestCode);
|
|
288
157
|
};
|
|
158
|
+
dismiss = () => Navigation.dispatch(this.sceneId, 'dismiss');
|
|
289
159
|
showModal = async (moduleName, props = {}, options = {}) => {
|
|
290
|
-
const requestCode = --
|
|
291
|
-
const success = await
|
|
160
|
+
const requestCode = --tagGenerator;
|
|
161
|
+
const success = await Navigation.dispatch(this.sceneId, 'showModal', {
|
|
292
162
|
moduleName,
|
|
293
163
|
props,
|
|
294
164
|
options,
|
|
295
165
|
requestCode,
|
|
296
166
|
});
|
|
297
|
-
|
|
167
|
+
if (!success) {
|
|
168
|
+
return [RESULT_CANCEL, null];
|
|
169
|
+
}
|
|
170
|
+
return await Navigation.result(this.sceneId, requestCode);
|
|
298
171
|
};
|
|
299
172
|
showModalLayout = async (layout) => {
|
|
300
|
-
const requestCode = --
|
|
301
|
-
const success = await
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
hideModal = () => {
|
|
305
|
-
return this.dispatch('hideModal');
|
|
306
|
-
};
|
|
307
|
-
setResult = (resultCode, data = null) => {
|
|
308
|
-
NavigationModule.setResult(this.sceneId, resultCode, data);
|
|
309
|
-
};
|
|
310
|
-
switchTab = async (index, popToRoot = false) => {
|
|
311
|
-
const from = await new Promise((resolve, reject) => {
|
|
312
|
-
NavigationModule.currentTab(this.sceneId, (error, result) => {
|
|
313
|
-
if (error) {
|
|
314
|
-
reject(error);
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
resolve(result);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
173
|
+
const requestCode = --tagGenerator;
|
|
174
|
+
const success = await Navigation.dispatch(this.sceneId, 'showModalLayout', {
|
|
175
|
+
layout,
|
|
176
|
+
requestCode,
|
|
320
177
|
});
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return this.
|
|
325
|
-
};
|
|
326
|
-
openMenu = () => {
|
|
327
|
-
return this.dispatch('openMenu');
|
|
328
|
-
};
|
|
329
|
-
closeMenu = () => {
|
|
330
|
-
return this.dispatch('closeMenu');
|
|
331
|
-
};
|
|
332
|
-
signalFirstRenderComplete = () => {
|
|
333
|
-
NavigationModule.signalFirstRenderComplete(this.sceneId);
|
|
178
|
+
if (!success) {
|
|
179
|
+
return [RESULT_CANCEL, null];
|
|
180
|
+
}
|
|
181
|
+
return await Navigation.result(this.sceneId, requestCode);
|
|
334
182
|
};
|
|
183
|
+
hideModal = () => Navigation.dispatch(this.sceneId, 'hideModal');
|
|
184
|
+
setResult = (resultCode, data = null) => Navigation.setResult(this.sceneId, resultCode, data);
|
|
185
|
+
switchTab = async (index, popToRoot = false) => {
|
|
186
|
+
const from = await Navigation.currentTab(this.sceneId);
|
|
187
|
+
return Navigation.dispatch(this.sceneId, 'switchTab', { from, to: index, popToRoot });
|
|
188
|
+
};
|
|
189
|
+
toggleMenu = () => Navigation.dispatch(this.sceneId, 'toggleMenu');
|
|
190
|
+
openMenu = () => Navigation.dispatch(this.sceneId, 'openMenu');
|
|
191
|
+
closeMenu = () => Navigation.dispatch(this.sceneId, 'closeMenu');
|
|
192
|
+
isStackRoot = () => Navigation.isStackRoot(this.sceneId);
|
|
193
|
+
signalFirstRenderComplete = () => Navigation.signalFirstRenderComplete(this.sceneId);
|
|
335
194
|
}
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import { Insets } from 'react-native';
|
|
2
|
-
import { Navigator } from './Navigator';
|
|
3
|
-
export interface IndexType {
|
|
4
|
-
[index: string]: any;
|
|
5
|
-
}
|
|
6
|
-
export interface PropsType {
|
|
7
|
-
[index: string]: any;
|
|
8
|
-
}
|
|
9
|
-
export declare type ResultType = IndexType | null;
|
|
10
|
-
interface Extras {
|
|
11
|
-
sceneId: string;
|
|
12
|
-
from?: number | string;
|
|
13
|
-
to?: number | string;
|
|
14
|
-
}
|
|
15
|
-
export interface NavigationInterceptor {
|
|
16
|
-
(action: string, extras: Extras): boolean | Promise<boolean>;
|
|
17
|
-
}
|
|
1
|
+
import type { Insets } from 'react-native';
|
|
2
|
+
import type { Navigator } from './Navigator';
|
|
18
3
|
export declare type Color = string;
|
|
19
4
|
export declare type ImageSource = {
|
|
20
5
|
uri: string;
|
|
@@ -93,41 +78,52 @@ export interface TabItem {
|
|
|
93
78
|
unselectedIcon?: ImageSource;
|
|
94
79
|
hideTabBarWhenPush?: boolean;
|
|
95
80
|
}
|
|
96
|
-
export interface
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
props?: IndexType;
|
|
100
|
-
options?: NavigationItem;
|
|
101
|
-
};
|
|
81
|
+
export interface ShadowImage {
|
|
82
|
+
image?: ImageSource;
|
|
83
|
+
color?: Color;
|
|
102
84
|
}
|
|
103
|
-
export interface
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
85
|
+
export interface DefaultOptions {
|
|
86
|
+
screenBackgroundColor?: Color;
|
|
87
|
+
topBarStyle?: BarStyle;
|
|
88
|
+
topBarColor?: Color;
|
|
89
|
+
topBarColorDarkContent?: Color;
|
|
90
|
+
topBarColorLightContent?: Color;
|
|
91
|
+
statusBarColorAndroid?: Color;
|
|
92
|
+
navigationBarColorAndroid?: Color;
|
|
93
|
+
hideBackTitleIOS?: boolean;
|
|
94
|
+
elevationAndroid?: number;
|
|
95
|
+
shadowImage?: ShadowImage;
|
|
96
|
+
backIcon?: ImageSource;
|
|
97
|
+
topBarTintColor?: Color;
|
|
98
|
+
topBarTintColorDarkContent?: Color;
|
|
99
|
+
topBarTintColorLightContent?: Color;
|
|
100
|
+
titleTextColor?: Color;
|
|
101
|
+
titleTextColorDarkContent?: Color;
|
|
102
|
+
titleTextColorLightContent?: Color;
|
|
103
|
+
titleTextSize?: number;
|
|
104
|
+
titleAlignmentAndroid?: TitleAlignment;
|
|
105
|
+
barButtonItemTextSize?: number;
|
|
106
|
+
swipeBackEnabledAndroid?: boolean;
|
|
107
|
+
splitTopBarTransitionIOS?: boolean;
|
|
108
|
+
scrimAlphaAndroid?: number;
|
|
109
|
+
displayCutoutWhenLandscapeAndroid?: boolean;
|
|
110
|
+
tabBarColor?: Color;
|
|
111
|
+
tabBarShadowImage?: ShadowImage;
|
|
112
|
+
tabBarItemColor?: Color;
|
|
113
|
+
tabBarUnselectedItemColor?: Color;
|
|
114
|
+
tabBarBadgeColor?: Color;
|
|
108
115
|
}
|
|
109
|
-
export
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
export declare type TabBarStyle = Pick<DefaultOptions, 'tabBarColor' | 'tabBarShadowImage' | 'tabBarItemColor' | 'tabBarUnselectedItemColor'>;
|
|
117
|
+
export interface TabItemInfo {
|
|
118
|
+
index: number;
|
|
119
|
+
title?: string;
|
|
120
|
+
badge?: {
|
|
121
|
+
text?: string;
|
|
122
|
+
hidden: boolean;
|
|
123
|
+
dot?: boolean;
|
|
117
124
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
children: [BuildInLayout | Layout, BuildInLayout | Layout];
|
|
122
|
-
options?: {
|
|
123
|
-
maxDrawerWidth?: number;
|
|
124
|
-
minDrawerMargin?: number;
|
|
125
|
-
menuInteractive?: boolean;
|
|
126
|
-
};
|
|
125
|
+
icon?: {
|
|
126
|
+
selected: ImageSource;
|
|
127
|
+
unselected?: ImageSource;
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
|
-
export declare type BuildInLayout = Screen | Stack | Tabs | Drawer;
|
|
130
|
-
export interface Layout {
|
|
131
|
-
[index: string]: {};
|
|
132
|
-
}
|
|
133
|
-
export {};
|
|
File without changes
|
package/lib/ReactRegistry.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { ComponentProvider } from 'react-native';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { Garden } from './Garden';
|
|
5
|
-
import { RouteConfig } from './router';
|
|
6
|
-
import { NavigationItem } from './typing';
|
|
7
|
-
export interface InjectedProps {
|
|
8
|
-
navigator: Navigator;
|
|
9
|
-
garden: Garden;
|
|
10
|
-
sceneId: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const NavigationContext: React.Context<any>;
|
|
13
|
-
export declare type HOC = (WrappedComponent: React.ComponentType<any>) => React.ComponentType<any>;
|
|
2
|
+
import type { RouteConfig } from './Route';
|
|
3
|
+
import { HOC } from './Navigation';
|
|
14
4
|
export declare class ReactRegistry {
|
|
15
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use Navigation.startRegisterComponent() instead.
|
|
7
|
+
* @param hoc
|
|
8
|
+
*/
|
|
16
9
|
static startRegisterComponent(hoc?: HOC): void;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use Navigation.endRegisterComponent() instead.
|
|
12
|
+
*/
|
|
17
13
|
static endRegisterComponent(): void;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @deprecated Use Navigation.registerComponent() instead.
|
|
17
|
+
* @param appKey
|
|
18
|
+
* @param getComponentFunc
|
|
19
|
+
* @param routeConfig
|
|
20
|
+
*/
|
|
18
21
|
static registerComponent(appKey: string, getComponentFunc: ComponentProvider, routeConfig?: RouteConfig): void;
|
|
19
22
|
}
|
|
20
|
-
export declare function withNavigationItem(item: NavigationItem): (WrappedComponent: React.ComponentType<any>) => React.ComponentType<any>;
|