hybrid-navigation 2.12.2 → 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/HBDEventEmitter.java +1 -0
- 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 +7 -15
- 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 +13 -20
- 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,16 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDReactViewController.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/26.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "HBDReactViewController.h"
|
|
2
|
+
|
|
10
3
|
#import "HBDReactBridgeManager.h"
|
|
11
4
|
#import "HBDTitleView.h"
|
|
12
5
|
#import "HBDRootView.h"
|
|
13
6
|
#import "HBDEventEmitter.h"
|
|
7
|
+
#import "HBDUtils.h"
|
|
14
8
|
|
|
15
9
|
#import <React/RCTConvert.h>
|
|
16
10
|
|
|
@@ -22,7 +16,9 @@
|
|
|
22
16
|
|
|
23
17
|
@end
|
|
24
18
|
|
|
25
|
-
@implementation HBDReactViewController
|
|
19
|
+
@implementation HBDReactViewController {
|
|
20
|
+
NSArray *_reactViewConstraints;
|
|
21
|
+
}
|
|
26
22
|
|
|
27
23
|
- (void)dealloc {
|
|
28
24
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillReloadNotification object:nil];
|
|
@@ -42,14 +38,20 @@
|
|
|
42
38
|
|
|
43
39
|
- (void)loadView {
|
|
44
40
|
RCTRootView *rootView = [[HBDRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:self.moduleName initialProperties:[self propsWithSceneId]];
|
|
41
|
+
self.rootView = rootView;
|
|
42
|
+
|
|
45
43
|
BOOL passThroughTouches = [self.options[@"passThroughTouches"] boolValue];
|
|
46
44
|
rootView.passThroughTouches = passThroughTouches;
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
rootView.backgroundColor = UIColor.clearColor;
|
|
46
|
+
rootView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
47
|
+
self.view = [UIView new];
|
|
48
|
+
[self.view addSubview:rootView];
|
|
49
|
+
[self updateReactViewConstraints];
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
- (void)viewDidLoad {
|
|
52
53
|
[super viewDidLoad];
|
|
54
|
+
|
|
53
55
|
NSDictionary *titleItem = self.options[@"titleItem"];
|
|
54
56
|
if (titleItem && self.navigationController) {
|
|
55
57
|
if (self.hbd_barHidden) {
|
|
@@ -71,6 +73,34 @@
|
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
- (void)viewSafeAreaInsetsDidChange {
|
|
77
|
+
[super viewSafeAreaInsetsDidChange];
|
|
78
|
+
[self updateReactViewConstraints];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (void)updateReactViewConstraints {
|
|
82
|
+
if (self.isViewLoaded && self.rootView) {
|
|
83
|
+
[NSLayoutConstraint deactivateConstraints:_reactViewConstraints];
|
|
84
|
+
_reactViewConstraints = @[
|
|
85
|
+
[self.rootView.topAnchor
|
|
86
|
+
constraintEqualToAnchor:self.shouldFitWindowInsetTop ? self.view.topAnchor : self.view.safeAreaLayoutGuide.topAnchor],
|
|
87
|
+
[self.rootView.bottomAnchor
|
|
88
|
+
constraintEqualToAnchor:self.view.bottomAnchor],
|
|
89
|
+
[self.rootView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
|
|
90
|
+
[self.rootView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor]
|
|
91
|
+
];
|
|
92
|
+
[NSLayoutConstraint activateConstraints:_reactViewConstraints];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
- (BOOL)shouldFitWindowInsetTop {
|
|
97
|
+
if (![self.parentViewController isKindOfClass:UINavigationController.class]) {
|
|
98
|
+
return YES;
|
|
99
|
+
}
|
|
100
|
+
BOOL isTranslucent = self.hbd_barHidden || self.hbd_barAlpha < 1.0 || colorHasAlphaComponent(self.hbd_barTintColor);
|
|
101
|
+
return isTranslucent || self.extendedLayoutIncludesOpaqueBars;
|
|
102
|
+
}
|
|
103
|
+
|
|
74
104
|
- (NSDictionary *)propsWithSceneId {
|
|
75
105
|
NSMutableDictionary *props;
|
|
76
106
|
if (self.props) {
|
|
@@ -91,15 +121,18 @@
|
|
|
91
121
|
|
|
92
122
|
- (void)viewWillAppear:(BOOL)animated {
|
|
93
123
|
[super viewWillAppear:animated];
|
|
124
|
+
#pragma clang diagnostic push
|
|
125
|
+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
94
126
|
self.automaticallyAdjustsScrollViewInsets = NO;
|
|
127
|
+
#pragma clang diagnostic pop
|
|
95
128
|
id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
96
129
|
if (coordinator && !coordinator.interactive) {
|
|
97
130
|
if (!self.viewAppeared) {
|
|
98
131
|
self.viewAppeared = YES;
|
|
99
132
|
if (self.firstRenderCompleted) {
|
|
100
133
|
[HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
|
|
101
|
-
|
|
102
|
-
|
|
134
|
+
KEY_SCENE_ID: self.sceneId,
|
|
135
|
+
KEY_ON: ON_COMPONENT_APPEAR
|
|
103
136
|
}];
|
|
104
137
|
}
|
|
105
138
|
}
|
|
@@ -112,8 +145,8 @@
|
|
|
112
145
|
self.viewAppeared = YES;
|
|
113
146
|
if (self.firstRenderCompleted) {
|
|
114
147
|
[HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
|
|
115
|
-
|
|
116
|
-
|
|
148
|
+
KEY_SCENE_ID: self.sceneId,
|
|
149
|
+
KEY_ON: ON_COMPONENT_APPEAR
|
|
117
150
|
}];
|
|
118
151
|
}
|
|
119
152
|
}
|
|
@@ -127,8 +160,8 @@
|
|
|
127
160
|
self.viewAppeared = NO;
|
|
128
161
|
if (self.firstRenderCompleted) {
|
|
129
162
|
[HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
|
|
130
|
-
|
|
131
|
-
|
|
163
|
+
KEY_SCENE_ID: self.sceneId,
|
|
164
|
+
KEY_ON: ON_COMPONENT_DISAPPEAR
|
|
132
165
|
}];
|
|
133
166
|
}
|
|
134
167
|
}
|
|
@@ -141,8 +174,8 @@
|
|
|
141
174
|
self.viewAppeared = NO;
|
|
142
175
|
if (self.firstRenderCompleted) {
|
|
143
176
|
[HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
|
|
144
|
-
|
|
145
|
-
|
|
177
|
+
KEY_SCENE_ID: self.sceneId,
|
|
178
|
+
KEY_ON: ON_COMPONENT_DISAPPEAR
|
|
146
179
|
}];
|
|
147
180
|
}
|
|
148
181
|
}
|
|
@@ -155,8 +188,8 @@
|
|
|
155
188
|
self.firstRenderCompleted = YES;
|
|
156
189
|
if (self.viewAppeared) {
|
|
157
190
|
[HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
|
|
158
|
-
|
|
159
|
-
|
|
191
|
+
KEY_SCENE_ID: self.sceneId,
|
|
192
|
+
KEY_ON: ON_COMPONENT_APPEAR
|
|
160
193
|
}];
|
|
161
194
|
}
|
|
162
195
|
}
|
|
@@ -164,11 +197,11 @@
|
|
|
164
197
|
- (void)didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
|
|
165
198
|
[super didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
166
199
|
[HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
200
|
+
KEY_ON: ON_COMPONENT_RESULT,
|
|
201
|
+
KEY_REQUEST_CODE: @(requestCode),
|
|
202
|
+
KEY_RESULT_CODE: @(resultCode),
|
|
203
|
+
KEY_RESULT_DATA: RCTNullIfNil(data),
|
|
204
|
+
KEY_SCENE_ID: self.sceneId,
|
|
172
205
|
}];
|
|
173
206
|
}
|
|
174
207
|
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDTabBarController.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/1/30.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "HBDTabBarController.h"
|
|
2
|
+
|
|
10
3
|
#import "HBDReactViewController.h"
|
|
11
4
|
#import "HBDReactBridgeManager.h"
|
|
12
5
|
#import "HBDUtils.h"
|
|
13
6
|
#import "HBDEventEmitter.h"
|
|
14
7
|
#import "HBDReactTabBar.h"
|
|
15
8
|
#import "HBDRootView.h"
|
|
9
|
+
#import "HBDFadeAnimation.h"
|
|
16
10
|
|
|
17
11
|
#import <React/RCTRootViewDelegate.h>
|
|
18
12
|
#import <React/RCTLog.h>
|
|
@@ -117,7 +111,7 @@
|
|
|
117
111
|
|
|
118
112
|
- (void)setTabItem:(NSArray<NSDictionary *> *)options {
|
|
119
113
|
for (NSDictionary *option in options) {
|
|
120
|
-
NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
|
|
114
|
+
NSUInteger index = (NSUInteger) (option[@"index"] ? [option[@"index"] integerValue] : 0);
|
|
121
115
|
if (self.hasCustomTabBar) {
|
|
122
116
|
[self updateCustomTabItem:option atIndex:index];
|
|
123
117
|
} else {
|
|
@@ -258,4 +252,13 @@
|
|
|
258
252
|
return YES;
|
|
259
253
|
}
|
|
260
254
|
|
|
255
|
+
- (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
|
|
256
|
+
|
|
257
|
+
if (toVC.viewLoaded) {
|
|
258
|
+
return nil;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return [[HBDFadeAnimation alloc] init];
|
|
262
|
+
}
|
|
263
|
+
|
|
261
264
|
@end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
#import <React/RCTConvert.h>
|
|
2
|
-
#import <React/RCTRootView.h>
|
|
3
|
-
|
|
4
1
|
#import "HBDViewController+Garden.h"
|
|
5
2
|
|
|
6
3
|
#import "HBDBarButtonItem.h"
|
|
7
4
|
#import "HBDUtils.h"
|
|
8
5
|
#import "HBDEventEmitter.h"
|
|
9
6
|
|
|
7
|
+
#import <React/RCTConvert.h>
|
|
8
|
+
#import <React/RCTRootView.h>
|
|
9
|
+
|
|
10
10
|
@implementation HBDViewController (Garden)
|
|
11
11
|
|
|
12
12
|
- (void)setLeftBarButtonItem:(NSDictionary *)item {
|
|
@@ -16,16 +16,14 @@
|
|
|
16
16
|
|
|
17
17
|
if (item) {
|
|
18
18
|
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
19
|
+
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
|
|
20
|
+
spacer.width = -8;
|
|
21
|
+
[array addObject:spacer];
|
|
22
|
+
|
|
25
23
|
UIBarButtonItem *buttonItem = [self createBarButtonItem:item];
|
|
26
24
|
UIView *customView = buttonItem.customView;
|
|
27
25
|
if ([customView isKindOfClass:[HBDBarButton class]]) {
|
|
28
|
-
HBDBarButton *button = (HBDBarButton *)
|
|
26
|
+
HBDBarButton *button = (HBDBarButton *)customView;
|
|
29
27
|
button.imageEdgeInsets = buttonItem.imageInsets;
|
|
30
28
|
button.alignmentRectInsetsOverride = UIEdgeInsetsMake(0, 4, 0, -4);
|
|
31
29
|
}
|
|
@@ -44,16 +42,14 @@
|
|
|
44
42
|
|
|
45
43
|
if (item) {
|
|
46
44
|
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
45
|
+
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
|
|
46
|
+
spacer.width = -8;
|
|
47
|
+
[array addObject:spacer];
|
|
48
|
+
|
|
53
49
|
UIBarButtonItem *buttonItem = [self createBarButtonItem:item];
|
|
54
50
|
UIView *customView = buttonItem.customView;
|
|
55
51
|
if ([customView isKindOfClass:[HBDBarButton class]]) {
|
|
56
|
-
HBDBarButton *button = (HBDBarButton *)
|
|
52
|
+
HBDBarButton *button = (HBDBarButton *)customView;
|
|
57
53
|
button.imageEdgeInsets = buttonItem.imageInsets;
|
|
58
54
|
button.alignmentRectInsetsOverride = UIEdgeInsetsMake(0, -4, 0, 4);
|
|
59
55
|
}
|
|
@@ -73,19 +69,16 @@
|
|
|
73
69
|
if (items) {
|
|
74
70
|
NSArray *barButtonItems = [self createBarButtonItems:items];
|
|
75
71
|
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
[array addObject:spacer];
|
|
81
|
-
}
|
|
82
|
-
|
|
72
|
+
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
|
|
73
|
+
spacer.width = -8;
|
|
74
|
+
[array addObject:spacer];
|
|
75
|
+
|
|
83
76
|
[array addObjectsFromArray:barButtonItems];
|
|
84
77
|
for (NSUInteger i = 0; i < barButtonItems.count; i++) {
|
|
85
78
|
UIBarButtonItem *buttonItem = barButtonItems[i];
|
|
86
79
|
UIView *customView = buttonItem.customView;
|
|
87
80
|
if ([customView isKindOfClass:[HBDBarButton class]]) {
|
|
88
|
-
HBDBarButton *button = (HBDBarButton *)
|
|
81
|
+
HBDBarButton *button = (HBDBarButton *)customView;
|
|
89
82
|
button.imageEdgeInsets = buttonItem.imageInsets;
|
|
90
83
|
button.alignmentRectInsetsOverride = UIEdgeInsetsMake(0, 4, 0, -4);
|
|
91
84
|
}
|
|
@@ -103,18 +96,16 @@
|
|
|
103
96
|
if (items) {
|
|
104
97
|
NSArray *barButtonItems = [self createBarButtonItems:items];
|
|
105
98
|
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
99
|
+
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
|
|
100
|
+
spacer.width = -8;
|
|
101
|
+
[array addObject:spacer];
|
|
102
|
+
|
|
112
103
|
[array addObjectsFromArray:barButtonItems];
|
|
113
104
|
for (NSUInteger i = 0; i < barButtonItems.count; i++) {
|
|
114
105
|
UIBarButtonItem *buttonItem = barButtonItems[i];
|
|
115
106
|
UIView *customView = buttonItem.customView;
|
|
116
107
|
if ([customView isKindOfClass:[HBDBarButton class]]) {
|
|
117
|
-
HBDBarButton *button = (HBDBarButton *)
|
|
108
|
+
HBDBarButton *button = (HBDBarButton *)customView;
|
|
118
109
|
button.imageEdgeInsets = buttonItem.imageInsets;
|
|
119
110
|
button.alignmentRectInsetsOverride = UIEdgeInsetsMake(0, -4, 0, 4);
|
|
120
111
|
}
|
|
@@ -135,7 +126,6 @@
|
|
|
135
126
|
|
|
136
127
|
- (HBDBarButtonItem *)createBarButtonItem:(NSDictionary *)item {
|
|
137
128
|
HBDBarButtonItem *barButtonItem;
|
|
138
|
-
|
|
139
129
|
NSDictionary *insetsOption = item[@"insetsIOS"];
|
|
140
130
|
UIEdgeInsets insets = UIEdgeInsetsZero;
|
|
141
131
|
if (insetsOption) {
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
// HBDViewController.h
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/25.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
1
|
+
#import "UIViewController+HBD.h"
|
|
8
2
|
|
|
9
3
|
#import <UIKit/UIKit.h>
|
|
10
|
-
#import "UIViewController+HBD.h"
|
|
11
4
|
|
|
12
5
|
@interface HBDViewController : UIViewController
|
|
13
6
|
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDViewController.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/25.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <React/RCTLog.h>
|
|
10
|
-
|
|
11
1
|
#import "HBDViewController.h"
|
|
2
|
+
|
|
12
3
|
#import "HBDViewController+Garden.h"
|
|
13
4
|
#import "HBDUtils.h"
|
|
14
5
|
#import "GlobalStyle.h"
|
|
15
6
|
|
|
7
|
+
#import <React/RCTLog.h>
|
|
8
|
+
|
|
16
9
|
@interface HBDViewController ()
|
|
17
10
|
|
|
18
11
|
@property(nonatomic, copy, readwrite) NSDictionary *props;
|
|
@@ -247,17 +240,9 @@
|
|
|
247
240
|
NSNumber *backButtonHidden = options[@"backButtonHidden"];
|
|
248
241
|
if (backButtonHidden) {
|
|
249
242
|
if ([backButtonHidden boolValue]) {
|
|
250
|
-
|
|
251
|
-
[self.navigationItem setHidesBackButton:YES];
|
|
252
|
-
} else {
|
|
253
|
-
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[UIView new]];
|
|
254
|
-
}
|
|
243
|
+
[self.navigationItem setHidesBackButton:YES];
|
|
255
244
|
} else {
|
|
256
|
-
|
|
257
|
-
[self.navigationItem setHidesBackButton:NO];
|
|
258
|
-
} else {
|
|
259
|
-
self.navigationItem.leftBarButtonItem = nil;
|
|
260
|
-
}
|
|
245
|
+
[self.navigationItem setHidesBackButton:NO];
|
|
261
246
|
}
|
|
262
247
|
}
|
|
263
248
|
|
|
@@ -329,9 +314,7 @@
|
|
|
329
314
|
}
|
|
330
315
|
|
|
331
316
|
if (options[@"homeIndicatorAutoHiddenIOS"]) {
|
|
332
|
-
|
|
333
|
-
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
334
|
-
}
|
|
317
|
+
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
335
318
|
}
|
|
336
319
|
|
|
337
320
|
NSNumber *passThroughTouches = options[@"passThroughTouches"];
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
// UIViewController+HBD.h
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/1/22.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <UIKit/UIKit.h>
|
|
10
1
|
#import "HBDDrawerController.h"
|
|
11
2
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
typedef void(^HBDDidHideActionBlock)(void);
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
15
4
|
|
|
16
5
|
@interface UIViewController (HBD)
|
|
17
6
|
|
|
@@ -28,13 +17,10 @@ typedef void(^HBDDidHideActionBlock)(void);
|
|
|
28
17
|
@property(nonatomic, assign) BOOL hbd_statusBarHidden;
|
|
29
18
|
|
|
30
19
|
@property(nonatomic, assign) BOOL hbd_viewAppeared;
|
|
31
|
-
@property(nonatomic,
|
|
32
|
-
@property(nonatomic, copy) HBDDidHideActionBlock didHideActionBlock;
|
|
20
|
+
@property(nonatomic, assign) BOOL hbd_inViewHierarchy;
|
|
33
21
|
|
|
34
22
|
- (void)hbd_setNeedsUpdateNavigationBar;
|
|
35
23
|
|
|
36
|
-
@property(nonatomic, assign) BOOL hbd_extendedLayoutDidSet;
|
|
37
|
-
|
|
38
24
|
@property(nonatomic, copy, readonly) NSString *sceneId;
|
|
39
25
|
@property(nonatomic, assign) NSInteger resultCode;
|
|
40
26
|
@property(nonatomic, assign) NSInteger requestCode;
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
//
|
|
2
|
-
// UIViewController+HBD.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/1/22.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <objc/runtime.h>
|
|
10
|
-
#import <React/RCTLog.h>
|
|
11
|
-
|
|
12
1
|
#import "UIViewController+HBD.h"
|
|
13
|
-
#import "UITabBar+Badge.h"
|
|
14
2
|
|
|
15
3
|
#import "HBDNavigationController.h"
|
|
16
4
|
#import "HBDUtils.h"
|
|
17
5
|
#import "GlobalStyle.h"
|
|
6
|
+
#import "UITabBar+Badge.h"
|
|
7
|
+
|
|
8
|
+
#import <React/RCTLog.h>
|
|
18
9
|
|
|
19
10
|
@implementation UIViewController (HBD)
|
|
20
11
|
|
|
21
12
|
+ (void)load {
|
|
22
13
|
static dispatch_once_t onceToken;
|
|
23
14
|
dispatch_once(&onceToken, ^{
|
|
24
|
-
Class
|
|
25
|
-
hbd_exchangeImplementations(
|
|
26
|
-
hbd_exchangeImplementations(
|
|
27
|
-
hbd_exchangeImplementations(
|
|
28
|
-
hbd_exchangeImplementations(
|
|
15
|
+
Class clazz = [self class];
|
|
16
|
+
hbd_exchangeImplementations(clazz, @selector(presentViewController:animated:completion:), @selector(hbd_presentViewController:animated:completion:));
|
|
17
|
+
hbd_exchangeImplementations(clazz, @selector(dismissViewControllerAnimated:completion:), @selector(hbd_dismissViewControllerAnimated:completion:));
|
|
18
|
+
hbd_exchangeImplementations(clazz, @selector(viewDidAppear:), @selector(hbd_viewDidAppear:));
|
|
19
|
+
hbd_exchangeImplementations(clazz, @selector(viewDidDisappear:), @selector(hbd_viewDidDisappear:));
|
|
20
|
+
hbd_exchangeImplementations(clazz, @selector(didMoveToParentViewController:), @selector(hbd_didMoveToParentViewController:));
|
|
29
21
|
});
|
|
30
22
|
}
|
|
31
23
|
|
|
24
|
+
- (void)hbd_didMoveToParentViewController:(UIViewController *)parent {
|
|
25
|
+
[self hbd_didMoveToParentViewController:parent];
|
|
26
|
+
self.hbd_inViewHierarchy = parent != nil;
|
|
27
|
+
}
|
|
28
|
+
|
|
32
29
|
- (void)hbd_viewDidAppear:(BOOL)animated {
|
|
33
30
|
[self hbd_viewDidAppear:animated];
|
|
34
31
|
self.hbd_viewAppeared = YES;
|
|
@@ -248,29 +245,13 @@
|
|
|
248
245
|
objc_setAssociatedObject(self, @selector(hbd_viewAppeared), @(viewAppeared), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
249
246
|
}
|
|
250
247
|
|
|
251
|
-
- (
|
|
252
|
-
return objc_getAssociatedObject(self, _cmd);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
- (void)setDidShowActionBlock:(HBDDidShowActionBlock)actionBlock {
|
|
256
|
-
objc_setAssociatedObject(self, @selector(didShowActionBlock), actionBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
- (HBDDidHideActionBlock)didHideActionBlock {
|
|
260
|
-
return objc_getAssociatedObject(self, _cmd);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
- (void)setDidHideActionBlock:(HBDDidHideActionBlock)actionBlock {
|
|
264
|
-
objc_setAssociatedObject(self, @selector(didHideActionBlock), actionBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
- (BOOL)hbd_extendedLayoutDidSet {
|
|
248
|
+
- (BOOL)hbd_inViewHierarchy {
|
|
268
249
|
id obj = objc_getAssociatedObject(self, _cmd);
|
|
269
|
-
return obj ? [obj boolValue] :
|
|
250
|
+
return obj ? [obj boolValue] : YES;
|
|
270
251
|
}
|
|
271
252
|
|
|
272
|
-
- (void)
|
|
273
|
-
objc_setAssociatedObject(self, @selector(
|
|
253
|
+
- (void)setHbd_inViewHierarchy:(BOOL)inViewHierarchy {
|
|
254
|
+
objc_setAssociatedObject(self, @selector(hbd_inViewHierarchy), @(inViewHierarchy), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
274
255
|
}
|
|
275
256
|
|
|
276
257
|
- (void)hbd_setNeedsUpdateNavigationBar {
|
|
@@ -325,19 +306,24 @@
|
|
|
325
306
|
if ([self isKindOfClass:[UITabBarController class]]) {
|
|
326
307
|
UIViewController *child = ((UITabBarController *) self).selectedViewController;
|
|
327
308
|
[child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
328
|
-
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if ([self isKindOfClass:[UINavigationController class]]) {
|
|
329
313
|
UIViewController *child = ((UINavigationController *) self).topViewController;
|
|
330
314
|
[child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
331
|
-
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if ([self isKindOfClass:[HBDDrawerController class]]) {
|
|
332
319
|
UIViewController *child = ((HBDDrawerController *) self).contentController;
|
|
333
320
|
[child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
NSArray *children = self.childViewControllers;
|
|
325
|
+
for (UIViewController *vc in children) {
|
|
326
|
+
[vc didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
341
327
|
}
|
|
342
328
|
}
|
|
343
329
|
|
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 {};
|