hybrid-navigation 2.12.4 → 2.13.0-beta.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/README.md +63 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +2 -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 +5 -0
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +128 -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 +3 -12
- package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -8
- package/ios/HybridNavigation/View/HBDReactTabBar.m +1 -8
- package/ios/HybridNavigation/View/HBDRootView.h +0 -9
- package/ios/HybridNavigation/View/HBDRootView.m +0 -8
- 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 +59 -26
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +12 -9
- 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/Navigator.d.ts +25 -25
- package/lib/Navigator.js +116 -73
- package/package.json +4 -5
- package/src/Navigator.ts +96 -58
- 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
|
@@ -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
|
-
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDNavigatorModule.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/19.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import "HBDNavigationModule.h"
|
|
10
|
-
#import <React/RCTLog.h>
|
|
11
|
-
#import "HBDReactBridgeManager.h"
|
|
12
|
-
#import "HBDReactViewController.h"
|
|
13
|
-
|
|
14
|
-
@interface Promise : NSObject
|
|
15
|
-
|
|
16
|
-
@property(nonatomic, copy) RCTPromiseResolveBlock resolve;
|
|
17
|
-
@property(nonatomic, copy) RCTPromiseRejectBlock reject;
|
|
18
|
-
|
|
19
|
-
@end
|
|
20
|
-
|
|
21
|
-
@implementation Promise
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- (instancetype)initWithResolver:(RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter {
|
|
25
|
-
if (self = [super init]) {
|
|
26
|
-
_resolve = resolver;
|
|
27
|
-
_reject = rejecter;
|
|
28
|
-
}
|
|
29
|
-
return self;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@end
|
|
33
|
-
|
|
34
|
-
@interface HBDNavigationModule ()
|
|
35
|
-
|
|
36
|
-
@property(nonatomic, strong, readonly) HBDReactBridgeManager *bridgeManager;
|
|
37
|
-
|
|
38
|
-
@end
|
|
39
|
-
|
|
40
|
-
@implementation HBDNavigationModule
|
|
41
|
-
|
|
42
|
-
@synthesize bridge = _bridge;
|
|
43
|
-
|
|
44
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
45
|
-
return YES;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
RCT_EXPORT_MODULE(NavigationModule)
|
|
49
|
-
|
|
50
|
-
- (instancetype)init {
|
|
51
|
-
if (self = [super init]) {
|
|
52
|
-
_bridgeManager = [HBDReactBridgeManager get];
|
|
53
|
-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleReload) name:RCTBridgeWillReloadNotification object:nil];
|
|
54
|
-
}
|
|
55
|
-
return self;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
- (void)dealloc {
|
|
59
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillReloadNotification object:nil];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
- (void)handleReload {
|
|
63
|
-
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
- (dispatch_queue_t)methodQueue {
|
|
67
|
-
return dispatch_get_main_queue();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
- (NSDictionary *)constantsToExport {
|
|
71
|
-
return @{@"RESULT_OK": @(ResultOK),
|
|
72
|
-
@"RESULT_CANCEL": @(ResultCancel)
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
RCT_EXPORT_METHOD(startRegisterReactComponent) {
|
|
77
|
-
[self.bridgeManager startRegisterReactModule];
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
RCT_EXPORT_METHOD(endRegisterReactComponent) {
|
|
81
|
-
[self.bridgeManager endRegisterReactModule];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
RCT_EXPORT_METHOD(registerReactComponent:
|
|
85
|
-
(NSString *) appKey options:
|
|
86
|
-
(NSDictionary *) options) {
|
|
87
|
-
[self.bridgeManager registerReactModule:appKey options:options];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
RCT_EXPORT_METHOD(signalFirstRenderComplete:
|
|
91
|
-
(NSString *) sceneId) {
|
|
92
|
-
// RCTLogInfo(@"[Navigator] signalFirstRenderComplete sceneId:%@", sceneId);
|
|
93
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
94
|
-
if ([vc isKindOfClass:[HBDReactViewController class]]) {
|
|
95
|
-
[(HBDReactViewController *) vc signalFirstRenderComplete];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
RCT_EXPORT_METHOD(setRoot:
|
|
100
|
-
(NSDictionary *) layout sticky:
|
|
101
|
-
(BOOL) sticky tag:
|
|
102
|
-
(NSNumber *__nonnull) tag) {
|
|
103
|
-
self.bridgeManager.viewHierarchyReady = NO;
|
|
104
|
-
UIViewController *vc = [self.bridgeManager controllerWithLayout:layout];
|
|
105
|
-
if (vc) {
|
|
106
|
-
self.bridgeManager.hasRootLayout = YES;
|
|
107
|
-
[self.bridgeManager setRootViewController:vc withTag:tag];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
RCT_EXPORT_METHOD(dispatch:
|
|
112
|
-
(NSString *) sceneId action:
|
|
113
|
-
(NSString *) action extras:
|
|
114
|
-
(NSDictionary *) extras resolver:
|
|
115
|
-
(RCTPromiseResolveBlock) resolve rejecter:
|
|
116
|
-
(RCTPromiseRejectBlock) reject) {
|
|
117
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
118
|
-
if (vc) {
|
|
119
|
-
[self.bridgeManager handleNavigationWithViewController:vc action:action extras:extras resolver:resolve rejecter:reject];
|
|
120
|
-
} else {
|
|
121
|
-
resolve(@(NO));
|
|
122
|
-
RCTLogWarn(@"[Navigator] Can't find target scene for action: %@, maybe the scene is gone. \nextras: %@", action, extras);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
RCT_EXPORT_METHOD(currentTab:
|
|
127
|
-
(NSString *) sceneId resolver:
|
|
128
|
-
(RCTPromiseResolveBlock) resolve rejecter:
|
|
129
|
-
(RCTPromiseRejectBlock) reject) {
|
|
130
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
131
|
-
UITabBarController *tabs = vc.tabBarController;
|
|
132
|
-
if (tabs) {
|
|
133
|
-
resolve(@(tabs.selectedIndex));
|
|
134
|
-
} else {
|
|
135
|
-
resolve(@(-1));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
RCT_EXPORT_METHOD(isStackRoot:
|
|
140
|
-
(NSString *) sceneId resolver:
|
|
141
|
-
(RCTPromiseResolveBlock) resolve rejecter:
|
|
142
|
-
(RCTPromiseRejectBlock) reject) {
|
|
143
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
144
|
-
UINavigationController *nav = vc.navigationController;
|
|
145
|
-
if (nav) {
|
|
146
|
-
NSArray *children = nav.childViewControllers;
|
|
147
|
-
if (children.count > 0) {
|
|
148
|
-
HBDReactViewController *reactViewController = children[0];
|
|
149
|
-
if ([reactViewController.sceneId isEqualToString:sceneId]) {
|
|
150
|
-
resolve(@YES);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
resolve(@NO);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
RCT_EXPORT_METHOD(setResult:
|
|
159
|
-
(NSString *) sceneId resultCode:
|
|
160
|
-
(NSInteger) resultCode data:
|
|
161
|
-
(NSDictionary *) data) {
|
|
162
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
163
|
-
[vc setResultCode:resultCode resultData:data];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
RCT_EXPORT_METHOD(findSceneIdByModuleName:
|
|
167
|
-
(NSString *) moduleName resolver:
|
|
168
|
-
(RCTPromiseResolveBlock) resolve rejecter:
|
|
169
|
-
(RCTPromiseRejectBlock) reject) {
|
|
170
|
-
Promise *promise = [[Promise alloc] initWithResolver:resolve rejecter:reject];
|
|
171
|
-
[self performSelector:@selector(findSceneIdWithParams:) withObject:@{
|
|
172
|
-
@"promise": promise,
|
|
173
|
-
@"moduleName": moduleName,
|
|
174
|
-
}];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
- (void)findSceneIdWithParams:(NSDictionary *)params {
|
|
178
|
-
if (!self.bridgeManager.isViewHierarchyReady) {
|
|
179
|
-
[self performSelector:@selector(findSceneIdWithParams:) withObject:params afterDelay:0.016];
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
|
|
184
|
-
NSString *sceneId = nil;
|
|
185
|
-
NSString *moduleName = params[@"moduleName"];
|
|
186
|
-
Promise *promise = params[@"promise"];
|
|
187
|
-
|
|
188
|
-
NSUInteger index = application.windows.count;
|
|
189
|
-
while (index > 0 && sceneId == nil) {
|
|
190
|
-
UIWindow *window = application.windows[index - 1];
|
|
191
|
-
sceneId = [self findSceneIdByModuleName:moduleName withViewController:window.rootViewController];
|
|
192
|
-
index--;
|
|
193
|
-
}
|
|
194
|
-
RCTLogInfo(@"[Navigator] The sceneId found by %@ : %@", moduleName, sceneId);
|
|
195
|
-
promise.resolve(RCTNullIfNil(sceneId));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
- (NSString *)findSceneIdByModuleName:(NSString *)moduleName withViewController:(UIViewController *)vc {
|
|
199
|
-
NSString *sceneId = nil;
|
|
200
|
-
|
|
201
|
-
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
202
|
-
HBDViewController *hbd = (HBDViewController *) vc;
|
|
203
|
-
if ([moduleName isEqualToString:hbd.moduleName]) {
|
|
204
|
-
sceneId = hbd.sceneId;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (sceneId == nil) {
|
|
209
|
-
if (vc.presentedViewController && !vc.presentedViewController.isBeingDismissed) {
|
|
210
|
-
sceneId = [self findSceneIdByModuleName:moduleName withViewController:vc.presentedViewController];
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (sceneId == nil) {
|
|
215
|
-
NSArray<UIViewController *> *children = vc.childViewControllers;
|
|
216
|
-
NSUInteger count = children.count;
|
|
217
|
-
if (count > 0) {
|
|
218
|
-
NSUInteger index = count;
|
|
219
|
-
while (index > 0 && sceneId == nil) {
|
|
220
|
-
UIViewController *child = children[index - 1];
|
|
221
|
-
sceneId = [self findSceneIdByModuleName:moduleName withViewController:child];
|
|
222
|
-
index--;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return sceneId;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
RCT_EXPORT_METHOD(currentRoute:
|
|
231
|
-
(RCTPromiseResolveBlock) resolve rejecter:
|
|
232
|
-
(RCTPromiseRejectBlock) reject) {
|
|
233
|
-
Promise *promise = [[Promise alloc] initWithResolver:resolve rejecter:reject];
|
|
234
|
-
[self performSelector:@selector(currentRouteWithPromise:) withObject:promise];
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
- (void)currentRouteWithPromise:(Promise *)promise {
|
|
238
|
-
if (!self.bridgeManager.isViewHierarchyReady) {
|
|
239
|
-
[self performSelector:@selector(currentRouteWithPromise:) withObject:promise afterDelay:0.016];
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
HBDViewController *current = [self.bridgeManager primaryViewController];
|
|
244
|
-
if (current) {
|
|
245
|
-
promise.resolve(@{@"moduleName": RCTNullIfNil(current.moduleName), @"sceneId": current.sceneId, @"mode": [current hbd_mode]});
|
|
246
|
-
} else {
|
|
247
|
-
[self performSelector:@selector(currentRouteWithPromise:) withObject:promise afterDelay:0.016];
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
RCT_EXPORT_METHOD(routeGraph:
|
|
252
|
-
(RCTPromiseResolveBlock) resolve rejecter:
|
|
253
|
-
(RCTPromiseRejectBlock) reject) {
|
|
254
|
-
Promise *promise = [[Promise alloc] initWithResolver:resolve rejecter:reject];
|
|
255
|
-
[self performSelector:@selector(routeGraphWithPromise:) withObject:promise];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
- (void)routeGraphWithPromise:(Promise *)promise {
|
|
259
|
-
if (!self.bridgeManager.isViewHierarchyReady) {
|
|
260
|
-
[self performSelector:@selector(routeGraphWithPromise:) withObject:promise afterDelay:0.016];
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
NSArray *root = [self.bridgeManager routeGraph];
|
|
265
|
-
if (root.count > 0) {
|
|
266
|
-
promise.resolve(root);
|
|
267
|
-
} else {
|
|
268
|
-
[self performSelector:@selector(routeGraphWithPromise:) withObject:promise afterDelay:0.016];
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
@end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDNavigator.h
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/6/28.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
#import "HBDViewController.h"
|
|
11
|
-
#import <React/RCTBridge.h>
|
|
12
|
-
|
|
13
|
-
@protocol HBDNavigator <NSObject>
|
|
14
|
-
|
|
15
|
-
@property(nonatomic, copy, readonly) NSString *name;
|
|
16
|
-
@property(nonatomic, copy, readonly) NSArray<NSString *> *supportActions;
|
|
17
|
-
|
|
18
|
-
- (UIViewController *)createViewControllerWithLayout:(NSDictionary *)layout;
|
|
19
|
-
|
|
20
|
-
- (NSDictionary *)buildRouteGraphWithViewController:(UIViewController *)vc;
|
|
21
|
-
|
|
22
|
-
- (HBDViewController *)primaryViewControllerWithViewController:(UIViewController *)vc;
|
|
23
|
-
|
|
24
|
-
- (void)handleNavigationWithViewController:(UIViewController *)target action:(NSString *)action extras:(NSDictionary *)extras resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
|
|
25
|
-
|
|
26
|
-
@end
|