hybrid-navigation 2.20.1 → 3.0.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/HybridNavigation.podspec +7 -5
- package/README.md +17 -0
- package/android/build.gradle +56 -19
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +320 -326
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +13 -20
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +6 -11
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +55 -21
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeEvent.java +31 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +223 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeNavigation.java +370 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +239 -224
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +177 -198
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactDrawerFragment.java +2 -9
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +41 -78
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +438 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +10 -19
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +7 -15
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +135 -173
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +54 -227
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +2 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +12 -14
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +18 -21
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +17 -20
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +13 -26
- package/dist/NativeEvent.d.ts +33 -0
- package/dist/NativeEvent.js +2 -0
- package/dist/NativeGarden.d.ts +18 -0
- package/dist/NativeGarden.js +2 -0
- package/dist/NativeNavigation.d.ts +47 -0
- package/dist/NativeNavigation.js +2 -0
- package/dist/Navigation.js +3 -3
- package/dist/NavigationModule.d.ts +3 -3
- package/dist/NavigationModule.js +18 -19
- package/dist/Navigator.js +1 -2
- package/dist/Options.d.ts +4 -7
- package/dist/Route.d.ts +0 -2
- package/dist/handler/BarButtonEventHandler.js +2 -2
- package/dist/handler/LayoutCommandHandler.js +3 -3
- package/dist/handler/ResultEventHandler.js +3 -3
- package/dist/handler/VisibilityEventHandler.js +11 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/ios/HybridNavigation/GlobalStyle.h +0 -6
- package/ios/HybridNavigation/{GlobalStyle.m → GlobalStyle.mm} +54 -44
- package/ios/HybridNavigation/HBDUtils.h +0 -4
- package/ios/HybridNavigation/{HBDUtils.m → HBDUtils.mm} +0 -41
- package/ios/HybridNavigation/Navigator/{HBDScreenNavigator.m → HBDScreenNavigator.mm} +3 -9
- package/ios/HybridNavigation/Navigator/{HBDStackNavigator.m → HBDStackNavigator.mm} +0 -4
- package/ios/HybridNavigation/Navigator/{HBDTabNavigator.m → HBDTabNavigator.mm} +1 -55
- package/ios/HybridNavigation/React/HBDNativeEvent.h +13 -0
- package/ios/HybridNavigation/React/HBDNativeEvent.mm +31 -0
- package/ios/HybridNavigation/React/HBDNativeGarden.h +10 -0
- package/ios/HybridNavigation/React/HBDNativeGarden.mm +151 -0
- package/ios/HybridNavigation/React/HBDNativeNavigation.h +11 -0
- package/ios/HybridNavigation/React/HBDNativeNavigation.mm +263 -0
- package/ios/HybridNavigation/{ReactBridge → React}/HBDReactBridgeManager.h +3 -1
- package/ios/HybridNavigation/{ReactBridge/HBDReactBridgeManager.m → React/HBDReactBridgeManager.mm} +7 -30
- package/ios/HybridNavigation/View/{HBDNavigationBar.m → HBDNavigationBar.mm} +8 -28
- package/ios/HybridNavigation/View/HBDRootView.h +2 -2
- package/ios/HybridNavigation/View/{HBDRootView.m → HBDRootView.mm} +2 -2
- package/ios/HybridNavigation/View/HBDTitleView.h +2 -2
- package/ios/HybridNavigation/View/{HBDTitleView.m → HBDTitleView.mm} +3 -3
- package/ios/HybridNavigation/View/UIImage+WithBadge.h +13 -0
- package/ios/HybridNavigation/View/UIImage+WithBadge.mm +36 -0
- package/ios/HybridNavigation/ViewController/{HBDDrawerController.m → HBDDrawerController.mm} +2 -25
- package/ios/HybridNavigation/ViewController/HBDReactViewController.h +0 -4
- package/ios/HybridNavigation/ViewController/{HBDReactViewController.m → HBDReactViewController.mm} +40 -31
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -2
- package/ios/HybridNavigation/ViewController/HBDTabBarController.mm +140 -0
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.h +0 -2
- package/ios/HybridNavigation/ViewController/{HBDViewController+Garden.m → HBDViewController+Garden.mm} +8 -26
- package/ios/HybridNavigation/ViewController/HBDViewController.h +2 -0
- package/ios/HybridNavigation/ViewController/{HBDViewController.m → HBDViewController.mm} +67 -57
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +0 -2
- package/ios/HybridNavigation/ViewController/{UIViewController+HBD.m → UIViewController+HBD.mm} +10 -44
- package/package.json +11 -2
- package/src/DeepLink.ts +3 -3
- package/src/NativeEvent.ts +40 -0
- package/src/NativeGarden.ts +27 -0
- package/src/NativeNavigation.ts +72 -0
- package/src/Navigation.ts +13 -13
- package/src/NavigationComponentWrap.tsx +4 -4
- package/src/NavigationModule.ts +21 -46
- package/src/Navigator.ts +13 -13
- package/src/Options.ts +9 -9
- package/src/Route.ts +0 -2
- package/src/handler/BarButtonEventHandler.ts +4 -8
- package/src/handler/DispatchCommandHandler.ts +4 -8
- package/src/handler/LayoutCommandHandler.ts +4 -5
- package/src/handler/ResultEventHandler.ts +11 -27
- package/src/handler/VisibilityEventHandler.ts +23 -32
- package/src/hooks.ts +2 -2
- package/src/index.ts +4 -5
- package/src/router/drawer.ts +5 -5
- package/src/router/index.ts +15 -15
- package/src/router/screen.ts +2 -2
- package/src/router/stack.ts +4 -4
- package/src/router/tabs.ts +3 -3
- package/src/store.ts +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/DefaultTabBarProvider.java +0 -143
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +0 -230
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDEventEmitter.java +0 -89
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +0 -71
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +0 -370
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +0 -445
- package/dist/Event.d.ts +0 -16
- package/dist/Event.js +0 -62
- package/dist/GardenModule.d.ts +0 -24
- package/dist/GardenModule.js +0 -21
- package/ios/HybridNavigation/HBDAnimationObserver.h +0 -24
- package/ios/HybridNavigation/HBDAnimationObserver.m +0 -45
- package/ios/HybridNavigation/ReactBridge/HBDEventEmitter.h +0 -28
- package/ios/HybridNavigation/ReactBridge/HBDEventEmitter.m +0 -72
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +0 -6
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +0 -157
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.h +0 -6
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +0 -249
- package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -9
- package/ios/HybridNavigation/View/HBDReactTabBar.m +0 -36
- package/ios/HybridNavigation/View/UITabBar+Badge.h +0 -9
- package/ios/HybridNavigation/View/UITabBar+Badge.m +0 -46
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +0 -265
- package/src/Event.ts +0 -117
- package/src/GardenModule.ts +0 -50
- /package/ios/HybridNavigation/Navigator/{HBDDrawerNavigator.m → HBDDrawerNavigator.mm} +0 -0
- /package/ios/HybridNavigation/Navigator/{HBDNavigatorRegistry.m → HBDNavigatorRegistry.mm} +0 -0
- /package/ios/HybridNavigation/{ReactBridge → React}/HBDNavigator.h +0 -0
- /package/ios/HybridNavigation/View/{HBDBackBarButtonItem.m → HBDBackBarButtonItem.mm} +0 -0
- /package/ios/HybridNavigation/View/{HBDBarButtonItem.m → HBDBarButtonItem.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDFadeAnimation.m → HBDFadeAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDNavigationController.m → HBDNavigationController.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDPopAnimation.m → HBDPopAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDPushAnimation.m → HBDPushAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{UINavigationController+HBD.m → UINavigationController+HBD.mm} +0 -0
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
#import "HBDEventEmitter.h"
|
|
2
|
-
|
|
3
|
-
#import "HBDReactBridgeManager.h"
|
|
4
|
-
|
|
5
|
-
#import <React/RCTBridgeModule.h>
|
|
6
|
-
|
|
7
|
-
NSString *const ON_COMPONENT_RESULT = @"ON_COMPONENT_RESULT";
|
|
8
|
-
NSString *const ON_BAR_BUTTON_ITEM_CLICK = @"ON_BAR_BUTTON_ITEM_CLICK";
|
|
9
|
-
NSString *const ON_COMPONENT_APPEAR = @"ON_COMPONENT_APPEAR";
|
|
10
|
-
NSString *const ON_COMPONENT_DISAPPEAR = @"ON_COMPONENT_DISAPPEAR";
|
|
11
|
-
|
|
12
|
-
NSString *const EVENT_SWITCH_TAB = @"EVENT_SWITCH_TAB";
|
|
13
|
-
NSString *const EVENT_NAVIGATION = @"EVENT_NAVIGATION";
|
|
14
|
-
NSString *const EVENT_DID_SET_ROOT = @"EVENT_DID_SET_ROOT";
|
|
15
|
-
NSString *const EVENT_WILL_SET_ROOT = @"EVENT_WILL_SET_ROOT";
|
|
16
|
-
|
|
17
|
-
NSString *const KEY_REQUEST_CODE = @"request_code";
|
|
18
|
-
NSString *const KEY_RESULT_CODE = @"result_code";
|
|
19
|
-
NSString *const KEY_RESULT_DATA = @"data";
|
|
20
|
-
NSString *const KEY_SCENE_ID = @"scene_id";
|
|
21
|
-
NSString *const KEY_MODULE_NAME = @"module_name";
|
|
22
|
-
NSString *const KEY_INDEX = @"index";
|
|
23
|
-
NSString *const KEY_ACTION = @"action";
|
|
24
|
-
NSString *const KEY_ON = @"on";
|
|
25
|
-
|
|
26
|
-
@implementation HBDEventEmitter
|
|
27
|
-
|
|
28
|
-
RCT_EXPORT_MODULE(HBDEventEmitter)
|
|
29
|
-
|
|
30
|
-
- (NSArray<NSString *> *)supportedEvents {
|
|
31
|
-
return @[EVENT_NAVIGATION, EVENT_SWITCH_TAB, EVENT_DID_SET_ROOT, EVENT_WILL_SET_ROOT];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
- (NSDictionary<NSString *, NSString *> *)constantsToExport {
|
|
35
|
-
return @{
|
|
36
|
-
@"EVENT_NAVIGATION": EVENT_NAVIGATION,
|
|
37
|
-
@"EVENT_SWITCH_TAB": EVENT_SWITCH_TAB,
|
|
38
|
-
@"EVENT_DID_SET_ROOT": EVENT_DID_SET_ROOT,
|
|
39
|
-
@"EVENT_WILL_SET_ROOT": EVENT_WILL_SET_ROOT,
|
|
40
|
-
@"ON_COMPONENT_RESULT": ON_COMPONENT_RESULT,
|
|
41
|
-
@"ON_BAR_BUTTON_ITEM_CLICK": ON_BAR_BUTTON_ITEM_CLICK,
|
|
42
|
-
@"ON_COMPONENT_APPEAR": ON_COMPONENT_APPEAR,
|
|
43
|
-
@"ON_COMPONENT_DISAPPEAR": ON_COMPONENT_DISAPPEAR,
|
|
44
|
-
@"KEY_REQUEST_CODE": KEY_REQUEST_CODE,
|
|
45
|
-
@"KEY_RESULT_CODE": KEY_RESULT_CODE,
|
|
46
|
-
@"KEY_RESULT_DATA": KEY_RESULT_DATA,
|
|
47
|
-
@"KEY_SCENE_ID": KEY_SCENE_ID,
|
|
48
|
-
@"KEY_MODULE_NAME": KEY_MODULE_NAME,
|
|
49
|
-
@"KEY_INDEX": KEY_INDEX,
|
|
50
|
-
@"KEY_ACTION": KEY_ACTION,
|
|
51
|
-
@"KEY_ON": KEY_ON,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
- (dispatch_queue_t)methodQueue {
|
|
56
|
-
return dispatch_get_main_queue();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
60
|
-
return YES;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
+ (void)sendEvent:(NSString *)eventName data:(NSDictionary *)data {
|
|
64
|
-
HBDReactBridgeManager *manager = [HBDReactBridgeManager get];
|
|
65
|
-
RCTBridge *bride = manager.bridge;
|
|
66
|
-
if (bride.valid && manager.isReactModuleRegisterCompleted) {
|
|
67
|
-
RCTEventEmitter *emitter = [bride moduleForName:@"HBDEventEmitter"];
|
|
68
|
-
[emitter sendEventWithName:eventName body:data];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@end
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
#import "HBDGardenModule.h"
|
|
2
|
-
|
|
3
|
-
#import "HBDReactBridgeManager.h"
|
|
4
|
-
#import "HBDTabBarController.h"
|
|
5
|
-
#import "GlobalStyle.h"
|
|
6
|
-
#import "HBDUtils.h"
|
|
7
|
-
|
|
8
|
-
#import <React/RCTLog.h>
|
|
9
|
-
|
|
10
|
-
static NSString *const EVENT_STATUSBAR_FRAME_CHANGE = @"EVENT_STATUSBAR_FRAME_CHANGE";
|
|
11
|
-
|
|
12
|
-
@interface HBDGardenModule ()
|
|
13
|
-
|
|
14
|
-
@property(nonatomic, strong, readonly) HBDReactBridgeManager *bridgeManager;
|
|
15
|
-
|
|
16
|
-
@end
|
|
17
|
-
|
|
18
|
-
@implementation HBDGardenModule
|
|
19
|
-
|
|
20
|
-
RCT_EXPORT_MODULE(GardenModule)
|
|
21
|
-
|
|
22
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
23
|
-
return YES;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
- (dispatch_queue_t)methodQueue {
|
|
27
|
-
return dispatch_get_main_queue();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
- (instancetype)init {
|
|
31
|
-
if (self = [super init]) {
|
|
32
|
-
_bridgeManager = [HBDReactBridgeManager get];
|
|
33
|
-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleStatusBarFrameChange) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
|
34
|
-
}
|
|
35
|
-
return self;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
- (void)dealloc {
|
|
39
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
- (NSDictionary *)constantsToExport {
|
|
43
|
-
return @{
|
|
44
|
-
@"TOOLBAR_HEIGHT": @(44),
|
|
45
|
-
@"STATUSBAR_HEIGHT": @([self currentStatusBarHeight]),
|
|
46
|
-
@"EVENT_STATUSBAR_FRAME_CHANGE": EVENT_STATUSBAR_FRAME_CHANGE,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
- (NSArray<NSString *> *)supportedEvents {
|
|
51
|
-
return @[EVENT_STATUSBAR_FRAME_CHANGE];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
- (CGFloat)currentStatusBarHeight {
|
|
55
|
-
return [HBDUtils statusBarHeight];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
- (void)handleStatusBarFrameChange {
|
|
59
|
-
RCTLogInfo(@"[Navigation] handleStatusBarFrameChange: %f", [self currentStatusBarHeight]);
|
|
60
|
-
if ([self.bridge isValid]) {
|
|
61
|
-
[self sendEventWithName:EVENT_STATUSBAR_FRAME_CHANGE body:@{
|
|
62
|
-
@"statusBarHeight": @([self currentStatusBarHeight])
|
|
63
|
-
}];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
RCT_EXPORT_METHOD(setStyle:(NSDictionary *) style) {
|
|
68
|
-
[GlobalStyle createWithOptions:style];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
RCT_EXPORT_METHOD(setTitleItem:(NSString *)sceneId item:(NSDictionary *)item) {
|
|
72
|
-
HBDViewController *vc = [self viewControllerWithSceneId:sceneId];
|
|
73
|
-
if (vc) {
|
|
74
|
-
[vc updateNavigationBarOptions:@{@"titleItem": RCTNullIfNil(item)}];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
RCT_EXPORT_METHOD(setLeftBarButtonItem:(NSString *)sceneId item:(NSDictionary *__nullable)item) {
|
|
79
|
-
HBDViewController *vc = [self viewControllerWithSceneId:sceneId];
|
|
80
|
-
if (vc) {
|
|
81
|
-
[vc updateNavigationBarOptions:@{@"leftBarButtonItem": RCTNullIfNil(item)}];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
RCT_EXPORT_METHOD(setRightBarButtonItem:(NSString *)sceneId item:(NSDictionary *__nullable)item) {
|
|
86
|
-
HBDViewController *vc = [self viewControllerWithSceneId:sceneId];
|
|
87
|
-
if (vc) {
|
|
88
|
-
[vc updateNavigationBarOptions:@{@"rightBarButtonItem": RCTNullIfNil(item)}];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
RCT_EXPORT_METHOD(setLeftBarButtonItems:(NSString *)sceneId item:(NSArray *__nullable)items) {
|
|
93
|
-
HBDViewController *vc = [self viewControllerWithSceneId:sceneId];
|
|
94
|
-
if (vc) {
|
|
95
|
-
[vc updateNavigationBarOptions:@{@"leftBarButtonItems": RCTNullIfNil(items)}];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
RCT_EXPORT_METHOD(setRightBarButtonItems:(NSString *)sceneId item:(NSArray *__nullable)items) {
|
|
100
|
-
HBDViewController *vc = [self viewControllerWithSceneId:sceneId];
|
|
101
|
-
if (vc) {
|
|
102
|
-
[vc updateNavigationBarOptions:@{@"rightBarButtonItems": RCTNullIfNil(items)}];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
RCT_EXPORT_METHOD(updateOptions:(NSString *)sceneId item:(NSDictionary *)options) {
|
|
107
|
-
RCTLogInfo(@"[Navigation] updateNavigationBarOptions: %@", options);
|
|
108
|
-
HBDViewController *vc = [self viewControllerWithSceneId:sceneId];
|
|
109
|
-
if (vc) {
|
|
110
|
-
[vc updateNavigationBarOptions:options];
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
RCT_EXPORT_METHOD(updateTabBar:(NSString *)sceneId item:(NSDictionary *)item) {
|
|
115
|
-
RCTLogInfo(@"[Navigation] updateTabBar: %@", item);
|
|
116
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
117
|
-
UITabBarController *tabBarVC = [self tabBarControllerWithViewController:vc];
|
|
118
|
-
if (tabBarVC && [tabBarVC isKindOfClass:[HBDTabBarController class]]) {
|
|
119
|
-
[((HBDTabBarController *)tabBarVC) updateTabBar:item];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
RCT_EXPORT_METHOD(setTabItem:(NSString *)sceneId options:(NSArray<NSDictionary *> *)options) {
|
|
124
|
-
RCTLogInfo(@"[Navigation] setTabItem: %@", options);
|
|
125
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
126
|
-
UITabBarController *tabBarController = [self tabBarControllerWithViewController:vc];
|
|
127
|
-
if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
|
|
128
|
-
HBDTabBarController *tabBarVC = (HBDTabBarController *)tabBarController;
|
|
129
|
-
[tabBarVC setTabItem:options];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
RCT_EXPORT_METHOD(setMenuInteractive:(NSString *)sceneId enabled:(BOOL)enabled) {
|
|
134
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
135
|
-
HBDDrawerController *drawer = [vc drawerController];
|
|
136
|
-
if (drawer) {
|
|
137
|
-
drawer.menuInteractive = enabled;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
- (HBDViewController *)viewControllerWithSceneId:(NSString *)sceneId {
|
|
142
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
143
|
-
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
144
|
-
return (HBDViewController *)vc;
|
|
145
|
-
}
|
|
146
|
-
return nil;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
- (UITabBarController *)tabBarControllerWithViewController:(UIViewController *)vc {
|
|
150
|
-
if ([vc isKindOfClass:[UITabBarController class]]) {
|
|
151
|
-
return (UITabBarController *)vc;
|
|
152
|
-
} else {
|
|
153
|
-
return vc.tabBarController;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@end
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
#import "HBDNavigationModule.h"
|
|
2
|
-
|
|
3
|
-
#import "HBDReactBridgeManager.h"
|
|
4
|
-
#import "HBDReactViewController.h"
|
|
5
|
-
#import "HBDAnimationObserver.h"
|
|
6
|
-
|
|
7
|
-
#import <React/RCTLog.h>
|
|
8
|
-
|
|
9
|
-
@interface HBDNavigationModule () <RCTInvalidating>
|
|
10
|
-
|
|
11
|
-
@property(nonatomic, strong, readonly) HBDReactBridgeManager *bridgeManager;
|
|
12
|
-
|
|
13
|
-
@end
|
|
14
|
-
|
|
15
|
-
@implementation HBDNavigationModule
|
|
16
|
-
|
|
17
|
-
+ (BOOL)requiresMainQueueSetup {
|
|
18
|
-
return YES;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
RCT_EXPORT_MODULE(NavigationModule)
|
|
22
|
-
|
|
23
|
-
- (instancetype)init {
|
|
24
|
-
if (self = [super init]) {
|
|
25
|
-
_bridgeManager = [HBDReactBridgeManager get];
|
|
26
|
-
}
|
|
27
|
-
return self;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
- (void)invalidate {
|
|
31
|
-
RCTLogInfo(@"[Navigation] NavigationModule#invalidate");
|
|
32
|
-
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
33
|
-
[[HBDAnimationObserver sharedObserver] invalidate];
|
|
34
|
-
[self.bridgeManager invalidate];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
- (dispatch_queue_t)methodQueue {
|
|
38
|
-
return dispatch_get_main_queue();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
- (NSDictionary *)constantsToExport {
|
|
42
|
-
return @{
|
|
43
|
-
@"RESULT_OK": @(ResultOK),
|
|
44
|
-
@"RESULT_CANCEL": @(ResultCancel),
|
|
45
|
-
@"RESULT_BLOCK": @(ResultBlock)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
RCT_EXPORT_METHOD(startRegisterReactComponent) {
|
|
50
|
-
[self.bridgeManager startRegisterReactModule];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
RCT_EXPORT_METHOD(endRegisterReactComponent) {
|
|
54
|
-
[self.bridgeManager endRegisterReactModule];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
RCT_EXPORT_METHOD(registerReactComponent:(NSString *)appKey options:(NSDictionary *)options) {
|
|
58
|
-
[self.bridgeManager registerReactModule:appKey options:options];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
RCT_EXPORT_METHOD(signalFirstRenderComplete:(NSString *) sceneId) {
|
|
62
|
-
// RCTLogInfo(@"[Navigation] signalFirstRenderComplete sceneId:%@", sceneId);
|
|
63
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
64
|
-
if ([vc isKindOfClass:[HBDReactViewController class]]) {
|
|
65
|
-
[(HBDReactViewController *)vc signalFirstRenderComplete];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
RCT_EXPORT_METHOD(setRoot:(NSDictionary *)layout sticky:(BOOL)sticky callback:(RCTResponseSenderBlock)callback) {
|
|
70
|
-
self.bridgeManager.viewHierarchyReady = NO;
|
|
71
|
-
UIViewController *vc = [self.bridgeManager viewControllerWithLayout:layout];
|
|
72
|
-
if (!vc) {
|
|
73
|
-
@throw [[NSException alloc] initWithName:@"IllegalArgumentsException" reason:@"无法创建 ViewController" userInfo:@{ @"layout": layout }];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (self.bridgeManager.didSetRoot) {
|
|
77
|
-
self.bridgeManager.didSetRoot(@[NSNull.null, @NO]);
|
|
78
|
-
}
|
|
79
|
-
self.bridgeManager.didSetRoot = callback;
|
|
80
|
-
self.bridgeManager.hasRootLayout = YES;
|
|
81
|
-
|
|
82
|
-
[self.bridgeManager setRootViewController:vc];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
RCT_EXPORT_METHOD(dispatch:(NSString *)sceneId action:(NSString *)action extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback) {
|
|
86
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
87
|
-
if (!vc) {
|
|
88
|
-
callback(@[NSNull.null, @NO]);
|
|
89
|
-
RCTLogInfo(@"[Navigation] Can't find target scene for action: %@, maybe the scene is gone. \nextras: %@", action, extras);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[self.bridgeManager handleNavigationWithViewController:vc action:action extras:extras callback:(RCTResponseSenderBlock)callback];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
RCT_EXPORT_METHOD(currentTab:(NSString *)sceneId callback:(RCTResponseSenderBlock)callback) {
|
|
97
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
98
|
-
UITabBarController *tabs = vc.tabBarController;
|
|
99
|
-
if (tabs) {
|
|
100
|
-
callback(@[NSNull.null, @(tabs.selectedIndex)]);
|
|
101
|
-
} else {
|
|
102
|
-
callback(@[NSNull.null, @(-1)]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
RCT_EXPORT_METHOD(isStackRoot:(NSString *)sceneId callback:(RCTResponseSenderBlock)callback) {
|
|
107
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
108
|
-
UINavigationController *nav = vc.navigationController;
|
|
109
|
-
if (!nav) {
|
|
110
|
-
callback(@[NSNull.null, @NO]);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
NSArray *children = nav.childViewControllers;
|
|
115
|
-
if (children.count == 0) {
|
|
116
|
-
callback(@[NSNull.null, @NO]);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
UIViewController *root = children[0];
|
|
121
|
-
if ([root.sceneId isEqualToString:sceneId]) {
|
|
122
|
-
callback(@[NSNull.null, @YES]);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
callback(@[NSNull.null, @NO]);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
RCT_EXPORT_METHOD(setResult:(NSString *)sceneId resultCode:(NSInteger)resultCode data:(NSDictionary *)data) {
|
|
130
|
-
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
131
|
-
[vc setResultCode:resultCode resultData:data];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
RCT_EXPORT_METHOD(findSceneIdByModuleName:(NSString *)moduleName callback:(RCTResponseSenderBlock)callback) {
|
|
135
|
-
[self performSelector:@selector(findSceneIdWithParams:) withObject:@{
|
|
136
|
-
@"callback": callback,
|
|
137
|
-
@"moduleName": moduleName,
|
|
138
|
-
}];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
- (void)findSceneIdWithParams:(NSDictionary *)params {
|
|
142
|
-
if (!self.bridgeManager.isViewHierarchyReady) {
|
|
143
|
-
[self performSelector:@selector(findSceneIdWithParams:) withObject:params afterDelay:0.016];
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
NSString *moduleName = params[@"moduleName"];
|
|
148
|
-
RCTResponseSenderBlock callback = params[@"callback"];
|
|
149
|
-
|
|
150
|
-
NSString *sceneId = [self findSceneIdByModuleName:moduleName];
|
|
151
|
-
if (sceneId == nil) {
|
|
152
|
-
RCTLogInfo(@"[Navigation] Can't find sceneId by : %@", moduleName);
|
|
153
|
-
callback(@[NSNull.null, NSNull.null]);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
RCTLogInfo(@"[Navigation] The sceneId found by %@ : %@", moduleName, sceneId);
|
|
158
|
-
callback(@[[NSNull null], sceneId]);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
- (NSString *)findSceneIdByModuleName:(NSString *)moduleName {
|
|
162
|
-
UIWindow *keyWindow = RCTKeyWindow();
|
|
163
|
-
if (keyWindow) {
|
|
164
|
-
NSString *sceneId = [self findSceneIdByModuleName:moduleName withViewController:keyWindow.rootViewController];
|
|
165
|
-
if (sceneId != nil) {
|
|
166
|
-
RCTLogInfo(@"[Navigation] The sceneId found by %@ : %@", moduleName, sceneId);
|
|
167
|
-
return sceneId;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
RCTLogInfo(@"[Navigation] KeyWindow NOT found.");
|
|
172
|
-
|
|
173
|
-
return nil;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
- (NSString *)findSceneIdByModuleName:(NSString *)moduleName withViewController:(UIViewController *)vc {
|
|
177
|
-
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
178
|
-
HBDViewController *hbd = (HBDViewController *)vc;
|
|
179
|
-
if ([moduleName isEqualToString:hbd.moduleName]) {
|
|
180
|
-
return hbd.sceneId;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (vc.presentedViewController && vc != vc.presentedViewController && !vc.presentedViewController.isBeingDismissed) {
|
|
185
|
-
NSString *sceneId = [self findSceneIdByModuleName:moduleName withViewController:vc.presentedViewController];
|
|
186
|
-
if (sceneId) {
|
|
187
|
-
return sceneId;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
NSArray<UIViewController *> *children = vc.childViewControllers;
|
|
192
|
-
if (children.count == 0) {
|
|
193
|
-
return nil;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
for (UIViewController *child in children) {
|
|
197
|
-
NSString *sceneId = [self findSceneIdByModuleName:moduleName withViewController:child];
|
|
198
|
-
if (sceneId) {
|
|
199
|
-
return sceneId;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return nil;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
RCT_EXPORT_METHOD(currentRoute:(RCTResponseSenderBlock)callback) {
|
|
207
|
-
[self performSelector:@selector(currentRouteWithCallback:) withObject:callback];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
- (void)currentRouteWithCallback:(RCTResponseSenderBlock)callback {
|
|
211
|
-
if (!self.bridgeManager.isViewHierarchyReady) {
|
|
212
|
-
[self performSelector:@selector(currentRouteWithCallback:) withObject:callback afterDelay:0.016];
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
HBDViewController *current = [self.bridgeManager primaryViewController];
|
|
217
|
-
|
|
218
|
-
if (current) {
|
|
219
|
-
callback(@[[NSNull null], @{
|
|
220
|
-
@"moduleName": RCTNullIfNil(current.moduleName),
|
|
221
|
-
@"sceneId": current.sceneId,
|
|
222
|
-
@"presentingId": RCTNullIfNil(current.presentingSceneId),
|
|
223
|
-
@"mode": [current hbd_mode],
|
|
224
|
-
@"requestCode": @(current.requestCode),
|
|
225
|
-
}]);
|
|
226
|
-
} else {
|
|
227
|
-
[self performSelector:@selector(currentRouteWithCallback:) withObject:callback afterDelay:0.016];
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
RCT_EXPORT_METHOD(routeGraph:(RCTResponseSenderBlock)callback) {
|
|
232
|
-
[self performSelector:@selector(routeGraphWithCallback:) withObject:callback];
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
- (void)routeGraphWithCallback:(RCTResponseSenderBlock)callback {
|
|
236
|
-
if (!self.bridgeManager.isViewHierarchyReady) {
|
|
237
|
-
[self performSelector:@selector(routeGraphWithCallback:) withObject:callback afterDelay:0.016];
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
NSArray *root = [self.bridgeManager routeGraph];
|
|
242
|
-
if (root.count > 0) {
|
|
243
|
-
callback(@[[NSNull null], root]);
|
|
244
|
-
} else {
|
|
245
|
-
[self performSelector:@selector(routeGraphWithCallback:) withObject:callback afterDelay:0.016];
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
@end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#import "HBDReactTabBar.h"
|
|
2
|
-
|
|
3
|
-
#import <React/RCTRootView.h>
|
|
4
|
-
|
|
5
|
-
@interface HBDReactTabBar ()
|
|
6
|
-
|
|
7
|
-
@property(nonatomic, strong) RCTRootView *rootView;
|
|
8
|
-
|
|
9
|
-
@end
|
|
10
|
-
|
|
11
|
-
@implementation HBDReactTabBar
|
|
12
|
-
|
|
13
|
-
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
14
|
-
if (!self.isUserInteractionEnabled || self.isHidden || self.alpha <= 0.01) {
|
|
15
|
-
return nil;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
UIView *hitView = [super hitTest:point withEvent:event];
|
|
19
|
-
if (hitView == self.rootView) {
|
|
20
|
-
return hitView;
|
|
21
|
-
}
|
|
22
|
-
CGPoint convertedPoint = [self.rootView convertPoint:point fromView:self];
|
|
23
|
-
if ([self.rootView pointInside:convertedPoint withEvent:event]) {
|
|
24
|
-
return [self.rootView hitTest:convertedPoint withEvent:event];
|
|
25
|
-
}
|
|
26
|
-
return hitView;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
- (void)addSubview:(UIView *)view {
|
|
30
|
-
if ([view isKindOfClass:[RCTRootView class]]) {
|
|
31
|
-
self.rootView = (RCTRootView *) view;
|
|
32
|
-
}
|
|
33
|
-
[super addSubview:view];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
#import "UITabBar+Badge.h"
|
|
2
|
-
|
|
3
|
-
@implementation UITabBar (DotBadge)
|
|
4
|
-
|
|
5
|
-
- (void)showDotBadgeAtIndex:(NSInteger)index {
|
|
6
|
-
[self hideDotBadgeAtIndex:index];
|
|
7
|
-
//label为小红点,并设置label属性
|
|
8
|
-
UILabel *label = [[UILabel alloc] init];
|
|
9
|
-
label.tag = 1000 + index;
|
|
10
|
-
|
|
11
|
-
label.backgroundColor = [UITabBarItem appearance].badgeColor ?: [UIColor colorWithRed:1 green:58.0 / 255.0 blue:47. / 255. alpha:1];
|
|
12
|
-
|
|
13
|
-
CGFloat percentX = (index + 0.5) / self.items.count;
|
|
14
|
-
CGFloat x = ceilf((float) (percentX * self.frame.size.width + 8));
|
|
15
|
-
CGFloat y = 6;
|
|
16
|
-
//10为小红点的高度和宽度
|
|
17
|
-
label.frame = CGRectMake(x, y, 8, 8);
|
|
18
|
-
[self addSubview:label];
|
|
19
|
-
//把小红点移到最顶层
|
|
20
|
-
[self bringSubviewToFront:label];
|
|
21
|
-
|
|
22
|
-
[self styleLabel:label];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
- (void)hideDotBadgeAtIndex:(NSInteger)index {
|
|
26
|
-
for (UIView *subView in self.subviews) {
|
|
27
|
-
if (subView.tag == 1000 + index) {
|
|
28
|
-
[subView removeFromSuperview];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
- (void)styleLabel:(UILabel *)label {
|
|
34
|
-
CGRect rect = label.bounds;
|
|
35
|
-
CGFloat radius = 4;
|
|
36
|
-
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect
|
|
37
|
-
byRoundingCorners:UIRectCornerAllCorners
|
|
38
|
-
cornerRadii:CGSizeMake(radius, radius)];
|
|
39
|
-
|
|
40
|
-
CAShapeLayer *maskLayer = [CAShapeLayer layer];
|
|
41
|
-
maskLayer.frame = rect;
|
|
42
|
-
maskLayer.path = maskPath.CGPath;
|
|
43
|
-
label.layer.mask = maskLayer;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@end
|