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/src/Navigator.ts
CHANGED
|
@@ -109,7 +109,16 @@ export class Navigator {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
static async find(moduleName: string) {
|
|
112
|
-
const sceneId = await
|
|
112
|
+
const sceneId = await new Promise<string>((resolve, reject) => {
|
|
113
|
+
NavigationModule.findSceneIdByModuleName(moduleName, (error: never, id: string) => {
|
|
114
|
+
if (error) {
|
|
115
|
+
reject(error)
|
|
116
|
+
} else {
|
|
117
|
+
resolve(id)
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
113
122
|
if (sceneId) {
|
|
114
123
|
return Navigator.of(sceneId)
|
|
115
124
|
}
|
|
@@ -120,12 +129,28 @@ export class Navigator {
|
|
|
120
129
|
return Navigator.of(route.sceneId)
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
static
|
|
124
|
-
return
|
|
132
|
+
static currentRoute(): Promise<Route> {
|
|
133
|
+
return new Promise<Route>((resolve, reject) => {
|
|
134
|
+
NavigationModule.currentRoute((error: never, route: Route) => {
|
|
135
|
+
if (error) {
|
|
136
|
+
reject(error)
|
|
137
|
+
} else {
|
|
138
|
+
resolve(route)
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
})
|
|
125
142
|
}
|
|
126
143
|
|
|
127
|
-
static
|
|
128
|
-
return
|
|
144
|
+
static routeGraph(): Promise<RouteGraph[]> {
|
|
145
|
+
return new Promise<RouteGraph[]>((resolve, reject) => {
|
|
146
|
+
NavigationModule.routeGraph((error: never, result: RouteGraph[]) => {
|
|
147
|
+
if (error) {
|
|
148
|
+
reject(error)
|
|
149
|
+
} else {
|
|
150
|
+
resolve(result)
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
})
|
|
129
154
|
}
|
|
130
155
|
|
|
131
156
|
static setRoot(layout: BuildInLayout | Layout, sticky = false) {
|
|
@@ -175,7 +200,15 @@ export class Navigator {
|
|
|
175
200
|
}
|
|
176
201
|
|
|
177
202
|
if (!intercepted) {
|
|
178
|
-
return
|
|
203
|
+
return new Promise<boolean>((resolve, reject) => {
|
|
204
|
+
NavigationModule.dispatch(sceneId, action, params, (error: never, result: boolean) => {
|
|
205
|
+
if (error) {
|
|
206
|
+
reject(error)
|
|
207
|
+
} else {
|
|
208
|
+
resolve(result)
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
})
|
|
179
212
|
}
|
|
180
213
|
|
|
181
214
|
return false
|
|
@@ -185,39 +218,19 @@ export class Navigator {
|
|
|
185
218
|
interceptor = interceptFn
|
|
186
219
|
}
|
|
187
220
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
constructor(public sceneId: string, public moduleName?: string) {
|
|
191
|
-
this.dispatch = this.dispatch.bind(this)
|
|
192
|
-
this.setParams = this.setParams.bind(this)
|
|
221
|
+
constructor(public sceneId: string, public moduleName?: string) {}
|
|
193
222
|
|
|
194
|
-
|
|
195
|
-
this.pop = this.pop.bind(this)
|
|
196
|
-
this.popTo = this.popTo.bind(this)
|
|
197
|
-
this.popToRoot = this.popToRoot.bind(this)
|
|
198
|
-
this.redirectTo = this.redirectTo.bind(this)
|
|
199
|
-
this.isStackRoot = this.isStackRoot.bind(this)
|
|
200
|
-
|
|
201
|
-
this.present = this.present.bind(this)
|
|
202
|
-
this.dismiss = this.dismiss.bind(this)
|
|
203
|
-
this.showModal = this.showModal.bind(this)
|
|
204
|
-
this.hideModal = this.hideModal.bind(this)
|
|
205
|
-
this.setResult = this.setResult.bind(this)
|
|
206
|
-
|
|
207
|
-
this.toggleMenu = this.toggleMenu.bind(this)
|
|
208
|
-
this.openMenu = this.openMenu.bind(this)
|
|
209
|
-
this.closeMenu = this.closeMenu.bind(this)
|
|
210
|
-
}
|
|
223
|
+
visibility: Visibility = 'pending'
|
|
211
224
|
|
|
212
225
|
readonly state: NavigationState = {
|
|
213
226
|
params: {},
|
|
214
227
|
}
|
|
215
228
|
|
|
216
|
-
setParams(params: { [index: string]: any }) {
|
|
229
|
+
setParams = (params: { [index: string]: any }) => {
|
|
217
230
|
this.state.params = { ...this.state.params, ...params }
|
|
218
231
|
}
|
|
219
232
|
|
|
220
|
-
dispatch(action: string, params: Params = {}) {
|
|
233
|
+
dispatch = (action: string, params: Params = {}) => {
|
|
221
234
|
return Navigator.dispatch(this.sceneId, action, {
|
|
222
235
|
from: this.moduleName,
|
|
223
236
|
to: params.moduleName,
|
|
@@ -225,14 +238,14 @@ export class Navigator {
|
|
|
225
238
|
})
|
|
226
239
|
}
|
|
227
240
|
|
|
228
|
-
result(resultCode: number, data: ResultType) {
|
|
241
|
+
result = (resultCode: number, data: ResultType) => {
|
|
229
242
|
if (this.resultListener) {
|
|
230
243
|
this.resultListener(resultCode, data)
|
|
231
244
|
this.resultListener = null
|
|
232
245
|
}
|
|
233
246
|
}
|
|
234
247
|
|
|
235
|
-
unmount() {
|
|
248
|
+
unmount = () => {
|
|
236
249
|
const codes: number[] = []
|
|
237
250
|
for (const [requestCode, listener] of resultListeners) {
|
|
238
251
|
if (listener.sceneId === this.sceneId) {
|
|
@@ -288,49 +301,66 @@ export class Navigator {
|
|
|
288
301
|
})
|
|
289
302
|
}
|
|
290
303
|
|
|
291
|
-
async
|
|
304
|
+
push = async <T extends ResultType, P extends PropsType = PropsType>(
|
|
292
305
|
moduleName: string,
|
|
293
306
|
props: P = {} as any,
|
|
294
307
|
options: NavigationItem = {},
|
|
295
|
-
) {
|
|
308
|
+
) => {
|
|
296
309
|
const success = await this.dispatch('push', { moduleName, props, options })
|
|
310
|
+
console.log('push', success)
|
|
297
311
|
return await this.waitResult<T>(0, success)
|
|
298
312
|
}
|
|
299
313
|
|
|
300
|
-
async
|
|
314
|
+
pushLayout = async <T extends ResultType>(layout: BuildInLayout | Layout) => {
|
|
301
315
|
const success = await this.dispatch('pushLayout', { layout })
|
|
302
316
|
return await this.waitResult<T>(0, success)
|
|
303
317
|
}
|
|
304
318
|
|
|
305
|
-
pop() {
|
|
306
|
-
|
|
319
|
+
pop = async () => {
|
|
320
|
+
const success = await this.dispatch('pop')
|
|
321
|
+
console.log('pop', success)
|
|
322
|
+
return success
|
|
307
323
|
}
|
|
308
324
|
|
|
309
|
-
popTo(moduleName: string, inclusive: boolean = false) {
|
|
325
|
+
popTo = (moduleName: string, inclusive: boolean = false) => {
|
|
310
326
|
return this.dispatch('popTo', { moduleName, inclusive })
|
|
311
327
|
}
|
|
312
328
|
|
|
313
|
-
popToRoot() {
|
|
329
|
+
popToRoot = () => {
|
|
314
330
|
return this.dispatch('popToRoot')
|
|
315
331
|
}
|
|
316
332
|
|
|
317
|
-
redirectTo<P extends PropsType = PropsType>(
|
|
318
|
-
|
|
333
|
+
redirectTo = async <P extends PropsType = PropsType>(
|
|
334
|
+
moduleName: string,
|
|
335
|
+
props: P = {} as any,
|
|
336
|
+
options: NavigationItem = {},
|
|
337
|
+
) => {
|
|
338
|
+
const success = await this.dispatch('redirectTo', {
|
|
319
339
|
moduleName,
|
|
320
340
|
props,
|
|
321
341
|
options,
|
|
322
342
|
})
|
|
343
|
+
console.log('redirectTo', success)
|
|
344
|
+
return success
|
|
323
345
|
}
|
|
324
346
|
|
|
325
|
-
isStackRoot()
|
|
326
|
-
return
|
|
347
|
+
isStackRoot = () => {
|
|
348
|
+
return new Promise<boolean>((resolve, reject) => {
|
|
349
|
+
NavigationModule.isStackRoot(this.sceneId, (error: never, result: boolean) => {
|
|
350
|
+
if (error) {
|
|
351
|
+
reject(error)
|
|
352
|
+
} else {
|
|
353
|
+
resolve(result)
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
})
|
|
327
357
|
}
|
|
328
358
|
|
|
329
|
-
async
|
|
359
|
+
present = async <T extends ResultType, P extends PropsType = PropsType>(
|
|
330
360
|
moduleName: string,
|
|
331
361
|
props: P = {} as any,
|
|
332
362
|
options: NavigationItem = {},
|
|
333
|
-
) {
|
|
363
|
+
) => {
|
|
334
364
|
const requestCode = --tag
|
|
335
365
|
const success = await this.dispatch('present', {
|
|
336
366
|
moduleName,
|
|
@@ -341,21 +371,21 @@ export class Navigator {
|
|
|
341
371
|
return await this.waitResult<T>(requestCode, success)
|
|
342
372
|
}
|
|
343
373
|
|
|
344
|
-
async
|
|
374
|
+
presentLayout = async <T extends ResultType>(layout: BuildInLayout | Layout) => {
|
|
345
375
|
const requestCode = --tag
|
|
346
376
|
const success = await this.dispatch('presentLayout', { layout, requestCode })
|
|
347
377
|
return await this.waitResult<T>(requestCode, success)
|
|
348
378
|
}
|
|
349
379
|
|
|
350
|
-
dismiss() {
|
|
380
|
+
dismiss = () => {
|
|
351
381
|
return this.dispatch('dismiss')
|
|
352
382
|
}
|
|
353
383
|
|
|
354
|
-
async
|
|
384
|
+
showModal = async <T extends ResultType, P extends PropsType = PropsType>(
|
|
355
385
|
moduleName: string,
|
|
356
386
|
props: P = {} as any,
|
|
357
387
|
options: NavigationItem = {},
|
|
358
|
-
) {
|
|
388
|
+
) => {
|
|
359
389
|
const requestCode = --tag
|
|
360
390
|
const success = await this.dispatch('showModal', {
|
|
361
391
|
moduleName,
|
|
@@ -366,38 +396,46 @@ export class Navigator {
|
|
|
366
396
|
return await this.waitResult<T>(requestCode, success)
|
|
367
397
|
}
|
|
368
398
|
|
|
369
|
-
async
|
|
399
|
+
showModalLayout = async <T extends ResultType>(layout: BuildInLayout | Layout) => {
|
|
370
400
|
const requestCode = --tag
|
|
371
401
|
const success = await this.dispatch('showModalLayout', { layout, requestCode })
|
|
372
402
|
return await this.waitResult<T>(requestCode, success)
|
|
373
403
|
}
|
|
374
404
|
|
|
375
|
-
hideModal() {
|
|
405
|
+
hideModal = () => {
|
|
376
406
|
return this.dispatch('hideModal')
|
|
377
407
|
}
|
|
378
408
|
|
|
379
|
-
setResult<T extends ResultType>(resultCode: number, data: T = null as any): void {
|
|
409
|
+
setResult = <T extends ResultType>(resultCode: number, data: T = null as any): void => {
|
|
380
410
|
NavigationModule.setResult(this.sceneId, resultCode, data)
|
|
381
411
|
}
|
|
382
412
|
|
|
383
|
-
async
|
|
384
|
-
const from = await
|
|
413
|
+
switchTab = async (index: number, popToRoot: boolean = false) => {
|
|
414
|
+
const from = await new Promise<number>((resolve, reject) => {
|
|
415
|
+
NavigationModule.currentTab(this.sceneId, (error: never, result: number) => {
|
|
416
|
+
if (error) {
|
|
417
|
+
reject(error)
|
|
418
|
+
} else {
|
|
419
|
+
resolve(result)
|
|
420
|
+
}
|
|
421
|
+
})
|
|
422
|
+
})
|
|
385
423
|
return this.dispatch('switchTab', { from, to: index, popToRoot })
|
|
386
424
|
}
|
|
387
425
|
|
|
388
|
-
toggleMenu() {
|
|
426
|
+
toggleMenu = () => {
|
|
389
427
|
return this.dispatch('toggleMenu')
|
|
390
428
|
}
|
|
391
429
|
|
|
392
|
-
openMenu() {
|
|
430
|
+
openMenu = () => {
|
|
393
431
|
return this.dispatch('openMenu')
|
|
394
432
|
}
|
|
395
433
|
|
|
396
|
-
closeMenu() {
|
|
434
|
+
closeMenu = () => {
|
|
397
435
|
return this.dispatch('closeMenu')
|
|
398
436
|
}
|
|
399
437
|
|
|
400
|
-
signalFirstRenderComplete()
|
|
438
|
+
signalFirstRenderComplete = () => {
|
|
401
439
|
NavigationModule.signalFirstRenderComplete(this.sceneId)
|
|
402
440
|
}
|
|
403
441
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDGardenModule.h
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/26.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
#import <React/RCTBridgeModule.h>
|
|
11
|
-
|
|
12
|
-
@interface HBDGardenModule : NSObject <RCTBridgeModule>
|
|
13
|
-
|
|
14
|
-
@end
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDGardenModule.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/26.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import "HBDGardenModule.h"
|
|
10
|
-
#import "HBDReactBridgeManager.h"
|
|
11
|
-
#import "HBDTabBarController.h"
|
|
12
|
-
#import "GlobalStyle.h"
|
|
13
|
-
#import <React/RCTLog.h>
|
|
14
|
-
|
|
15
|
-
@interface HBDGardenModule ()
|
|
16
|
-
|
|
17
|
-
@property(nonatomic, strong, readonly) HBDReactBridgeManager *bridgeManager;
|
|
18
|
-
|
|
19
|
-
@end
|
|
20
|
-
|
|
21
|
-
@implementation HBDGardenModule
|
|
22
|
-
|
|
23
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
24
|
-
return YES;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
RCT_EXPORT_MODULE(GardenModule)
|
|
28
|
-
|
|
29
|
-
- (instancetype)init {
|
|
30
|
-
if (self = [super init]) {
|
|
31
|
-
_bridgeManager = [HBDReactBridgeManager get];
|
|
32
|
-
}
|
|
33
|
-
return self;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
- (dispatch_queue_t)methodQueue {
|
|
37
|
-
return dispatch_get_main_queue();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
- (NSDictionary *)constantsToExport {
|
|
41
|
-
return @{@"TOOLBAR_HEIGHT": @(44)};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
RCT_EXPORT_METHOD(setStyle:
|
|
45
|
-
(NSDictionary *) style) {
|
|
46
|
-
[GlobalStyle createWithOptions:style];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
RCT_EXPORT_METHOD(setTitleItem:
|
|
50
|
-
(NSString *) sceneId item:
|
|
51
|
-
(NSDictionary *) item) {
|
|
52
|
-
HBDViewController *vc = [self HBDViewControllerForSceneId:sceneId];
|
|
53
|
-
if (vc) {
|
|
54
|
-
[vc updateNavigationBarOptions:@{@"titleItem": RCTNullIfNil(item)}];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
RCT_EXPORT_METHOD(setLeftBarButtonItem:
|
|
59
|
-
(NSString *) sceneId item:
|
|
60
|
-
(NSDictionary *__nullable) item) {
|
|
61
|
-
HBDViewController *vc = [self HBDViewControllerForSceneId:sceneId];
|
|
62
|
-
if (vc) {
|
|
63
|
-
[vc updateNavigationBarOptions:@{@"leftBarButtonItem": RCTNullIfNil(item)}];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
RCT_EXPORT_METHOD(setRightBarButtonItem:
|
|
68
|
-
(NSString *) sceneId item:
|
|
69
|
-
(NSDictionary *__nullable) item) {
|
|
70
|
-
HBDViewController *vc = [self HBDViewControllerForSceneId:sceneId];
|
|
71
|
-
if (vc) {
|
|
72
|
-
[vc updateNavigationBarOptions:@{@"rightBarButtonItem": RCTNullIfNil(item)}];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
RCT_EXPORT_METHOD(setLeftBarButtonItems:
|
|
77
|
-
(NSString *) sceneId item:
|
|
78
|
-
(NSArray *__nullable) items) {
|
|
79
|
-
HBDViewController *vc = [self HBDViewControllerForSceneId:sceneId];
|
|
80
|
-
if (vc) {
|
|
81
|
-
[vc updateNavigationBarOptions:@{@"leftBarButtonItems": RCTNullIfNil(items)}];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
RCT_EXPORT_METHOD(setRightBarButtonItems:
|
|
86
|
-
(NSString *) sceneId item:
|
|
87
|
-
(NSArray *__nullable) items) {
|
|
88
|
-
HBDViewController *vc = [self HBDViewControllerForSceneId:sceneId];
|
|
89
|
-
if (vc) {
|
|
90
|
-
[vc updateNavigationBarOptions:@{@"rightBarButtonItems": RCTNullIfNil(items)}];
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
RCT_EXPORT_METHOD(updateOptions:
|
|
95
|
-
(NSString *) sceneId item:
|
|
96
|
-
(NSDictionary *) options) {
|
|
97
|
-
RCTLogInfo(@"[Navigator] updateNavigationBarOptions: %@", options);
|
|
98
|
-
HBDViewController *vc = [self HBDViewControllerForSceneId:sceneId];
|
|
99
|
-
if (vc) {
|
|
100
|
-
[vc updateNavigationBarOptions:options];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
RCT_EXPORT_METHOD(updateTabBar:
|
|
105
|
-
(NSString *) sceneId item:
|
|
106
|
-
(NSDictionary *) item) {
|
|
107
|
-
RCTLogInfo(@"[Navigator] updateTabBar: %@", item);
|
|
108
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
109
|
-
UITabBarController *tabBarVC = [self tabBarControllerWithViewController:vc];
|
|
110
|
-
if (tabBarVC && [tabBarVC isKindOfClass:[HBDTabBarController class]]) {
|
|
111
|
-
[((HBDTabBarController *) tabBarVC) updateTabBar:item];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
RCT_EXPORT_METHOD(setTabItem:
|
|
116
|
-
(NSString *) sceneId options:
|
|
117
|
-
(NSArray<NSDictionary *> *) options) {
|
|
118
|
-
RCTLogInfo(@"[Navigator] setTabItem: %@", options);
|
|
119
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
120
|
-
UITabBarController *tabBarController = [self tabBarControllerWithViewController:vc];
|
|
121
|
-
if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
|
|
122
|
-
HBDTabBarController *tabBarVC = (HBDTabBarController *) tabBarController;
|
|
123
|
-
[tabBarVC setTabItem:options];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
RCT_EXPORT_METHOD(setMenuInteractive:
|
|
128
|
-
(NSString *) sceneId enabled:
|
|
129
|
-
(BOOL) enabled) {
|
|
130
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
131
|
-
HBDDrawerController *drawer = [vc drawerController];
|
|
132
|
-
if (drawer) {
|
|
133
|
-
drawer.menuInteractive = enabled;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
- (HBDViewController *)HBDViewControllerForSceneId:(NSString *)sceneId {
|
|
138
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
139
|
-
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
140
|
-
return (HBDViewController *) vc;
|
|
141
|
-
}
|
|
142
|
-
return nil;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
- (UITabBarController *)tabBarControllerWithViewController:(UIViewController *)vc {
|
|
146
|
-
UITabBarController *tabBarController;
|
|
147
|
-
if ([vc isKindOfClass:[UITabBarController class]]) {
|
|
148
|
-
tabBarController = (UITabBarController *) vc;
|
|
149
|
-
} else {
|
|
150
|
-
tabBarController = vc.tabBarController;
|
|
151
|
-
}
|
|
152
|
-
return tabBarController;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
@end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDNavigatorModule.h
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/19.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
#import <React/RCTBridgeModule.h>
|
|
11
|
-
|
|
12
|
-
@interface HBDNavigationModule : NSObject <RCTBridgeModule>
|
|
13
|
-
|
|
14
|
-
@end
|
|
15
|
-
|