hybrid-navigation 2.12.3 → 2.13.0-beta.1
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/README.md +63 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +6 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +29 -30
- package/android/src/main/java/com/reactnative/hybridnavigation/Navigator.java +2 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +4 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +24 -33
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +22 -22
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +8 -8
- package/ios/HybridNavigation/GlobalStyle.h +0 -8
- package/ios/HybridNavigation/GlobalStyle.m +2 -8
- package/ios/HybridNavigation/HBDUtils.h +5 -13
- package/ios/HybridNavigation/HBDUtils.m +2 -12
- package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.m +91 -67
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.h +2 -7
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +28 -26
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +127 -99
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +199 -142
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.m +144 -124
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDEventEmitter.h +1 -11
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDEventEmitter.m +4 -10
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +6 -0
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +161 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.h +6 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +237 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigator.h +20 -0
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDReactBridgeManager.h +12 -20
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDReactBridgeManager.m +91 -91
- package/ios/HybridNavigation/View/HBDBarButtonItem.h +0 -8
- package/ios/HybridNavigation/View/HBDBarButtonItem.m +1 -11
- package/ios/HybridNavigation/View/HBDNavigationBar.h +0 -8
- package/ios/HybridNavigation/View/HBDNavigationBar.m +13 -20
- package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -8
- package/ios/HybridNavigation/View/HBDReactTabBar.m +1 -8
- package/ios/HybridNavigation/View/HBDRootView.h +3 -10
- package/ios/HybridNavigation/View/HBDRootView.m +14 -25
- package/ios/HybridNavigation/View/HBDTitleView.h +0 -9
- package/ios/HybridNavigation/View/HBDTitleView.m +1 -26
- package/ios/HybridNavigation/View/UITabBar+Badge.h +0 -8
- package/ios/HybridNavigation/View/UITabBar+Badge.m +0 -7
- package/ios/HybridNavigation/ViewController/HBDDrawerController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDDrawerController.m +2 -9
- package/ios/HybridNavigation/ViewController/HBDFadeAnimation.h +9 -0
- package/ios/HybridNavigation/ViewController/HBDFadeAnimation.m +22 -0
- package/ios/HybridNavigation/ViewController/HBDNavigationController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +17 -120
- package/ios/HybridNavigation/ViewController/HBDPopAnimation.h +0 -7
- package/ios/HybridNavigation/ViewController/HBDPopAnimation.m +1 -8
- package/ios/HybridNavigation/ViewController/HBDPushAnimation.h +0 -7
- package/ios/HybridNavigation/ViewController/HBDPushAnimation.m +1 -8
- package/ios/HybridNavigation/ViewController/HBDReactViewController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDReactViewController.m +60 -27
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +15 -11
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.m +23 -33
- package/ios/HybridNavigation/ViewController/HBDViewController.h +1 -8
- package/ios/HybridNavigation/ViewController/HBDViewController.m +6 -23
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.h +0 -8
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -8
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +2 -16
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +32 -46
- package/lib/Garden.d.ts +3 -0
- package/lib/Garden.js +12 -1
- package/lib/NavigationModule.d.ts +0 -2
- package/lib/NavigationModule.js +0 -3
- package/lib/Navigator.d.ts +25 -25
- package/lib/Navigator.js +116 -73
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +4 -6
- package/src/Garden.ts +15 -1
- package/src/NavigationModule.ts +0 -4
- package/src/Navigator.ts +96 -58
- package/src/index.ts +1 -1
- package/ios/HybridNavigation/Bridge/HBDGardenModule.h +0 -14
- package/ios/HybridNavigation/Bridge/HBDGardenModule.m +0 -155
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.h +0 -15
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +0 -272
- package/ios/HybridNavigation/Navigator/HBDNavigator.h +0 -26
package/lib/Garden.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
2
2
|
import { bindBarButtonItemClickEvent } from './utils';
|
|
3
3
|
const GardenModule = NativeModules.GardenModule;
|
|
4
|
+
const { STATUSBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE, TOOLBAR_HEIGHT } = GardenModule.getConstants();
|
|
5
|
+
if (Platform.OS === 'ios') {
|
|
6
|
+
const GardenEventEmitter = new NativeEventEmitter(GardenModule);
|
|
7
|
+
GardenEventEmitter.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
8
|
+
Garden.statusBarHeight = statusBarHeight;
|
|
9
|
+
Garden.topBarHeight = statusBarHeight + TOOLBAR_HEIGHT;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
4
12
|
export class Garden {
|
|
5
13
|
sceneId;
|
|
6
14
|
static setStyle(style = {}) {
|
|
7
15
|
GardenModule.setStyle(style);
|
|
8
16
|
}
|
|
17
|
+
static statusBarHeight = STATUSBAR_HEIGHT;
|
|
18
|
+
static toolbarHeight = TOOLBAR_HEIGHT;
|
|
19
|
+
static topBarHeight = TOOLBAR_HEIGHT + STATUSBAR_HEIGHT;
|
|
9
20
|
constructor(sceneId) {
|
|
10
21
|
this.sceneId = sceneId;
|
|
11
22
|
}
|
|
@@ -19,6 +19,4 @@ export declare const KEY_INDEX: string;
|
|
|
19
19
|
export declare const KEY_ACTION: string;
|
|
20
20
|
export declare const RESULT_OK: number;
|
|
21
21
|
export declare const RESULT_CANCEL: number;
|
|
22
|
-
export declare const toolbarHeight: number;
|
|
23
|
-
export declare const TOOLBAR_HEIGHT: number;
|
|
24
22
|
export { EventEmitter, NavigationModule };
|
package/lib/NavigationModule.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
2
2
|
const NavigationModule = NativeModules.NavigationModule;
|
|
3
|
-
const GardenModule = NativeModules.GardenModule;
|
|
4
3
|
const HBDEventEmitter = NativeModules.HBDEventEmitter;
|
|
5
4
|
const EventEmitter = new NativeEventEmitter(HBDEventEmitter);
|
|
6
5
|
export const EVENT_SWITCH_TAB = HBDEventEmitter.EVENT_SWITCH_TAB;
|
|
@@ -21,6 +20,4 @@ export const KEY_INDEX = HBDEventEmitter.KEY_INDEX;
|
|
|
21
20
|
export const KEY_ACTION = HBDEventEmitter.KEY_ACTION;
|
|
22
21
|
export const RESULT_OK = NavigationModule.RESULT_OK;
|
|
23
22
|
export const RESULT_CANCEL = NavigationModule.RESULT_CANCEL;
|
|
24
|
-
export const toolbarHeight = GardenModule.TOOLBAR_HEIGHT;
|
|
25
|
-
export const TOOLBAR_HEIGHT = GardenModule.TOOLBAR_HEIGHT;
|
|
26
23
|
export { EventEmitter, NavigationModule };
|
package/lib/Navigator.d.ts
CHANGED
|
@@ -29,37 +29,37 @@ export declare class Navigator {
|
|
|
29
29
|
static setRootLayoutUpdateListener(willSetRoot?: () => void, didSetRoot?: () => void): void;
|
|
30
30
|
static dispatch(sceneId: string, action: string, params?: Params): Promise<boolean>;
|
|
31
31
|
static setInterceptor(interceptFn: NavigationInterceptor): void;
|
|
32
|
-
visibility: Visibility;
|
|
33
32
|
constructor(sceneId: string, moduleName?: string | undefined);
|
|
33
|
+
visibility: Visibility;
|
|
34
34
|
readonly state: NavigationState;
|
|
35
|
-
setParams(params: {
|
|
35
|
+
setParams: (params: {
|
|
36
36
|
[index: string]: any;
|
|
37
|
-
})
|
|
38
|
-
dispatch(action: string, params?: Params)
|
|
39
|
-
result(resultCode: number, data: ResultType)
|
|
40
|
-
unmount()
|
|
37
|
+
}) => void;
|
|
38
|
+
dispatch: (action: string, params?: Params) => Promise<boolean>;
|
|
39
|
+
result: (resultCode: number, data: ResultType) => void;
|
|
40
|
+
unmount: () => void;
|
|
41
41
|
private _garden?;
|
|
42
42
|
get garden(): Garden;
|
|
43
43
|
private resultListener;
|
|
44
44
|
private waitResult;
|
|
45
|
-
push<T extends ResultType, P extends PropsType = PropsType>(moduleName: string, props?: P, options?: NavigationItem)
|
|
46
|
-
pushLayout<T extends ResultType>(layout: BuildInLayout | Layout)
|
|
47
|
-
pop()
|
|
48
|
-
popTo(moduleName: string, inclusive?: boolean)
|
|
49
|
-
popToRoot()
|
|
50
|
-
redirectTo<P extends PropsType = PropsType>(moduleName: string, props?: P, options?: NavigationItem)
|
|
51
|
-
isStackRoot()
|
|
52
|
-
present<T extends ResultType, P extends PropsType = PropsType>(moduleName: string, props?: P, options?: NavigationItem)
|
|
53
|
-
presentLayout<T extends ResultType>(layout: BuildInLayout | Layout)
|
|
54
|
-
dismiss()
|
|
55
|
-
showModal<T extends ResultType, P extends PropsType = PropsType>(moduleName: string, props?: P, options?: NavigationItem)
|
|
56
|
-
showModalLayout<T extends ResultType>(layout: BuildInLayout | Layout)
|
|
57
|
-
hideModal()
|
|
58
|
-
setResult<T extends ResultType>(resultCode: number, data?: T)
|
|
59
|
-
switchTab(index: number, popToRoot?: boolean)
|
|
60
|
-
toggleMenu()
|
|
61
|
-
openMenu()
|
|
62
|
-
closeMenu()
|
|
63
|
-
signalFirstRenderComplete()
|
|
45
|
+
push: <T extends ResultType, P extends PropsType = PropsType>(moduleName: string, props?: P, options?: NavigationItem) => Promise<[number, T]>;
|
|
46
|
+
pushLayout: <T extends ResultType>(layout: BuildInLayout | Layout) => Promise<[number, T]>;
|
|
47
|
+
pop: () => Promise<boolean>;
|
|
48
|
+
popTo: (moduleName: string, inclusive?: boolean) => Promise<boolean>;
|
|
49
|
+
popToRoot: () => Promise<boolean>;
|
|
50
|
+
redirectTo: <P extends PropsType = PropsType>(moduleName: string, props?: P, options?: NavigationItem) => Promise<boolean>;
|
|
51
|
+
isStackRoot: () => Promise<boolean>;
|
|
52
|
+
present: <T extends ResultType, P extends PropsType = PropsType>(moduleName: string, props?: P, options?: NavigationItem) => Promise<[number, T]>;
|
|
53
|
+
presentLayout: <T extends ResultType>(layout: BuildInLayout | Layout) => Promise<[number, T]>;
|
|
54
|
+
dismiss: () => Promise<boolean>;
|
|
55
|
+
showModal: <T extends ResultType, P extends PropsType = PropsType>(moduleName: string, props?: P, options?: NavigationItem) => Promise<[number, T]>;
|
|
56
|
+
showModalLayout: <T extends ResultType>(layout: BuildInLayout | Layout) => Promise<[number, T]>;
|
|
57
|
+
hideModal: () => Promise<boolean>;
|
|
58
|
+
setResult: <T extends ResultType>(resultCode: number, data?: T) => void;
|
|
59
|
+
switchTab: (index: number, popToRoot?: boolean) => Promise<boolean>;
|
|
60
|
+
toggleMenu: () => Promise<boolean>;
|
|
61
|
+
openMenu: () => Promise<boolean>;
|
|
62
|
+
closeMenu: () => Promise<boolean>;
|
|
63
|
+
signalFirstRenderComplete: () => void;
|
|
64
64
|
}
|
|
65
65
|
export {};
|
package/lib/Navigator.js
CHANGED
|
@@ -56,7 +56,16 @@ export class Navigator {
|
|
|
56
56
|
return navigator;
|
|
57
57
|
}
|
|
58
58
|
static async find(moduleName) {
|
|
59
|
-
const sceneId = await
|
|
59
|
+
const sceneId = await new Promise((resolve, reject) => {
|
|
60
|
+
NavigationModule.findSceneIdByModuleName(moduleName, (error, id) => {
|
|
61
|
+
if (error) {
|
|
62
|
+
reject(error);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
resolve(id);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
60
69
|
if (sceneId) {
|
|
61
70
|
return Navigator.of(sceneId);
|
|
62
71
|
}
|
|
@@ -65,11 +74,29 @@ export class Navigator {
|
|
|
65
74
|
const route = await Navigator.currentRoute();
|
|
66
75
|
return Navigator.of(route.sceneId);
|
|
67
76
|
}
|
|
68
|
-
static
|
|
69
|
-
return
|
|
77
|
+
static currentRoute() {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
NavigationModule.currentRoute((error, route) => {
|
|
80
|
+
if (error) {
|
|
81
|
+
reject(error);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
resolve(route);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
70
88
|
}
|
|
71
|
-
static
|
|
72
|
-
return
|
|
89
|
+
static routeGraph() {
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
NavigationModule.routeGraph((error, result) => {
|
|
92
|
+
if (error) {
|
|
93
|
+
reject(error);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
resolve(result);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
73
100
|
}
|
|
74
101
|
static setRoot(layout, sticky = false) {
|
|
75
102
|
const pureLayout = bindBarButtonItemClickEvent(layout, {
|
|
@@ -114,54 +141,47 @@ export class Navigator {
|
|
|
114
141
|
}
|
|
115
142
|
}
|
|
116
143
|
if (!intercepted) {
|
|
117
|
-
return
|
|
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
|
+
});
|
|
118
154
|
}
|
|
119
155
|
return false;
|
|
120
156
|
}
|
|
121
157
|
static setInterceptor(interceptFn) {
|
|
122
158
|
interceptor = interceptFn;
|
|
123
159
|
}
|
|
124
|
-
visibility = 'pending';
|
|
125
160
|
constructor(sceneId, moduleName) {
|
|
126
161
|
this.sceneId = sceneId;
|
|
127
162
|
this.moduleName = moduleName;
|
|
128
|
-
this.dispatch = this.dispatch.bind(this);
|
|
129
|
-
this.setParams = this.setParams.bind(this);
|
|
130
|
-
this.push = this.push.bind(this);
|
|
131
|
-
this.pop = this.pop.bind(this);
|
|
132
|
-
this.popTo = this.popTo.bind(this);
|
|
133
|
-
this.popToRoot = this.popToRoot.bind(this);
|
|
134
|
-
this.redirectTo = this.redirectTo.bind(this);
|
|
135
|
-
this.isStackRoot = this.isStackRoot.bind(this);
|
|
136
|
-
this.present = this.present.bind(this);
|
|
137
|
-
this.dismiss = this.dismiss.bind(this);
|
|
138
|
-
this.showModal = this.showModal.bind(this);
|
|
139
|
-
this.hideModal = this.hideModal.bind(this);
|
|
140
|
-
this.setResult = this.setResult.bind(this);
|
|
141
|
-
this.toggleMenu = this.toggleMenu.bind(this);
|
|
142
|
-
this.openMenu = this.openMenu.bind(this);
|
|
143
|
-
this.closeMenu = this.closeMenu.bind(this);
|
|
144
163
|
}
|
|
164
|
+
visibility = 'pending';
|
|
145
165
|
state = {
|
|
146
166
|
params: {},
|
|
147
167
|
};
|
|
148
|
-
setParams(params) {
|
|
168
|
+
setParams = (params) => {
|
|
149
169
|
this.state.params = { ...this.state.params, ...params };
|
|
150
|
-
}
|
|
151
|
-
dispatch(action, params = {}) {
|
|
170
|
+
};
|
|
171
|
+
dispatch = (action, params = {}) => {
|
|
152
172
|
return Navigator.dispatch(this.sceneId, action, {
|
|
153
173
|
from: this.moduleName,
|
|
154
174
|
to: params.moduleName,
|
|
155
175
|
...params,
|
|
156
176
|
});
|
|
157
|
-
}
|
|
158
|
-
result(resultCode, data) {
|
|
177
|
+
};
|
|
178
|
+
result = (resultCode, data) => {
|
|
159
179
|
if (this.resultListener) {
|
|
160
180
|
this.resultListener(resultCode, data);
|
|
161
181
|
this.resultListener = null;
|
|
162
182
|
}
|
|
163
|
-
}
|
|
164
|
-
unmount() {
|
|
183
|
+
};
|
|
184
|
+
unmount = () => {
|
|
165
185
|
const codes = [];
|
|
166
186
|
for (const [requestCode, listener] of resultListeners) {
|
|
167
187
|
if (listener.sceneId === this.sceneId) {
|
|
@@ -174,7 +194,7 @@ export class Navigator {
|
|
|
174
194
|
this.resultListener.cancel();
|
|
175
195
|
this.resultListener = null;
|
|
176
196
|
}
|
|
177
|
-
}
|
|
197
|
+
};
|
|
178
198
|
_garden;
|
|
179
199
|
get garden() {
|
|
180
200
|
if (!this._garden) {
|
|
@@ -207,34 +227,48 @@ export class Navigator {
|
|
|
207
227
|
}
|
|
208
228
|
});
|
|
209
229
|
}
|
|
210
|
-
async
|
|
230
|
+
push = async (moduleName, props = {}, options = {}) => {
|
|
211
231
|
const success = await this.dispatch('push', { moduleName, props, options });
|
|
232
|
+
console.log('push', success);
|
|
212
233
|
return await this.waitResult(0, success);
|
|
213
|
-
}
|
|
214
|
-
async
|
|
234
|
+
};
|
|
235
|
+
pushLayout = async (layout) => {
|
|
215
236
|
const success = await this.dispatch('pushLayout', { layout });
|
|
216
237
|
return await this.waitResult(0, success);
|
|
217
|
-
}
|
|
218
|
-
pop() {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
238
|
+
};
|
|
239
|
+
pop = async () => {
|
|
240
|
+
const success = await this.dispatch('pop');
|
|
241
|
+
console.log('pop', success);
|
|
242
|
+
return success;
|
|
243
|
+
};
|
|
244
|
+
popTo = (moduleName, inclusive = false) => {
|
|
222
245
|
return this.dispatch('popTo', { moduleName, inclusive });
|
|
223
|
-
}
|
|
224
|
-
popToRoot() {
|
|
246
|
+
};
|
|
247
|
+
popToRoot = () => {
|
|
225
248
|
return this.dispatch('popToRoot');
|
|
226
|
-
}
|
|
227
|
-
redirectTo(moduleName, props = {}, options = {}) {
|
|
228
|
-
|
|
249
|
+
};
|
|
250
|
+
redirectTo = async (moduleName, props = {}, options = {}) => {
|
|
251
|
+
const success = await this.dispatch('redirectTo', {
|
|
229
252
|
moduleName,
|
|
230
253
|
props,
|
|
231
254
|
options,
|
|
232
255
|
});
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
+
};
|
|
271
|
+
present = async (moduleName, props = {}, options = {}) => {
|
|
238
272
|
const requestCode = --tag;
|
|
239
273
|
const success = await this.dispatch('present', {
|
|
240
274
|
moduleName,
|
|
@@ -243,16 +277,16 @@ export class Navigator {
|
|
|
243
277
|
requestCode,
|
|
244
278
|
});
|
|
245
279
|
return await this.waitResult(requestCode, success);
|
|
246
|
-
}
|
|
247
|
-
async
|
|
280
|
+
};
|
|
281
|
+
presentLayout = async (layout) => {
|
|
248
282
|
const requestCode = --tag;
|
|
249
283
|
const success = await this.dispatch('presentLayout', { layout, requestCode });
|
|
250
284
|
return await this.waitResult(requestCode, success);
|
|
251
|
-
}
|
|
252
|
-
dismiss() {
|
|
285
|
+
};
|
|
286
|
+
dismiss = () => {
|
|
253
287
|
return this.dispatch('dismiss');
|
|
254
|
-
}
|
|
255
|
-
async
|
|
288
|
+
};
|
|
289
|
+
showModal = async (moduleName, props = {}, options = {}) => {
|
|
256
290
|
const requestCode = --tag;
|
|
257
291
|
const success = await this.dispatch('showModal', {
|
|
258
292
|
moduleName,
|
|
@@ -261,32 +295,41 @@ export class Navigator {
|
|
|
261
295
|
requestCode,
|
|
262
296
|
});
|
|
263
297
|
return await this.waitResult(requestCode, success);
|
|
264
|
-
}
|
|
265
|
-
async
|
|
298
|
+
};
|
|
299
|
+
showModalLayout = async (layout) => {
|
|
266
300
|
const requestCode = --tag;
|
|
267
301
|
const success = await this.dispatch('showModalLayout', { layout, requestCode });
|
|
268
302
|
return await this.waitResult(requestCode, success);
|
|
269
|
-
}
|
|
270
|
-
hideModal() {
|
|
303
|
+
};
|
|
304
|
+
hideModal = () => {
|
|
271
305
|
return this.dispatch('hideModal');
|
|
272
|
-
}
|
|
273
|
-
setResult(resultCode, data = null) {
|
|
306
|
+
};
|
|
307
|
+
setResult = (resultCode, data = null) => {
|
|
274
308
|
NavigationModule.setResult(this.sceneId, resultCode, data);
|
|
275
|
-
}
|
|
276
|
-
async
|
|
277
|
-
const from = await
|
|
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
|
+
});
|
|
320
|
+
});
|
|
278
321
|
return this.dispatch('switchTab', { from, to: index, popToRoot });
|
|
279
|
-
}
|
|
280
|
-
toggleMenu() {
|
|
322
|
+
};
|
|
323
|
+
toggleMenu = () => {
|
|
281
324
|
return this.dispatch('toggleMenu');
|
|
282
|
-
}
|
|
283
|
-
openMenu() {
|
|
325
|
+
};
|
|
326
|
+
openMenu = () => {
|
|
284
327
|
return this.dispatch('openMenu');
|
|
285
|
-
}
|
|
286
|
-
closeMenu() {
|
|
328
|
+
};
|
|
329
|
+
closeMenu = () => {
|
|
287
330
|
return this.dispatch('closeMenu');
|
|
288
|
-
}
|
|
289
|
-
signalFirstRenderComplete() {
|
|
331
|
+
};
|
|
332
|
+
signalFirstRenderComplete = () => {
|
|
290
333
|
NavigationModule.signalFirstRenderComplete(this.sceneId);
|
|
291
|
-
}
|
|
334
|
+
};
|
|
292
335
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
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.
|
|
4
|
+
"version": "2.13.0-beta.1",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|
|
@@ -32,9 +32,8 @@
|
|
|
32
32
|
"build": "rm -rf ./lib && tsc -p tsconfig.build.json",
|
|
33
33
|
"prepare": "npm run build",
|
|
34
34
|
"start": "react-native start --reset-cache",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"run:android": "cd example/android && ./gradlew installDebug && npm run start:android",
|
|
35
|
+
"android": "react-native run-android",
|
|
36
|
+
"ios": "react-native run-ios",
|
|
38
37
|
"test": "jest",
|
|
39
38
|
"tsc": "tsc",
|
|
40
39
|
"lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx",
|
|
@@ -64,14 +63,13 @@
|
|
|
64
63
|
"react": "17.0.2",
|
|
65
64
|
"react-native": "^0.67.4",
|
|
66
65
|
"react-native-fast-image": "^8.5.11",
|
|
67
|
-
"react-native-iphone-x-helper": "^1.2.0",
|
|
68
66
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
69
67
|
"react-native-toast-hybrid": "^2.5.0",
|
|
70
68
|
"react-redux": "^7.2.5",
|
|
71
69
|
"react-test-renderer": "17.0.2",
|
|
72
70
|
"redux": "^4.1.1",
|
|
73
71
|
"typescript": "^4.6.4",
|
|
74
|
-
"vuepress": "^2.0.0-beta.
|
|
72
|
+
"vuepress": "^2.0.0-beta.49",
|
|
75
73
|
"zustand": "^3.7.1"
|
|
76
74
|
}
|
|
77
75
|
}
|
package/src/Garden.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native'
|
|
1
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native'
|
|
2
2
|
import { bindBarButtonItemClickEvent } from './utils'
|
|
3
3
|
import { NavigationOption, ImageSource, Color, BarStyle, TitleAlignment, BarButtonItem, TitleItem } from './typing'
|
|
4
4
|
|
|
@@ -77,11 +77,25 @@ type Nullable<T> = {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const GardenModule = NativeModules.GardenModule
|
|
80
|
+
const { STATUSBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE, TOOLBAR_HEIGHT } = GardenModule.getConstants()
|
|
81
|
+
|
|
82
|
+
if (Platform.OS === 'ios') {
|
|
83
|
+
const GardenEventEmitter: NativeEventEmitter = new NativeEventEmitter(GardenModule)
|
|
84
|
+
GardenEventEmitter.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
85
|
+
Garden.statusBarHeight = statusBarHeight
|
|
86
|
+
Garden.topBarHeight = statusBarHeight + TOOLBAR_HEIGHT
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
80
90
|
export class Garden {
|
|
81
91
|
static setStyle(style: Style = {}) {
|
|
82
92
|
GardenModule.setStyle(style)
|
|
83
93
|
}
|
|
84
94
|
|
|
95
|
+
static statusBarHeight: number = STATUSBAR_HEIGHT
|
|
96
|
+
static toolbarHeight: number = TOOLBAR_HEIGHT
|
|
97
|
+
static topBarHeight: number = TOOLBAR_HEIGHT + STATUSBAR_HEIGHT
|
|
98
|
+
|
|
85
99
|
constructor(public sceneId: string) {}
|
|
86
100
|
|
|
87
101
|
// --------------- instance method --------------
|
package/src/NavigationModule.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter } from 'react-native'
|
|
2
2
|
|
|
3
3
|
const NavigationModule = NativeModules.NavigationModule
|
|
4
|
-
const GardenModule = NativeModules.GardenModule
|
|
5
4
|
const HBDEventEmitter = NativeModules.HBDEventEmitter
|
|
6
5
|
|
|
7
6
|
const EventEmitter: NativeEventEmitter = new NativeEventEmitter(HBDEventEmitter)
|
|
@@ -27,7 +26,4 @@ export const KEY_ACTION: string = HBDEventEmitter.KEY_ACTION
|
|
|
27
26
|
export const RESULT_OK: number = NavigationModule.RESULT_OK
|
|
28
27
|
export const RESULT_CANCEL: number = NavigationModule.RESULT_CANCEL
|
|
29
28
|
|
|
30
|
-
export const toolbarHeight: number = GardenModule.TOOLBAR_HEIGHT
|
|
31
|
-
export const TOOLBAR_HEIGHT: number = GardenModule.TOOLBAR_HEIGHT
|
|
32
|
-
|
|
33
29
|
export { EventEmitter, NavigationModule }
|