hybrid-navigation 2.12.3 → 2.13.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +6 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +29 -30
- package/android/src/main/java/com/reactnative/hybridnavigation/Navigator.java +2 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +4 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +24 -33
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +22 -22
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +8 -8
- package/ios/HybridNavigation/GlobalStyle.h +0 -8
- package/ios/HybridNavigation/GlobalStyle.m +2 -8
- package/ios/HybridNavigation/HBDUtils.h +5 -13
- package/ios/HybridNavigation/HBDUtils.m +2 -12
- package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.m +91 -67
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.h +2 -7
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +28 -26
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +127 -99
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +199 -142
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.m +144 -124
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDEventEmitter.h +1 -11
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDEventEmitter.m +4 -10
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +6 -0
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +161 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.h +6 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +237 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigator.h +20 -0
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDReactBridgeManager.h +12 -20
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDReactBridgeManager.m +91 -91
- package/ios/HybridNavigation/View/HBDBarButtonItem.h +0 -8
- package/ios/HybridNavigation/View/HBDBarButtonItem.m +1 -11
- package/ios/HybridNavigation/View/HBDNavigationBar.h +0 -8
- package/ios/HybridNavigation/View/HBDNavigationBar.m +13 -20
- package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -8
- package/ios/HybridNavigation/View/HBDReactTabBar.m +1 -8
- package/ios/HybridNavigation/View/HBDRootView.h +3 -10
- package/ios/HybridNavigation/View/HBDRootView.m +14 -25
- package/ios/HybridNavigation/View/HBDTitleView.h +0 -9
- package/ios/HybridNavigation/View/HBDTitleView.m +1 -26
- package/ios/HybridNavigation/View/UITabBar+Badge.h +0 -8
- package/ios/HybridNavigation/View/UITabBar+Badge.m +0 -7
- package/ios/HybridNavigation/ViewController/HBDDrawerController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDDrawerController.m +2 -9
- package/ios/HybridNavigation/ViewController/HBDFadeAnimation.h +9 -0
- package/ios/HybridNavigation/ViewController/HBDFadeAnimation.m +22 -0
- package/ios/HybridNavigation/ViewController/HBDNavigationController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +17 -120
- package/ios/HybridNavigation/ViewController/HBDPopAnimation.h +0 -7
- package/ios/HybridNavigation/ViewController/HBDPopAnimation.m +1 -8
- package/ios/HybridNavigation/ViewController/HBDPushAnimation.h +0 -7
- package/ios/HybridNavigation/ViewController/HBDPushAnimation.m +1 -8
- package/ios/HybridNavigation/ViewController/HBDReactViewController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDReactViewController.m +60 -27
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +15 -11
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.m +23 -33
- package/ios/HybridNavigation/ViewController/HBDViewController.h +1 -8
- package/ios/HybridNavigation/ViewController/HBDViewController.m +6 -23
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.h +0 -8
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -8
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +2 -16
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +32 -46
- package/lib/Garden.d.ts +3 -0
- package/lib/Garden.js +12 -1
- package/lib/NavigationModule.d.ts +0 -2
- package/lib/NavigationModule.js +0 -3
- package/lib/Navigator.d.ts +25 -25
- package/lib/Navigator.js +116 -73
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +4 -6
- package/src/Garden.ts +15 -1
- package/src/NavigationModule.ts +0 -4
- package/src/Navigator.ts +96 -58
- package/src/index.ts +1 -1
- package/ios/HybridNavigation/Bridge/HBDGardenModule.h +0 -14
- package/ios/HybridNavigation/Bridge/HBDGardenModule.m +0 -155
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.h +0 -15
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +0 -272
- package/ios/HybridNavigation/Navigator/HBDNavigator.h +0 -26
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDBarButtonItem.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/26.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "HBDBarButtonItem.h"
|
|
10
2
|
|
|
11
3
|
@implementation HBDBarButton
|
|
@@ -41,9 +33,7 @@
|
|
|
41
33
|
|
|
42
34
|
- (instancetype)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style {
|
|
43
35
|
HBDBarButton *button = [HBDBarButton buttonWithType:UIButtonTypeSystem];
|
|
44
|
-
|
|
45
|
-
button.translatesAutoresizingMaskIntoConstraints = NO;
|
|
46
|
-
}
|
|
36
|
+
button.translatesAutoresizingMaskIntoConstraints = NO;
|
|
47
37
|
[button setFrame:CGRectMake(0, 0, 32, 32)];
|
|
48
38
|
[button setImage:image forState:UIControlStateNormal];
|
|
49
39
|
[button addTarget:self action:@selector(didButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDNavigationBar.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/3/6.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "HBDNavigationBar.h"
|
|
2
|
+
|
|
10
3
|
#import "HBDUtils.h"
|
|
11
4
|
|
|
5
|
+
#define hairlineWidth (1.f/[UIScreen mainScreen].scale)
|
|
6
|
+
|
|
12
7
|
@interface HBDNavigationBar ()
|
|
13
8
|
|
|
14
9
|
@property(nonatomic, strong, readwrite) UIImageView *fakeShadowView;
|
|
@@ -60,13 +55,13 @@
|
|
|
60
55
|
- (void)layoutSubviews {
|
|
61
56
|
[super layoutSubviews];
|
|
62
57
|
self.fakeBackgroundView.frame = self.fakeBackgroundView.superview.bounds;
|
|
63
|
-
self.fakeShadowView.frame = CGRectMake(0, CGRectGetHeight(self.fakeShadowView.superview.bounds), CGRectGetWidth(self.fakeShadowView.superview.bounds),
|
|
58
|
+
self.fakeShadowView.frame = CGRectMake(0, CGRectGetHeight(self.fakeShadowView.superview.bounds) - hairlineWidth, CGRectGetWidth(self.fakeShadowView.superview.bounds), hairlineWidth);
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
- (void)setBarTintColor:(UIColor *)barTintColor {
|
|
67
62
|
[super setBarTintColor:barTintColor];
|
|
68
63
|
self.fakeBackgroundView.backgroundColor = barTintColor;
|
|
69
|
-
[self
|
|
64
|
+
[self makesureFakeView];
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
- (UIView *)fakeBackgroundView {
|
|
@@ -75,7 +70,6 @@
|
|
|
75
70
|
_fakeBackgroundView = [[UIView alloc] init];
|
|
76
71
|
_fakeBackgroundView.userInteractionEnabled = NO;
|
|
77
72
|
_fakeBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
78
|
-
[[self.subviews firstObject] insertSubview:_fakeBackgroundView atIndex:0];
|
|
79
73
|
}
|
|
80
74
|
return _fakeBackgroundView;
|
|
81
75
|
}
|
|
@@ -96,6 +90,7 @@
|
|
|
96
90
|
} else {
|
|
97
91
|
self.fakeShadowView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:77.0 / 255];
|
|
98
92
|
}
|
|
93
|
+
|
|
99
94
|
}
|
|
100
95
|
|
|
101
96
|
- (UIImageView *)fakeShadowView {
|
|
@@ -104,27 +99,26 @@
|
|
|
104
99
|
_fakeShadowView = [[UIImageView alloc] init];
|
|
105
100
|
_fakeShadowView.userInteractionEnabled = NO;
|
|
106
101
|
_fakeShadowView.contentScaleFactor = 1;
|
|
107
|
-
|
|
102
|
+
_fakeShadowView.layer.allowsEdgeAntialiasing = YES;
|
|
108
103
|
}
|
|
109
104
|
return _fakeShadowView;
|
|
110
105
|
}
|
|
111
106
|
|
|
112
|
-
- (void)
|
|
107
|
+
- (void)makesureFakeView {
|
|
113
108
|
[UIView setAnimationsEnabled:NO];
|
|
114
109
|
if (!self.fakeBackgroundView.superview) {
|
|
115
|
-
[[self.subviews firstObject] insertSubview:
|
|
110
|
+
[[self.subviews firstObject] insertSubview:self.fakeBackgroundView atIndex:0];
|
|
116
111
|
self.fakeBackgroundView.frame = self.fakeBackgroundView.superview.bounds;
|
|
117
112
|
}
|
|
118
113
|
|
|
119
114
|
if (!self.fakeShadowView.superview) {
|
|
120
|
-
[[self.subviews firstObject] insertSubview:
|
|
121
|
-
self.fakeShadowView.frame = CGRectMake(0, CGRectGetHeight(self.fakeShadowView.superview.bounds), CGRectGetWidth(self.fakeShadowView.superview.bounds),
|
|
115
|
+
[[self.subviews firstObject] insertSubview:self.fakeShadowView aboveSubview:self.fakeBackgroundView];
|
|
116
|
+
self.fakeShadowView.frame = CGRectMake(0, CGRectGetHeight(self.fakeShadowView.superview.bounds) - hairlineWidth, CGRectGetWidth(self.fakeShadowView.superview.bounds), hairlineWidth);
|
|
122
117
|
}
|
|
123
118
|
[UIView setAnimationsEnabled:YES];
|
|
124
119
|
}
|
|
125
120
|
|
|
126
121
|
- (UILabel *)backButtonLabel {
|
|
127
|
-
if (@available(iOS 11, *)); else return nil;
|
|
128
122
|
UIView *navigationBarContentView = [self valueForKeyPath:@"visualProvider.contentView"];
|
|
129
123
|
__block UILabel *backButtonLabel = nil;
|
|
130
124
|
[navigationBarContentView.subviews enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(__kindof UIView *_Nonnull subview, NSUInteger idx, BOOL *_Nonnull stop) {
|
|
@@ -150,11 +144,10 @@
|
|
|
150
144
|
}
|
|
151
145
|
|
|
152
146
|
+ (void)load {
|
|
153
|
-
if (@available(iOS 11, *)); else return;
|
|
154
147
|
static dispatch_once_t onceToken;
|
|
155
148
|
dispatch_once(&onceToken, ^{
|
|
156
|
-
Class
|
|
157
|
-
hbd_exchangeImplementations(
|
|
149
|
+
Class clazz = [self class];
|
|
150
|
+
hbd_exchangeImplementations(clazz, @selector(setAttributedText:), @selector(hbd_setAttributedText:));
|
|
158
151
|
});
|
|
159
152
|
}
|
|
160
153
|
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDRootView.h
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/5/31.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <UIKit/UIKit.h>
|
|
10
1
|
#import <React/RCTRootView.h>
|
|
11
2
|
|
|
12
|
-
@interface HBDRootView :
|
|
3
|
+
@interface HBDRootView : UIView
|
|
4
|
+
|
|
5
|
+
- (instancetype)initWithRootView:(RCTRootView *)rootView;
|
|
13
6
|
|
|
14
7
|
@end
|
|
@@ -1,36 +1,25 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDRootView.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/5/31.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "HBDRootView.h"
|
|
10
2
|
|
|
3
|
+
@interface HBDRootView ()
|
|
4
|
+
|
|
5
|
+
@property (nonatomic, strong, readonly) RCTRootView *rootView;
|
|
6
|
+
|
|
7
|
+
@end
|
|
8
|
+
|
|
11
9
|
@implementation HBDRootView
|
|
12
10
|
|
|
13
|
-
- (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
UIView *view = self.contentView.subviews.firstObject;
|
|
17
|
-
while (view) {
|
|
18
|
-
if (view == hitView) {
|
|
19
|
-
if (CGRectEqualToRect(view.frame, self.bounds)) {
|
|
20
|
-
return nil;
|
|
21
|
-
} else {
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
view = view.subviews.firstObject;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
11
|
+
- (instancetype)initWithRootView:(RCTRootView *)rootView {
|
|
12
|
+
if (self = [super init]) {
|
|
13
|
+
_rootView = rootView;
|
|
28
14
|
}
|
|
15
|
+
return self;
|
|
16
|
+
}
|
|
29
17
|
|
|
30
|
-
|
|
18
|
+
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
19
|
+
UIView *hitView = [super hitTest:point withEvent:event];
|
|
20
|
+
if (self.rootView.passThroughTouches && hitView == self) {
|
|
31
21
|
return nil;
|
|
32
22
|
}
|
|
33
|
-
|
|
34
23
|
return hitView;
|
|
35
24
|
}
|
|
36
25
|
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDTitleView.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/3/6.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "HBDTitleView.h"
|
|
2
|
+
|
|
10
3
|
#import <React/RCTRootViewDelegate.h>
|
|
11
4
|
|
|
12
5
|
@interface HBDTitleView () <RCTRootViewDelegate>
|
|
@@ -57,24 +50,6 @@
|
|
|
57
50
|
self.bounds = CGRectMake(0, 0, rootView.intrinsicContentSize.width, rootView.intrinsicContentSize.height);
|
|
58
51
|
self.rootView.frame = CGRectMake(0, 0, rootView.intrinsicContentSize.width, rootView.intrinsicContentSize.height);
|
|
59
52
|
self.center = center;
|
|
60
|
-
|
|
61
|
-
// 修正版本在 10.0 的情况
|
|
62
|
-
NSString *version = [UIDevice currentDevice].systemVersion;
|
|
63
|
-
if (version.doubleValue < 11.0) {
|
|
64
|
-
UINavigationBar *bar = [self navigationBarInView:self];
|
|
65
|
-
if (bar) {
|
|
66
|
-
for (UIView *subview in bar.subviews) {
|
|
67
|
-
NSString *viewName = [[[subview classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
68
|
-
if ([viewName isEqualToString:@"UINavigationItemButtonView"]) {
|
|
69
|
-
CGFloat dx = subview.frame.origin.x + subview.frame.size.width + self.bounds.size.width / 2 + 6 - center.x;
|
|
70
|
-
if (dx > 0) {
|
|
71
|
-
self.center = CGPointMake(center.x + dx, center.y);
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
53
|
}
|
|
79
54
|
|
|
80
55
|
- (UINavigationBar *)navigationBarInView:(UIView *)view {
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDDrawerController.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2018/1/25.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "HBDDrawerController.h"
|
|
2
|
+
|
|
10
3
|
#import "HBDUtils.h"
|
|
11
4
|
#import "UIViewController+HBD.h"
|
|
12
5
|
|
|
@@ -139,7 +132,7 @@
|
|
|
139
132
|
[self dismissMenuView];
|
|
140
133
|
}
|
|
141
134
|
}
|
|
142
|
-
|
|
135
|
+
|
|
143
136
|
- (void)toggleMenu {
|
|
144
137
|
if (self.isMenuOpened) {
|
|
145
138
|
[self closeMenu];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#import "HBDFadeAnimation.h"
|
|
2
|
+
|
|
3
|
+
@implementation HBDFadeAnimation
|
|
4
|
+
|
|
5
|
+
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
|
|
6
|
+
return 0.15f;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
|
|
10
|
+
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
|
|
11
|
+
|
|
12
|
+
[[transitionContext containerView] addSubview:toView];
|
|
13
|
+
toView.alpha = 0;
|
|
14
|
+
|
|
15
|
+
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
|
|
16
|
+
toView.alpha = 1;
|
|
17
|
+
} completion:^(BOOL finished) {
|
|
18
|
+
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
|
|
19
|
+
}];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@end
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDNavigationController.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/12/16.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "HBDNavigationController.h"
|
|
2
|
+
|
|
10
3
|
#import "HBDViewController.h"
|
|
11
4
|
#import "HBDNavigationBar.h"
|
|
12
5
|
#import "HBDUtils.h"
|
|
13
|
-
#import "GlobalStyle.h"
|
|
14
6
|
#import "HBDPushAnimation.h"
|
|
15
7
|
#import "HBDPopAnimation.h"
|
|
8
|
+
#import "GlobalStyle.h"
|
|
9
|
+
|
|
16
10
|
#import <React/RCTLog.h>
|
|
17
11
|
|
|
12
|
+
#define hairlineWidth (1.f/[UIScreen mainScreen].scale)
|
|
13
|
+
|
|
18
14
|
UIColor *blendColor(UIColor *from, UIColor *to, CGFloat percent) {
|
|
19
15
|
CGFloat fromRed = 0;
|
|
20
16
|
CGFloat fromGreen = 0;
|
|
@@ -35,28 +31,6 @@ UIColor *blendColor(UIColor *from, UIColor *to, CGFloat percent) {
|
|
|
35
31
|
return [UIColor colorWithRed:newRed green:newGreen blue:newBlue alpha:newAlpha];
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
void adjustLayout(UIViewController *vc) {
|
|
39
|
-
if (vc.hbd_extendedLayoutDidSet) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
vc.hbd_extendedLayoutDidSet = YES;
|
|
43
|
-
|
|
44
|
-
BOOL isTranslucent = vc.hbd_barHidden || vc.hbd_barAlpha < 1.0 || colorHasAlphaComponent(vc.hbd_barTintColor);
|
|
45
|
-
if (isTranslucent || vc.extendedLayoutIncludesOpaqueBars) {
|
|
46
|
-
vc.edgesForExtendedLayout |= UIRectEdgeTop;
|
|
47
|
-
} else {
|
|
48
|
-
vc.edgesForExtendedLayout &= ~UIRectEdgeTop;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (vc.hbd_barHidden) {
|
|
52
|
-
if (@available(iOS 11.0, *)) {
|
|
53
|
-
UIEdgeInsets insets = vc.additionalSafeAreaInsets;
|
|
54
|
-
CGFloat height = vc.navigationController.navigationBar.bounds.size.height;
|
|
55
|
-
vc.additionalSafeAreaInsets = UIEdgeInsetsMake(-height + insets.top, insets.left, insets.bottom, insets.right);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
34
|
void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
61
35
|
NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
62
36
|
NSLog(@"%@%@ %@", prefix, viewName, NSStringFromCGRect(view.frame));
|
|
@@ -99,8 +73,6 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
99
73
|
|
|
100
74
|
- (void)clearFake;
|
|
101
75
|
|
|
102
|
-
- (void)resetSubviewsInNavBar:(UINavigationBar *)navBar;
|
|
103
|
-
|
|
104
76
|
- (UIGestureRecognizer *)superInteractivePopGestureRecognizer;
|
|
105
77
|
|
|
106
78
|
@end
|
|
@@ -134,7 +106,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
134
106
|
return NO;
|
|
135
107
|
}
|
|
136
108
|
|
|
137
|
-
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
|
|
109
|
+
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
|
138
110
|
if (gestureRecognizer == self.nav.interactivePopGestureRecognizer) {
|
|
139
111
|
return YES;
|
|
140
112
|
}
|
|
@@ -173,25 +145,10 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
173
145
|
}
|
|
174
146
|
}
|
|
175
147
|
}
|
|
176
|
-
|
|
177
|
-
// ----
|
|
178
|
-
if (coordinator) {
|
|
179
|
-
if (@available(iOS 11.0, *)) {
|
|
180
|
-
// empty
|
|
181
|
-
} else {
|
|
182
|
-
UIViewController *from = [coordinator viewControllerForKey:UITransitionContextFromViewControllerKey];
|
|
183
|
-
UIViewController *to = [coordinator viewControllerForKey:UITransitionContextToViewControllerKey];
|
|
184
|
-
if (pan.state == UIGestureRecognizerStateBegan || pan.state == UIGestureRecognizerStateChanged) {
|
|
185
|
-
nav.navigationBar.tintColor = blendColor(from.hbd_tintColor, to.hbd_tintColor, coordinator.percentComplete);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
148
|
}
|
|
190
149
|
|
|
191
150
|
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
192
151
|
|
|
193
|
-
adjustLayout(viewController);
|
|
194
|
-
|
|
195
152
|
if (self.proxyDelegate && [self.proxyDelegate respondsToSelector:@selector(navigationController:willShowViewController:animated:)]) {
|
|
196
153
|
[self.proxyDelegate navigationController:navigationController willShowViewController:viewController animated:animated];
|
|
197
154
|
}
|
|
@@ -218,20 +175,8 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
218
175
|
}
|
|
219
176
|
|
|
220
177
|
UIViewController *poppingVC = self.nav.poppingViewController;
|
|
221
|
-
if (poppingVC) {
|
|
222
|
-
|
|
223
|
-
poppingVC.didHideActionBlock();
|
|
224
|
-
poppingVC.didHideActionBlock = nil;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if ([poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
228
|
-
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
229
|
-
}
|
|
230
|
-
} else {
|
|
231
|
-
if (viewController.didShowActionBlock) {
|
|
232
|
-
viewController.didShowActionBlock();
|
|
233
|
-
viewController.didShowActionBlock = nil;
|
|
234
|
-
}
|
|
178
|
+
if (poppingVC && [poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
179
|
+
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
235
180
|
}
|
|
236
181
|
|
|
237
182
|
self.nav.poppingViewController = nil;
|
|
@@ -278,7 +223,6 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
278
223
|
} else {
|
|
279
224
|
if (operation == UINavigationControllerOperationPush) {
|
|
280
225
|
if ([self shouldBetterTransitionWithViewController:toVC]) {
|
|
281
|
-
adjustLayout(toVC);
|
|
282
226
|
return [HBDPushAnimation new];
|
|
283
227
|
}
|
|
284
228
|
} else if (operation == UINavigationControllerOperationPop) {
|
|
@@ -341,7 +285,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
341
285
|
}
|
|
342
286
|
}
|
|
343
287
|
}
|
|
344
|
-
}
|
|
288
|
+
} completion:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
345
289
|
self.nav.poppingViewController = nil;
|
|
346
290
|
if (@available(iOS 13.0, *)) {
|
|
347
291
|
self.nav.navigationBar.scrollEdgeAppearance.backgroundColor = UIColor.clearColor;
|
|
@@ -356,20 +300,8 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
356
300
|
// `to` != `viewController` when present
|
|
357
301
|
[self.nav updateNavigationBarForViewController:viewController];
|
|
358
302
|
UIViewController *poppingVC = self.nav.poppingViewController;
|
|
359
|
-
if (poppingVC) {
|
|
360
|
-
|
|
361
|
-
poppingVC.didHideActionBlock();
|
|
362
|
-
poppingVC.didHideActionBlock = nil;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
if ([poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
366
|
-
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
367
|
-
}
|
|
368
|
-
} else {
|
|
369
|
-
if (viewController.didShowActionBlock) {
|
|
370
|
-
viewController.didShowActionBlock();
|
|
371
|
-
viewController.didShowActionBlock = nil;
|
|
372
|
-
}
|
|
303
|
+
if (poppingVC && [poppingVC isKindOfClass:[HBDViewController class]]) {
|
|
304
|
+
[viewController didReceiveResultCode:poppingVC.resultCode resultData:poppingVC.resultData requestCode:0];
|
|
373
305
|
}
|
|
374
306
|
}
|
|
375
307
|
|
|
@@ -530,7 +462,6 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
530
462
|
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item {
|
|
531
463
|
if (self.viewControllers.count > 1 && self.topViewController.navigationItem == item) {
|
|
532
464
|
if (!self.topViewController.hbd_backInteractive) {
|
|
533
|
-
[self resetSubviewsInNavBar:self.navigationBar];
|
|
534
465
|
return NO;
|
|
535
466
|
}
|
|
536
467
|
}
|
|
@@ -538,12 +469,6 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
538
469
|
}
|
|
539
470
|
|
|
540
471
|
- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
|
|
541
|
-
UIViewController *rootViewController = self.childViewControllers[0];
|
|
542
|
-
if (self.topViewController.didHideActionBlock && self.topViewController == rootViewController) {
|
|
543
|
-
self.topViewController.didHideActionBlock();
|
|
544
|
-
self.topViewController.didHideActionBlock = nil;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
472
|
if (self.childViewControllers.count > 1) {
|
|
548
473
|
self.poppingViewController = self.topViewController;
|
|
549
474
|
}
|
|
@@ -555,11 +480,6 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
555
480
|
}
|
|
556
481
|
|
|
557
482
|
- (NSArray<UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
558
|
-
if (self.topViewController.didHideActionBlock && self.topViewController == viewController) {
|
|
559
|
-
self.topViewController.didHideActionBlock();
|
|
560
|
-
self.topViewController.didHideActionBlock = nil;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
483
|
if (self.childViewControllers.count > 1) {
|
|
564
484
|
self.poppingViewController = self.topViewController;
|
|
565
485
|
}
|
|
@@ -570,12 +490,6 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
570
490
|
}
|
|
571
491
|
|
|
572
492
|
- (NSArray<UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated {
|
|
573
|
-
UIViewController *rootViewController = self.childViewControllers[0];
|
|
574
|
-
if (self.topViewController.didHideActionBlock && self.topViewController == rootViewController) {
|
|
575
|
-
self.topViewController.didHideActionBlock();
|
|
576
|
-
self.topViewController.didHideActionBlock = nil;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
493
|
if (self.childViewControllers.count > 1) {
|
|
580
494
|
self.poppingViewController = self.topViewController;
|
|
581
495
|
}
|
|
@@ -590,28 +504,11 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
590
504
|
return;
|
|
591
505
|
}
|
|
592
506
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
self.navigationBar.titleTextAttributes = self.topViewController.hbd_titleTextAttributes;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
- (void)resetSubviewsInNavBar:(UINavigationBar *)navBar {
|
|
604
|
-
if (@available(iOS 11, *)) {
|
|
605
|
-
// empty
|
|
606
|
-
} else {
|
|
607
|
-
// Workaround for >= iOS7.1. Thanks to @boliva - http://stackoverflow.com/posts/comments/34452906
|
|
608
|
-
[navBar.subviews enumerateObjectsUsingBlock:^(__kindof UIView *_Nonnull subview, NSUInteger idx, BOOL *_Nonnull stop) {
|
|
609
|
-
if (subview.alpha < 1.0) {
|
|
610
|
-
[UIView animateWithDuration:.25 animations:^{
|
|
611
|
-
subview.alpha = 1.0;
|
|
612
|
-
}];
|
|
613
|
-
}
|
|
614
|
-
}];
|
|
507
|
+
// fix:ios 11,12,当前后两个页面的 barStyle 不一样时,点击返回按钮返回,前一个页面的标题颜色响应迟缓或不响应
|
|
508
|
+
id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
509
|
+
if (!(coordinator && coordinator.interactive)) {
|
|
510
|
+
self.navigationBar.barStyle = self.topViewController.hbd_barStyle;
|
|
511
|
+
self.navigationBar.titleTextAttributes = self.topViewController.hbd_titleTextAttributes;
|
|
615
512
|
}
|
|
616
513
|
}
|
|
617
514
|
|
|
@@ -734,7 +631,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
734
631
|
}
|
|
735
632
|
|
|
736
633
|
- (CGRect)fakeShadowFrameWithBarFrame:(CGRect)frame {
|
|
737
|
-
return CGRectMake(frame.origin.x, frame.size.height + frame.origin.y, frame.size.width,
|
|
634
|
+
return CGRectMake(frame.origin.x, frame.size.height + frame.origin.y - hairlineWidth, frame.size.width, hairlineWidth);
|
|
738
635
|
}
|
|
739
636
|
|
|
740
637
|
@end
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDPopAnimation.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by 李生 on 2019/9/26.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
1
|
#import "HBDPopAnimation.h"
|
|
9
2
|
|
|
10
3
|
@implementation HBDPopAnimation
|
|
@@ -24,7 +17,7 @@
|
|
|
24
17
|
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
|
|
25
18
|
toView.transform = CGAffineTransformIdentity;
|
|
26
19
|
fromView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, transitionContext.containerView.bounds.size.width, 0);
|
|
27
|
-
}
|
|
20
|
+
} completion:^(BOOL finished) {
|
|
28
21
|
toView.transform = CGAffineTransformIdentity;
|
|
29
22
|
fromView.transform = CGAffineTransformIdentity;
|
|
30
23
|
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
|