hybrid-navigation 2.7.5 → 2.7.8
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/CHANGELOG.md +24 -0
- package/android/build.gradle +1 -1
- package/ios/HybridNavigation/Bridge/HBDEventEmitter.h +16 -16
- package/ios/HybridNavigation/Bridge/HBDEventEmitter.m +33 -33
- package/ios/HybridNavigation/Bridge/HBDGardenModule.m +43 -25
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +83 -58
- package/ios/HybridNavigation/Bridge/HBDReactBridgeManager.h +3 -3
- package/ios/HybridNavigation/Bridge/HBDReactBridgeManager.m +57 -61
- package/ios/HybridNavigation/GlobalStyle.h +7 -7
- package/ios/HybridNavigation/GlobalStyle.m +86 -86
- package/ios/HybridNavigation/HBDGarden.m +28 -28
- package/ios/HybridNavigation/HBDUtils.h +4 -4
- package/ios/HybridNavigation/HBDUtils.m +43 -49
- package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.m +24 -24
- package/ios/HybridNavigation/Navigator/HBDNavigator.h +2 -2
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.h +4 -4
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +19 -20
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +24 -26
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +31 -30
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.m +54 -56
- package/ios/HybridNavigation/View/HBDBarButtonItem.h +1 -1
- package/ios/HybridNavigation/View/HBDBarButtonItem.m +5 -5
- package/ios/HybridNavigation/View/HBDNavigationBar.h +4 -4
- package/ios/HybridNavigation/View/HBDNavigationBar.m +19 -20
- package/ios/HybridNavigation/View/HBDReactTabBar.m +3 -3
- package/ios/HybridNavigation/View/HBDRootView.m +3 -3
- package/ios/HybridNavigation/View/HBDTitleView.m +7 -7
- package/ios/HybridNavigation/View/UITabBar+Badge.h +1 -0
- package/ios/HybridNavigation/View/UITabBar+Badge.m +6 -6
- package/ios/HybridNavigation/ViewController/HBDDrawerController.h +8 -5
- package/ios/HybridNavigation/ViewController/HBDDrawerController.m +39 -38
- package/ios/HybridNavigation/ViewController/HBDModalViewController.h +2 -2
- package/ios/HybridNavigation/ViewController/HBDModalViewController.m +45 -44
- package/ios/HybridNavigation/ViewController/HBDNavigationController.h +1 -1
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +111 -113
- package/ios/HybridNavigation/ViewController/HBDPopAnimation.m +4 -4
- package/ios/HybridNavigation/ViewController/HBDPushAnimation.m +4 -4
- package/ios/HybridNavigation/ViewController/HBDReactViewController.m +24 -26
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +1 -1
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +25 -26
- package/ios/HybridNavigation/ViewController/HBDViewController.m +31 -32
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +5 -4
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +20 -19
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +35 -36
- package/lib/DeepLink.js +5 -5
- package/lib/hooks.d.ts +1 -1
- package/lib/hooks.js +4 -7
- package/package.json +1 -1
|
@@ -8,33 +8,29 @@
|
|
|
8
8
|
|
|
9
9
|
#import "HBDNavigationController.h"
|
|
10
10
|
#import "HBDViewController.h"
|
|
11
|
-
#import "UIViewController+HBD.h"
|
|
12
11
|
#import "HBDNavigationBar.h"
|
|
13
|
-
#import "HBDReactBridgeManager.h"
|
|
14
12
|
#import "HBDUtils.h"
|
|
15
|
-
#import "HBDReactViewController.h"
|
|
16
13
|
#import "HBDPushAnimation.h"
|
|
17
14
|
#import "HBDPopAnimation.h"
|
|
18
|
-
#import "HBDGarden.h"
|
|
19
15
|
#import <React/RCTLog.h>
|
|
20
16
|
|
|
21
|
-
UIColor*
|
|
17
|
+
UIColor *blendColor(UIColor *from, UIColor *to, CGFloat percent) {
|
|
22
18
|
CGFloat fromRed = 0;
|
|
23
19
|
CGFloat fromGreen = 0;
|
|
24
20
|
CGFloat fromBlue = 0;
|
|
25
21
|
CGFloat fromAlpha = 0;
|
|
26
22
|
[from getRed:&fromRed green:&fromGreen blue:&fromBlue alpha:&fromAlpha];
|
|
27
|
-
|
|
23
|
+
|
|
28
24
|
CGFloat toRed = 0;
|
|
29
25
|
CGFloat toGreen = 0;
|
|
30
26
|
CGFloat toBlue = 0;
|
|
31
27
|
CGFloat toAlpha = 0;
|
|
32
28
|
[to getRed:&toRed green:&toGreen blue:&toBlue alpha:&toAlpha];
|
|
33
|
-
|
|
34
|
-
CGFloat newRed =
|
|
35
|
-
CGFloat newGreen = fromGreen + (toGreen - fromGreen) * fminf(1, percent * 4);
|
|
36
|
-
CGFloat newBlue = fromBlue + (toBlue - fromBlue) * fminf(1, percent * 4);
|
|
37
|
-
CGFloat newAlpha = fromAlpha + (toAlpha - fromAlpha) * fminf(1, percent * 4);
|
|
29
|
+
|
|
30
|
+
CGFloat newRed = fromRed + (toRed - fromRed) * fminf(1, (float) (percent * 4));
|
|
31
|
+
CGFloat newGreen = fromGreen + (toGreen - fromGreen) * fminf(1, (float) (percent * 4));
|
|
32
|
+
CGFloat newBlue = fromBlue + (toBlue - fromBlue) * fminf(1, (float) (percent * 4));
|
|
33
|
+
CGFloat newAlpha = fromAlpha + (toAlpha - fromAlpha) * fminf(1, (float) (percent * 4));
|
|
38
34
|
return [UIColor colorWithRed:newRed green:newGreen blue:newBlue alpha:newAlpha];
|
|
39
35
|
}
|
|
40
36
|
|
|
@@ -43,18 +39,18 @@ void adjustLayout(UIViewController *vc) {
|
|
|
43
39
|
return;
|
|
44
40
|
}
|
|
45
41
|
vc.hbd_extendedLayoutDidSet = YES;
|
|
46
|
-
|
|
42
|
+
|
|
47
43
|
BOOL isTranslucent = vc.hbd_barHidden || vc.hbd_barAlpha < 1.0 || colorHasAlphaComponent(vc.hbd_barTintColor);
|
|
48
44
|
if (isTranslucent || vc.extendedLayoutIncludesOpaqueBars) {
|
|
49
45
|
vc.edgesForExtendedLayout |= UIRectEdgeTop;
|
|
50
46
|
} else {
|
|
51
47
|
vc.edgesForExtendedLayout &= ~UIRectEdgeTop;
|
|
52
48
|
}
|
|
53
|
-
|
|
49
|
+
|
|
54
50
|
if (vc.hbd_barHidden) {
|
|
55
51
|
if (@available(iOS 11.0, *)) {
|
|
56
52
|
UIEdgeInsets insets = vc.additionalSafeAreaInsets;
|
|
57
|
-
|
|
53
|
+
CGFloat height = vc.navigationController.navigationBar.bounds.size.height;
|
|
58
54
|
vc.additionalSafeAreaInsets = UIEdgeInsetsMake(-height + insets.top, insets.left, insets.bottom, insets.right);
|
|
59
55
|
}
|
|
60
56
|
}
|
|
@@ -72,9 +68,9 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
72
68
|
|
|
73
69
|
@interface HBDNavigationControllerDelegate : UIScreenEdgePanGestureRecognizer <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
|
|
74
70
|
|
|
75
|
-
@property
|
|
76
|
-
@property
|
|
77
|
-
@property
|
|
71
|
+
@property(nonatomic, weak) id <UINavigationControllerDelegate> proxyDelegate;
|
|
72
|
+
@property(nonatomic, weak, readonly) HBDNavigationController *nav;
|
|
73
|
+
@property(nonatomic, strong) UIPercentDrivenInteractiveTransition *interactiveTransition;
|
|
78
74
|
|
|
79
75
|
- (instancetype)initWithNavigationController:(HBDNavigationController *)navigationController;
|
|
80
76
|
|
|
@@ -82,17 +78,20 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
82
78
|
|
|
83
79
|
@interface HBDNavigationController ()
|
|
84
80
|
|
|
85
|
-
@property
|
|
86
|
-
@property
|
|
87
|
-
@property
|
|
88
|
-
@property
|
|
89
|
-
@property
|
|
90
|
-
@property
|
|
91
|
-
@property
|
|
81
|
+
@property(nonatomic, readonly) HBDNavigationBar *navigationBar;
|
|
82
|
+
@property(nonatomic, strong) UIVisualEffectView *fromFakeBar;
|
|
83
|
+
@property(nonatomic, strong) UIVisualEffectView *toFakeBar;
|
|
84
|
+
@property(nonatomic, strong) UIImageView *fromFakeShadow;
|
|
85
|
+
@property(nonatomic, strong) UIImageView *toFakeShadow;
|
|
86
|
+
@property(nonatomic, weak) UIViewController *poppingViewController;
|
|
87
|
+
@property(nonatomic, strong) HBDNavigationControllerDelegate *navigationDelegate;
|
|
92
88
|
|
|
93
89
|
- (void)updateNavigationBarStyleForViewController:(UIViewController *)vc;
|
|
94
|
-
|
|
90
|
+
|
|
91
|
+
- (void)updateNavigationBarTintColorForViewController:(UIViewController *)vc;
|
|
92
|
+
|
|
95
93
|
- (void)updateNavigationBarAlphaForViewController:(UIViewController *)vc;
|
|
94
|
+
|
|
96
95
|
- (void)updateNavigationBarBackgroundForViewController:(UIViewController *)vc;
|
|
97
96
|
|
|
98
97
|
- (void)showFakeBarFrom:(UIViewController *)from to:(UIViewController *)to;
|
|
@@ -134,7 +133,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
134
133
|
return NO;
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer API_AVAILABLE(ios(7.0)){
|
|
136
|
+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer API_AVAILABLE(ios(7.0)) {
|
|
138
137
|
if (gestureRecognizer == self.nav.interactivePopGestureRecognizer) {
|
|
139
138
|
return YES;
|
|
140
139
|
}
|
|
@@ -143,13 +142,13 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
143
142
|
|
|
144
143
|
- (void)handleNavigationTransition:(UIScreenEdgePanGestureRecognizer *)pan {
|
|
145
144
|
HBDNavigationController *nav = self.nav;
|
|
146
|
-
|
|
147
|
-
id<UIViewControllerTransitionCoordinator> coordinator = nav.transitionCoordinator;
|
|
148
|
-
|
|
149
|
-
if (![self.
|
|
145
|
+
|
|
146
|
+
id <UIViewControllerTransitionCoordinator> coordinator = nav.transitionCoordinator;
|
|
147
|
+
|
|
148
|
+
if (![self.proxyDelegate respondsToSelector:@selector(navigationController:interactionControllerForAnimationController:)]) {
|
|
150
149
|
if (self.interactiveTransition || (!coordinator && [self shouldBetterTransitionWithViewController:nav.topViewController])) {
|
|
151
150
|
CGFloat process = [pan translationInView:nav.view].x / nav.view.bounds.size.width;
|
|
152
|
-
process = MIN(1.0,(MAX(0.0, process)));
|
|
151
|
+
process = MIN(1.0, (MAX(0.0, process)));
|
|
153
152
|
if (pan.state == UIGestureRecognizerStateBegan) {
|
|
154
153
|
self.interactiveTransition = [UIPercentDrivenInteractiveTransition new];
|
|
155
154
|
//触发pop转场动画
|
|
@@ -158,22 +157,22 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
158
157
|
UIPercentDrivenInteractiveTransition *transition = self.interactiveTransition;
|
|
159
158
|
[transition updateInteractiveTransition:process];
|
|
160
159
|
} else if (pan.state == UIGestureRecognizerStateEnded
|
|
161
|
-
|
|
160
|
+
|| pan.state == UIGestureRecognizerStateCancelled) {
|
|
162
161
|
if (process > 0.33) {
|
|
163
|
-
[
|
|
162
|
+
[self.interactiveTransition finishInteractiveTransition];
|
|
164
163
|
} else {
|
|
165
|
-
[
|
|
164
|
+
[self.interactiveTransition cancelInteractiveTransition];
|
|
166
165
|
}
|
|
167
166
|
self.interactiveTransition = nil;
|
|
168
167
|
}
|
|
169
168
|
} else {
|
|
170
|
-
id<HBDNavigationTransitionProtocol> target = (id<HBDNavigationTransitionProtocol>)[nav superInteractivePopGestureRecognizer].delegate;
|
|
169
|
+
id <HBDNavigationTransitionProtocol> target = (id <HBDNavigationTransitionProtocol>) [nav superInteractivePopGestureRecognizer].delegate;
|
|
171
170
|
if ([target respondsToSelector:@selector(handleNavigationTransition:)]) {
|
|
172
171
|
[target handleNavigationTransition:pan];
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
|
-
|
|
175
|
+
|
|
177
176
|
// ----
|
|
178
177
|
if (coordinator) {
|
|
179
178
|
if (@available(iOS 11.0, *)) {
|
|
@@ -189,15 +188,15 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
192
|
-
|
|
191
|
+
|
|
193
192
|
adjustLayout(viewController);
|
|
194
|
-
|
|
195
|
-
if (self.
|
|
196
|
-
[self.
|
|
193
|
+
|
|
194
|
+
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:willShowViewController:animated:)]) {
|
|
195
|
+
[self.proxyDelegate navigationController:navigationController willShowViewController:viewController animated:animated];
|
|
197
196
|
}
|
|
198
|
-
|
|
197
|
+
|
|
199
198
|
HBDNavigationController *nav = self.nav;
|
|
200
|
-
id<UIViewControllerTransitionCoordinator> coordinator = nav.transitionCoordinator;
|
|
199
|
+
id <UIViewControllerTransitionCoordinator> coordinator = nav.transitionCoordinator;
|
|
201
200
|
if (coordinator) {
|
|
202
201
|
[self showViewController:viewController withCoordinator:coordinator];
|
|
203
202
|
} else {
|
|
@@ -213,17 +212,17 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
213
212
|
}
|
|
214
213
|
|
|
215
214
|
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
216
|
-
if (self.
|
|
217
|
-
[self.
|
|
215
|
+
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:didShowViewController:animated:)]) {
|
|
216
|
+
[self.proxyDelegate navigationController:navigationController didShowViewController:viewController animated:animated];
|
|
218
217
|
}
|
|
219
|
-
|
|
218
|
+
|
|
220
219
|
UIViewController *poppingVC = self.nav.poppingViewController;
|
|
221
220
|
if (poppingVC) {
|
|
222
221
|
if (poppingVC.didHideActionBlock) {
|
|
223
222
|
poppingVC.didHideActionBlock();
|
|
224
223
|
poppingVC.didHideActionBlock = nil;
|
|
225
224
|
}
|
|
226
|
-
|
|
225
|
+
|
|
227
226
|
if ([poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
228
227
|
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
229
228
|
}
|
|
@@ -233,9 +232,9 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
233
232
|
viewController.didShowActionBlock = nil;
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
|
-
|
|
235
|
+
|
|
237
236
|
self.nav.poppingViewController = nil;
|
|
238
|
-
|
|
237
|
+
|
|
239
238
|
if (!animated) {
|
|
240
239
|
[self.nav updateNavigationBarForViewController:viewController];
|
|
241
240
|
[self.nav clearFake];
|
|
@@ -243,38 +242,38 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
243
242
|
}
|
|
244
243
|
|
|
245
244
|
- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController {
|
|
246
|
-
if (self.
|
|
247
|
-
return [self.
|
|
245
|
+
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationControllerSupportedInterfaceOrientations:)]) {
|
|
246
|
+
return [self.proxyDelegate navigationControllerSupportedInterfaceOrientations:navigationController];
|
|
248
247
|
}
|
|
249
248
|
return UIInterfaceOrientationMaskPortrait;
|
|
250
249
|
}
|
|
251
250
|
|
|
252
|
-
- (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController
|
|
253
|
-
if (self.
|
|
254
|
-
return [self.
|
|
251
|
+
- (UIInterfaceOrientation)navigationControllerPreferredInterfaceOrientationForPresentation:(UINavigationController *)navigationController {
|
|
252
|
+
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationControllerPreferredInterfaceOrientationForPresentation:)]) {
|
|
253
|
+
return [self.proxyDelegate navigationControllerPreferredInterfaceOrientationForPresentation:navigationController];
|
|
255
254
|
}
|
|
256
255
|
return UIInterfaceOrientationPortrait;
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
- (nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
|
|
260
|
-
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>)
|
|
261
|
-
if (self.
|
|
262
|
-
return [self.
|
|
259
|
+
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>)animationController {
|
|
260
|
+
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:interactionControllerForAnimationController:)]) {
|
|
261
|
+
return [self.proxyDelegate navigationController:navigationController interactionControllerForAnimationController:animationController];
|
|
263
262
|
}
|
|
264
263
|
|
|
265
264
|
if ([animationController isKindOfClass:[HBDPopAnimation class]]) {
|
|
266
|
-
|
|
265
|
+
return self.interactiveTransition;
|
|
267
266
|
}
|
|
268
267
|
|
|
269
268
|
return nil;
|
|
270
269
|
}
|
|
271
270
|
|
|
272
271
|
- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
toViewController:(UIViewController *)toVC
|
|
276
|
-
if (self.
|
|
277
|
-
return [self.
|
|
272
|
+
animationControllerForOperation:(UINavigationControllerOperation)operation
|
|
273
|
+
fromViewController:(UIViewController *)fromVC
|
|
274
|
+
toViewController:(UIViewController *)toVC {
|
|
275
|
+
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:animationControllerForOperation:fromViewController:toViewController:)]) {
|
|
276
|
+
return [self.proxyDelegate navigationController:navigationController animationControllerForOperation:operation fromViewController:fromVC toViewController:toVC];
|
|
278
277
|
} else {
|
|
279
278
|
if (operation == UINavigationControllerOperationPush) {
|
|
280
279
|
if ([self shouldBetterTransitionWithViewController:toVC]) {
|
|
@@ -294,42 +293,42 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
294
293
|
- (BOOL)shouldBetterTransitionWithViewController:(UIViewController *)vc {
|
|
295
294
|
BOOL shouldBetter = NO;
|
|
296
295
|
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
297
|
-
HBDViewController *hbd = (HBDViewController *)vc;
|
|
296
|
+
HBDViewController *hbd = (HBDViewController *) vc;
|
|
298
297
|
shouldBetter = [hbd.options[@"passThroughTouches"] boolValue];
|
|
299
298
|
}
|
|
300
299
|
return shouldBetter;
|
|
301
300
|
}
|
|
302
301
|
|
|
303
|
-
- (void)showViewController:(UIViewController *
|
|
302
|
+
- (void)showViewController:(UIViewController *_Nonnull)viewController withCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator {
|
|
304
303
|
UIViewController *from = [coordinator viewControllerForKey:UITransitionContextFromViewControllerKey];
|
|
305
304
|
UIViewController *to = [coordinator viewControllerForKey:UITransitionContextToViewControllerKey];
|
|
306
|
-
|
|
305
|
+
|
|
307
306
|
if (@available(iOS 12.0, *)) {
|
|
308
307
|
// Fix a system bug https://github.com/listenzz/HBDNavigationBar/issues/35
|
|
309
308
|
[self resetButtonLabelInNavBar:self.nav.navigationBar];
|
|
310
309
|
}
|
|
311
|
-
|
|
310
|
+
|
|
312
311
|
if (self.nav.poppingViewController) {
|
|
313
312
|
// Inspired by QMUI
|
|
314
313
|
UILabel *backButtonLabel = self.nav.navigationBar.backButtonLabel;
|
|
315
314
|
if (backButtonLabel) {
|
|
316
315
|
backButtonLabel.hbd_specifiedTextColor = backButtonLabel.textColor;
|
|
317
316
|
}
|
|
318
|
-
|
|
319
|
-
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>
|
|
320
|
-
|
|
321
|
-
}
|
|
317
|
+
|
|
318
|
+
[coordinator animateAlongsideTransition:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
319
|
+
|
|
320
|
+
} completion:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
322
321
|
backButtonLabel.hbd_specifiedTextColor = nil;
|
|
323
322
|
}];
|
|
324
323
|
}
|
|
325
|
-
|
|
324
|
+
|
|
326
325
|
[self.nav updateNavigationBarStyleForViewController:viewController];
|
|
327
326
|
|
|
328
|
-
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
327
|
+
[coordinator animateAlongsideTransition:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
329
328
|
BOOL shouldFake = [self shouldShowFakeBarFrom:from to:to viewController:viewController];
|
|
330
329
|
if (shouldFake) {
|
|
331
330
|
// title attributes, button tint color, barStyle
|
|
332
|
-
[self.nav
|
|
331
|
+
[self.nav updateNavigationBarTintColorForViewController:viewController];
|
|
333
332
|
// background alpha, background color, shadow image alpha
|
|
334
333
|
[self.nav showFakeBarFrom:from to:to];
|
|
335
334
|
} else {
|
|
@@ -341,14 +340,13 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
341
340
|
}
|
|
342
341
|
}
|
|
343
342
|
}
|
|
344
|
-
}
|
|
343
|
+
} completion:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
345
344
|
self.nav.poppingViewController = nil;
|
|
346
|
-
|
|
347
345
|
if (@available(iOS 13.0, *)) {
|
|
348
346
|
self.nav.navigationBar.scrollEdgeAppearance.backgroundColor = UIColor.clearColor;
|
|
349
347
|
self.nav.navigationBar.standardAppearance.backgroundColor = UIColor.clearColor;
|
|
350
348
|
}
|
|
351
|
-
|
|
349
|
+
|
|
352
350
|
if (context.isCancelled) {
|
|
353
351
|
if (to == viewController) {
|
|
354
352
|
[self.nav updateNavigationBarForViewController:from];
|
|
@@ -362,7 +360,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
362
360
|
poppingVC.didHideActionBlock();
|
|
363
361
|
poppingVC.didHideActionBlock = nil;
|
|
364
362
|
}
|
|
365
|
-
|
|
363
|
+
|
|
366
364
|
if ([poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
367
365
|
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
368
366
|
}
|
|
@@ -373,7 +371,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
373
371
|
}
|
|
374
372
|
}
|
|
375
373
|
}
|
|
376
|
-
|
|
374
|
+
|
|
377
375
|
if (to == viewController) {
|
|
378
376
|
[self.nav clearFake];
|
|
379
377
|
}
|
|
@@ -403,19 +401,19 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
403
401
|
}
|
|
404
402
|
}
|
|
405
403
|
|
|
406
|
-
- (BOOL)shouldShowFakeBarFrom:(UIViewController *)from to:(UIViewController *)to viewController:(UIViewController *
|
|
407
|
-
if ([HBDGarden globalStyle].
|
|
404
|
+
- (BOOL)shouldShowFakeBarFrom:(UIViewController *)from to:(UIViewController *)to viewController:(UIViewController *_Nonnull)viewController {
|
|
405
|
+
if ([HBDGarden globalStyle].alwaysSplitNavigationBarTransition && to == viewController) {
|
|
408
406
|
return YES;
|
|
409
407
|
}
|
|
410
|
-
|
|
408
|
+
|
|
411
409
|
if (to != viewController) {
|
|
412
410
|
return NO;
|
|
413
411
|
}
|
|
414
|
-
|
|
412
|
+
|
|
415
413
|
if (![from.hbd_barTintColor.description isEqual:to.hbd_barTintColor.description]) {
|
|
416
414
|
return YES;
|
|
417
415
|
}
|
|
418
|
-
|
|
416
|
+
|
|
419
417
|
return from.hbd_barAlpha < 1.0 || to.hbd_barAlpha < 1.0;
|
|
420
418
|
}
|
|
421
419
|
|
|
@@ -432,7 +430,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
432
430
|
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController {
|
|
433
431
|
if (self = [super initWithNavigationBarClass:[HBDNavigationBar class] toolbarClass:nil]) {
|
|
434
432
|
if ([rootViewController isKindOfClass:[HBDViewController class]]) {
|
|
435
|
-
HBDViewController *root = (HBDViewController *)rootViewController;
|
|
433
|
+
HBDViewController *root = (HBDViewController *) rootViewController;
|
|
436
434
|
self.tabBarItem = root.tabBarItem;
|
|
437
435
|
root.tabBarItem = nil;
|
|
438
436
|
NSDictionary *tabItem = root.options[@"tabItem"];
|
|
@@ -442,7 +440,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
442
440
|
self.hidesBottomBarWhenPushed = YES;
|
|
443
441
|
}
|
|
444
442
|
}
|
|
445
|
-
self.viewControllers = @[
|
|
443
|
+
self.viewControllers = @[rootViewController];
|
|
446
444
|
}
|
|
447
445
|
return self;
|
|
448
446
|
}
|
|
@@ -472,7 +470,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
472
470
|
self.definesPresentationContext = NO;
|
|
473
471
|
[self.navigationBar setTranslucent:YES];
|
|
474
472
|
[self.navigationBar setShadowImage:[UINavigationBar appearance].shadowImage];
|
|
475
|
-
|
|
473
|
+
|
|
476
474
|
if (@available(iOS 13.0, *)) {
|
|
477
475
|
UINavigationBarAppearance *scrollEdgeAppearance = [[UINavigationBarAppearance alloc] init];
|
|
478
476
|
[scrollEdgeAppearance configureWithTransparentBackground];
|
|
@@ -482,23 +480,23 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
482
480
|
self.navigationBar.scrollEdgeAppearance = scrollEdgeAppearance;
|
|
483
481
|
self.navigationBar.standardAppearance = [scrollEdgeAppearance copy];
|
|
484
482
|
}
|
|
485
|
-
|
|
483
|
+
|
|
486
484
|
self.navigationDelegate = [[HBDNavigationControllerDelegate alloc] initWithNavigationController:self];
|
|
487
|
-
self.navigationDelegate.
|
|
485
|
+
self.navigationDelegate.proxyDelegate = self.delegate;
|
|
488
486
|
self.delegate = self.navigationDelegate;
|
|
489
487
|
}
|
|
490
488
|
|
|
491
|
-
- (void)setDelegate:(id<UINavigationControllerDelegate>)delegate {
|
|
489
|
+
- (void)setDelegate:(id <UINavigationControllerDelegate>)delegate {
|
|
492
490
|
if ([delegate isKindOfClass:[HBDNavigationControllerDelegate class]] || !self.navigationDelegate) {
|
|
493
491
|
[super setDelegate:delegate];
|
|
494
492
|
} else {
|
|
495
|
-
self.navigationDelegate.
|
|
493
|
+
self.navigationDelegate.proxyDelegate = delegate;
|
|
496
494
|
}
|
|
497
495
|
}
|
|
498
496
|
|
|
499
497
|
- (void)viewWillLayoutSubviews {
|
|
500
498
|
[super viewWillLayoutSubviews];
|
|
501
|
-
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
499
|
+
id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
502
500
|
if (!coordinator) {
|
|
503
501
|
[self updateNavigationBarForViewController:self.topViewController];
|
|
504
502
|
}
|
|
@@ -509,19 +507,19 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
509
507
|
if ([HBDUtils isIphoneX]) {
|
|
510
508
|
return;
|
|
511
509
|
}
|
|
512
|
-
|
|
510
|
+
|
|
513
511
|
if (@available(iOS 13.0, *)) {
|
|
514
512
|
UIEdgeInsets safeAreaInsets = self.view.safeAreaInsets;
|
|
515
513
|
UIEdgeInsets additionalInsets = self.additionalSafeAreaInsets;
|
|
516
|
-
|
|
514
|
+
|
|
517
515
|
// RCTLogInfo(@"[Navigator] safeAreaInsets:%@, additionalInsets:%@", NSStringFromUIEdgeInsets(safeAreaInsets), NSStringFromUIEdgeInsets(additionalInsets));
|
|
518
|
-
|
|
516
|
+
|
|
519
517
|
BOOL statusBarHidden = [UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarHidden;
|
|
520
|
-
|
|
518
|
+
|
|
521
519
|
if (statusBarHidden && safeAreaInsets.top == 0) {
|
|
522
520
|
self.additionalSafeAreaInsets = UIEdgeInsetsMake(20, additionalInsets.left, additionalInsets.bottom, additionalInsets.right);
|
|
523
521
|
}
|
|
524
|
-
|
|
522
|
+
|
|
525
523
|
if (!statusBarHidden && safeAreaInsets.top == 40) {
|
|
526
524
|
self.additionalSafeAreaInsets = UIEdgeInsetsMake(-20, additionalInsets.left, additionalInsets.bottom, additionalInsets.right);
|
|
527
525
|
}
|
|
@@ -544,11 +542,11 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
544
542
|
self.topViewController.didHideActionBlock();
|
|
545
543
|
self.topViewController.didHideActionBlock = nil;
|
|
546
544
|
}
|
|
547
|
-
|
|
545
|
+
|
|
548
546
|
if (self.childViewControllers.count > 1) {
|
|
549
547
|
self.poppingViewController = self.topViewController;
|
|
550
548
|
}
|
|
551
|
-
|
|
549
|
+
|
|
552
550
|
UIViewController *vc = [super popViewControllerAnimated:animated];
|
|
553
551
|
// vc != self.topViewController
|
|
554
552
|
[self fixClickBackIssue];
|
|
@@ -560,11 +558,11 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
560
558
|
self.topViewController.didHideActionBlock();
|
|
561
559
|
self.topViewController.didHideActionBlock = nil;
|
|
562
560
|
}
|
|
563
|
-
|
|
561
|
+
|
|
564
562
|
if (self.childViewControllers.count > 1) {
|
|
565
563
|
self.poppingViewController = self.topViewController;
|
|
566
564
|
}
|
|
567
|
-
|
|
565
|
+
|
|
568
566
|
NSArray *array = [super popToViewController:viewController animated:animated];
|
|
569
567
|
[self fixClickBackIssue];
|
|
570
568
|
return array;
|
|
@@ -576,11 +574,11 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
576
574
|
self.topViewController.didHideActionBlock();
|
|
577
575
|
self.topViewController.didHideActionBlock = nil;
|
|
578
576
|
}
|
|
579
|
-
|
|
577
|
+
|
|
580
578
|
if (self.childViewControllers.count > 1) {
|
|
581
579
|
self.poppingViewController = self.topViewController;
|
|
582
580
|
}
|
|
583
|
-
|
|
581
|
+
|
|
584
582
|
NSArray *array = [super popToRootViewControllerAnimated:animated];
|
|
585
583
|
[self fixClickBackIssue];
|
|
586
584
|
return array;
|
|
@@ -590,10 +588,10 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
590
588
|
if (@available(iOS 13.0, *)) {
|
|
591
589
|
return;
|
|
592
590
|
}
|
|
593
|
-
|
|
591
|
+
|
|
594
592
|
if (@available(iOS 11.0, *)) {
|
|
595
593
|
// fix:ios 11,12,当前后两个页面的 barStyle 不一样时,点击返回按钮返回,前一个页面的标题颜色响应迟缓或不响应
|
|
596
|
-
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
594
|
+
id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
597
595
|
if (!(coordinator && coordinator.interactive)) {
|
|
598
596
|
self.navigationBar.barStyle = self.topViewController.hbd_barStyle;
|
|
599
597
|
self.navigationBar.titleTextAttributes = self.topViewController.hbd_titleTextAttributes;
|
|
@@ -606,7 +604,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
606
604
|
// empty
|
|
607
605
|
} else {
|
|
608
606
|
// Workaround for >= iOS7.1. Thanks to @boliva - http://stackoverflow.com/posts/comments/34452906
|
|
609
|
-
[navBar.subviews enumerateObjectsUsingBlock:^(__kindof UIView *
|
|
607
|
+
[navBar.subviews enumerateObjectsUsingBlock:^(__kindof UIView *_Nonnull subview, NSUInteger idx, BOOL *_Nonnull stop) {
|
|
610
608
|
if (subview.alpha < 1.0) {
|
|
611
609
|
[UIView animateWithDuration:.25 animations:^{
|
|
612
610
|
subview.alpha = 1.0;
|
|
@@ -620,14 +618,14 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
620
618
|
[self updateNavigationBarStyleForViewController:vc];
|
|
621
619
|
[self updateNavigationBarAlphaForViewController:vc];
|
|
622
620
|
[self updateNavigationBarBackgroundForViewController:vc];
|
|
623
|
-
[self
|
|
621
|
+
[self updateNavigationBarTintColorForViewController:vc];
|
|
624
622
|
}
|
|
625
623
|
|
|
626
624
|
- (void)updateNavigationBarStyleForViewController:(UIViewController *)vc {
|
|
627
625
|
self.navigationBar.barStyle = vc.hbd_barStyle;
|
|
628
626
|
}
|
|
629
627
|
|
|
630
|
-
- (void)
|
|
628
|
+
- (void)updateNavigationBarTintColorForViewController:(UIViewController *)vc {
|
|
631
629
|
self.navigationBar.tintColor = vc.hbd_tintColor;
|
|
632
630
|
self.navigationBar.titleTextAttributes = vc.hbd_titleTextAttributes;
|
|
633
631
|
if (@available(iOS 13.0, *)) {
|
|
@@ -639,7 +637,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
639
637
|
- (void)updateNavigationBarAlphaForViewController:(UIViewController *)vc {
|
|
640
638
|
self.navigationBar.fakeView.alpha = vc.hbd_barAlpha;
|
|
641
639
|
self.navigationBar.shadowImageView.alpha = vc.hbd_barShadowAlpha;
|
|
642
|
-
|
|
640
|
+
|
|
643
641
|
if (vc.hbd_barAlpha == 0) {
|
|
644
642
|
self.navigationBar.hbd_backgroundView.layer.mask = [CALayer new];
|
|
645
643
|
} else {
|
|
@@ -651,7 +649,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
651
649
|
self.navigationBar.barTintColor = vc.hbd_barTintColor;
|
|
652
650
|
}
|
|
653
651
|
|
|
654
|
-
- (void)showFakeBarFrom:(UIViewController *)from to:(UIViewController *
|
|
652
|
+
- (void)showFakeBarFrom:(UIViewController *)from to:(UIViewController *_Nonnull)to {
|
|
655
653
|
[UIView setAnimationsEnabled:NO];
|
|
656
654
|
self.navigationBar.fakeView.alpha = 0;
|
|
657
655
|
self.navigationBar.shadowImageView.alpha = 0;
|
|
@@ -673,7 +671,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
673
671
|
[from.view addSubview:self.fromFakeShadow];
|
|
674
672
|
}
|
|
675
673
|
|
|
676
|
-
- (void)showFakeBarTo:(UIViewController *
|
|
674
|
+
- (void)showFakeBarTo:(UIViewController *_Nonnull)to {
|
|
677
675
|
self.toFakeBar.subviews.lastObject.backgroundColor = to.hbd_barTintColor;
|
|
678
676
|
self.toFakeBar.alpha = to.hbd_barAlpha;
|
|
679
677
|
self.toFakeBar.frame = [self fakeBarFrameForViewController:to];
|
|
@@ -734,9 +732,9 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
734
732
|
|
|
735
733
|
// fix issue for pushed to UIViewController whose root view is UIScrollView.
|
|
736
734
|
if ([vc.view isKindOfClass:[UIScrollView class]]) {
|
|
737
|
-
UIScrollView *
|
|
738
|
-
|
|
739
|
-
if (
|
|
735
|
+
UIScrollView *scrollView = (UIScrollView *) vc.view;
|
|
736
|
+
scrollView.clipsToBounds = NO;
|
|
737
|
+
if (scrollView.contentOffset.y == 0) {
|
|
740
738
|
frame.origin.y = -frame.size.height;
|
|
741
739
|
}
|
|
742
740
|
}
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
|
|
17
17
|
UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
|
|
18
18
|
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
[[transitionContext containerView] insertSubview:toView belowSubview:fromView];
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
toView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -transitionContext.containerView.bounds.size.width, 0);
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
|
|
25
25
|
toView.transform = CGAffineTransformIdentity;
|
|
26
26
|
fromView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, transitionContext.containerView.bounds.size.width, 0);
|
|
27
|
-
}
|
|
27
|
+
} completion:^(BOOL finished) {
|
|
28
28
|
toView.transform = CGAffineTransformIdentity;
|
|
29
29
|
fromView.transform = CGAffineTransformIdentity;
|
|
30
30
|
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
|
|
19
19
|
[transitionContext.containerView addSubview:toView];
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
toView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, transitionContext.containerView.bounds.size.width, 0);
|
|
22
22
|
|
|
23
23
|
UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
|
|
26
26
|
fromView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -transitionContext.containerView.bounds.size.width, 0);
|
|
27
27
|
toView.transform = CGAffineTransformIdentity;
|
|
28
|
-
}
|
|
28
|
+
} completion:^(BOOL finished) {
|
|
29
29
|
fromView.transform = CGAffineTransformIdentity;
|
|
30
30
|
toView.transform = CGAffineTransformIdentity;
|
|
31
31
|
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
|