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
|
@@ -12,20 +12,20 @@
|
|
|
12
12
|
- (void)showDotBadgeAtIndex:(NSInteger)index {
|
|
13
13
|
[self hideDotBadgeAtIndex:index];
|
|
14
14
|
//label为小红点,并设置label属性
|
|
15
|
-
UILabel *label = [[UILabel alloc]init];
|
|
15
|
+
UILabel *label = [[UILabel alloc] init];
|
|
16
16
|
label.tag = 1000 + index;
|
|
17
|
-
|
|
18
|
-
label.backgroundColor = [UITabBarItem appearance].badgeColor ?: [UIColor colorWithRed:1 green:58.0/255.0 blue:47
|
|
17
|
+
|
|
18
|
+
label.backgroundColor = [UITabBarItem appearance].badgeColor ?: [UIColor colorWithRed:1 green:58.0 / 255.0 blue:47. / 255. alpha:1];
|
|
19
19
|
|
|
20
20
|
CGFloat percentX = (index + 0.5) / self.items.count;
|
|
21
|
-
CGFloat x = ceilf(percentX * self.frame.size.width + 10);
|
|
21
|
+
CGFloat x = ceilf((float) (percentX * self.frame.size.width + 10));
|
|
22
22
|
CGFloat y = 5;
|
|
23
23
|
//10为小红点的高度和宽度
|
|
24
24
|
label.frame = CGRectMake(x, y, 10, 10);
|
|
25
25
|
[self addSubview:label];
|
|
26
26
|
//把小红点移到最顶层
|
|
27
27
|
[self bringSubviewToFront:label];
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
[self styleLabel:label];
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
|
|
47
47
|
CAShapeLayer *maskLayer = [CAShapeLayer layer];
|
|
48
48
|
maskLayer.frame = rect;
|
|
49
|
-
maskLayer.path
|
|
49
|
+
maskLayer.path = maskPath.CGPath;
|
|
50
50
|
label.layer.mask = maskLayer;
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -10,17 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
@interface HBDDrawerController : UIViewController
|
|
12
12
|
|
|
13
|
-
@property
|
|
14
|
-
@property
|
|
15
|
-
@property
|
|
16
|
-
@property
|
|
17
|
-
@property
|
|
13
|
+
@property(nonatomic, strong, readonly) UIViewController *contentController;
|
|
14
|
+
@property(nonatomic, strong, readonly) UIViewController *menuController;
|
|
15
|
+
@property(nonatomic, assign) BOOL menuInteractive;
|
|
16
|
+
@property(nonatomic, assign) CGFloat minDrawerMargin;
|
|
17
|
+
@property(nonatomic, assign) CGFloat maxDrawerWidth;
|
|
18
18
|
|
|
19
19
|
- (instancetype)initWithContentViewController:(UIViewController *)content menuViewController:(UIViewController *)menu;
|
|
20
20
|
|
|
21
21
|
- (void)openMenu;
|
|
22
|
+
|
|
22
23
|
- (void)closeMenu;
|
|
24
|
+
|
|
23
25
|
- (void)toggleMenu;
|
|
26
|
+
|
|
24
27
|
- (BOOL)isMenuOpened;
|
|
25
28
|
|
|
26
29
|
@end
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
@interface HBDDrawerController () <UIGestureRecognizerDelegate>
|
|
14
14
|
|
|
15
|
-
@property
|
|
16
|
-
@property
|
|
17
|
-
@property
|
|
15
|
+
@property(nonatomic, assign, getter=isMenuOpened) BOOL menuOpened;
|
|
16
|
+
@property(nonatomic, strong) UIView *menuDimmingView; // 侧边栏半透明黑底
|
|
17
|
+
@property(nonatomic, strong) UIView *menuHolderView;
|
|
18
18
|
|
|
19
19
|
@end
|
|
20
20
|
|
|
@@ -32,20 +32,20 @@
|
|
|
32
32
|
|
|
33
33
|
- (void)viewDidLoad {
|
|
34
34
|
[super viewDidLoad];
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
[self addChildViewController:self.contentController];
|
|
37
37
|
self.contentController.view.frame = self.view.bounds;
|
|
38
38
|
[self.view addSubview:self.contentController.view];
|
|
39
39
|
[self.contentController didMoveToParentViewController:self];
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
[self addChildViewController:self.menuController];
|
|
42
42
|
self.menuController.view.frame = CGRectZero;
|
|
43
43
|
[self.menuController didMoveToParentViewController:self];
|
|
44
|
-
|
|
45
|
-
UIScreenEdgePanGestureRecognizer *
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[self.view addGestureRecognizer:
|
|
44
|
+
|
|
45
|
+
UIScreenEdgePanGestureRecognizer *edgePanGestureRecognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleEdgePanGestureRecognizer:)];
|
|
46
|
+
edgePanGestureRecognizer.edges = UIRectEdgeLeft;
|
|
47
|
+
edgePanGestureRecognizer.delegate = self;
|
|
48
|
+
[self.view addGestureRecognizer:edgePanGestureRecognizer];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
|
|
87
87
|
- (void)viewDidAppear:(BOOL)animated {
|
|
88
88
|
[super viewDidAppear:animated];
|
|
89
|
-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:)name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
89
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
- (void)viewDidDisappear:(BOOL)animated {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
- (void)statusBarFrameWillChange:(NSNotification*)notification {
|
|
97
|
+
- (void)statusBarFrameWillChange:(NSNotification *)notification {
|
|
98
98
|
CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
|
|
99
99
|
if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation) && statusBarHeight != 0) {
|
|
100
100
|
if (self.menuOpened) {
|
|
@@ -108,15 +108,16 @@
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
|
111
|
+
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator {
|
|
112
112
|
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
|
113
|
-
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>
|
|
113
|
+
[coordinator animateAlongsideTransition:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
114
114
|
if (self.menuOpened) {
|
|
115
115
|
self.menuHolderView.frame = CGRectMake(0, 0, size.width, size.height);
|
|
116
116
|
self.menuDimmingView.frame = self.menuHolderView.bounds;
|
|
117
117
|
self.menuController.view.frame = CGRectMake(0, 0, [self menuWidth], size.height);
|
|
118
118
|
}
|
|
119
|
-
}
|
|
119
|
+
} completion:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
120
|
+
}];
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
- (void)setContentViewController:(UIViewController *)contentViewController {
|
|
@@ -158,36 +159,36 @@
|
|
|
158
159
|
|
|
159
160
|
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
|
|
160
161
|
if ([gestureRecognizer isKindOfClass:[UIScreenEdgePanGestureRecognizer class]]) {
|
|
161
|
-
return
|
|
162
|
+
return self.menuInteractive && !self.menuDimmingView;
|
|
162
163
|
} else if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
|
|
163
|
-
UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)gestureRecognizer;
|
|
164
|
+
UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *) gestureRecognizer;
|
|
164
165
|
return [pan velocityInView:self.menuDimmingView].x < 0;
|
|
165
166
|
} else if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]) {
|
|
166
167
|
CGPoint location = [gestureRecognizer locationInView:self.menuController.view];
|
|
167
|
-
return
|
|
168
|
+
return !CGRectContainsPoint(self.menuController.view.frame, location);
|
|
168
169
|
}
|
|
169
170
|
return NO;
|
|
170
171
|
}
|
|
171
172
|
|
|
172
173
|
- (void)presentMenuView {
|
|
173
174
|
[self addMenuView];
|
|
174
|
-
|
|
175
|
+
|
|
175
176
|
UIViewController *menu = self.menuController;
|
|
176
|
-
|
|
177
|
+
CGFloat menuWidth = [self menuWidth];
|
|
177
178
|
|
|
178
179
|
[self.menuController beginAppearanceTransition:YES animated:YES];
|
|
179
|
-
|
|
180
|
+
|
|
180
181
|
[UIView animateWithDuration:0.2 delay:0. options:UIViewAnimationOptionCurveEaseOut animations:^{
|
|
181
182
|
self.menuDimmingView.alpha = 0.5;
|
|
182
183
|
menu.view.frame = CGRectMake(0, 0, menuWidth, CGRectGetHeight(self.view.bounds));
|
|
183
|
-
}
|
|
184
|
+
} completion:^(BOOL finished) {
|
|
184
185
|
[self.menuController endAppearanceTransition];
|
|
185
186
|
}];
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
- (void)addMenuView {
|
|
189
190
|
UIViewController *menu = self.menuController;
|
|
190
|
-
|
|
191
|
+
CGFloat menuWidth = [self menuWidth];
|
|
191
192
|
menu.view.frame = CGRectMake(-menuWidth, 0, menuWidth, CGRectGetHeight(self.view.bounds));
|
|
192
193
|
UIView *menuHolderView = [[UIView alloc] initWithFrame:self.view.bounds];
|
|
193
194
|
self.menuHolderView = menuHolderView;
|
|
@@ -195,7 +196,7 @@
|
|
|
195
196
|
dimmingView.backgroundColor = [UIColor colorWithRed:0. green:0. blue:0. alpha:1.0];
|
|
196
197
|
dimmingView.alpha = 0;
|
|
197
198
|
self.menuDimmingView = dimmingView;
|
|
198
|
-
|
|
199
|
+
|
|
199
200
|
[self.view insertSubview:menuHolderView aboveSubview:self.contentController.view];
|
|
200
201
|
[menuHolderView addSubview:dimmingView];
|
|
201
202
|
[self addGestureRecognizerToMenuHolderView];
|
|
@@ -205,18 +206,18 @@
|
|
|
205
206
|
|
|
206
207
|
- (void)dismissMenuView {
|
|
207
208
|
self.menuOpened = NO;
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
|
|
210
|
+
CGFloat menuWidth = [self menuWidth];
|
|
210
211
|
CGFloat dx = -menuWidth - CGRectGetMinX(self.menuController.view.frame);
|
|
211
212
|
CGRect rect = CGRectOffset(self.menuController.view.frame, dx, 0);
|
|
212
|
-
CGFloat duration = (1- (dx + menuWidth)/menuWidth) * 0.2;
|
|
213
|
-
|
|
213
|
+
CGFloat duration = (1 - (dx + menuWidth) / menuWidth) * 0.2;
|
|
214
|
+
|
|
214
215
|
[self.menuController beginAppearanceTransition:NO animated:YES];
|
|
215
|
-
|
|
216
|
+
|
|
216
217
|
[UIView animateWithDuration:duration delay:0. options:UIViewAnimationOptionCurveEaseIn animations:^{
|
|
217
218
|
self.menuController.view.frame = rect;
|
|
218
219
|
self.menuDimmingView.alpha = 0;
|
|
219
|
-
}
|
|
220
|
+
} completion:^(BOOL finished) {
|
|
220
221
|
[self.menuController.view removeFromSuperview];
|
|
221
222
|
[self.menuDimmingView removeFromSuperview];
|
|
222
223
|
self.menuDimmingView = nil;
|
|
@@ -230,12 +231,12 @@
|
|
|
230
231
|
CGFloat width = CGRectGetWidth(self.menuController.view.frame);
|
|
231
232
|
CGFloat dx = 0 - CGRectGetMinX(self.menuController.view.frame);
|
|
232
233
|
CGRect rect = CGRectOffset(self.menuController.view.frame, dx, 0);
|
|
233
|
-
CGFloat duration = (dx/width) * 0.2;
|
|
234
|
+
CGFloat duration = (dx / width) * 0.2;
|
|
234
235
|
[self.menuController beginAppearanceTransition:YES animated:YES];
|
|
235
236
|
[UIView animateWithDuration:duration delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
|
236
237
|
self.menuController.view.frame = rect;
|
|
237
238
|
self.menuDimmingView.alpha = 0.5;
|
|
238
|
-
}
|
|
239
|
+
} completion:^(BOOL finished) {
|
|
239
240
|
[self.menuController endAppearanceTransition];
|
|
240
241
|
}];
|
|
241
242
|
}
|
|
@@ -243,11 +244,11 @@
|
|
|
243
244
|
- (void)addGestureRecognizerToMenuHolderView {
|
|
244
245
|
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGestureRecognizer:)];
|
|
245
246
|
panGestureRecognizer.delegate = self;
|
|
246
|
-
|
|
247
|
+
|
|
247
248
|
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGestureRecognizer:)];
|
|
248
249
|
tapGestureRecognizer.delegate = self;
|
|
249
250
|
[tapGestureRecognizer requireGestureRecognizerToFail:panGestureRecognizer];
|
|
250
|
-
|
|
251
|
+
|
|
251
252
|
[self.menuHolderView addGestureRecognizer:panGestureRecognizer];
|
|
252
253
|
[self.menuHolderView addGestureRecognizer:tapGestureRecognizer];
|
|
253
254
|
}
|
|
@@ -260,11 +261,11 @@
|
|
|
260
261
|
[self addMenuView];
|
|
261
262
|
self.menuController.view.frame = CGRectMake(-width + dx, 0, width, CGRectGetHeight(self.view.bounds));
|
|
262
263
|
self.menuDimmingView.alpha = dx * 0.5 / width;
|
|
263
|
-
} else if(UIGestureRecognizerStateChanged == recognizer.state) {
|
|
264
|
+
} else if (UIGestureRecognizerStateChanged == recognizer.state) {
|
|
264
265
|
self.menuController.view.frame = CGRectMake(-width + dx, 0, width, CGRectGetHeight(self.view.bounds));
|
|
265
266
|
self.menuDimmingView.alpha = dx * 0.5 / width;
|
|
266
267
|
} else {
|
|
267
|
-
if (
|
|
268
|
+
if (dx / width < 0.2) {
|
|
268
269
|
[self dismissMenuView];
|
|
269
270
|
} else {
|
|
270
271
|
[self settleMuneView];
|
|
@@ -296,7 +297,7 @@
|
|
|
296
297
|
[self dismissMenuView];
|
|
297
298
|
}
|
|
298
299
|
|
|
299
|
-
- (
|
|
300
|
+
- (CGFloat)menuWidth {
|
|
300
301
|
CGFloat maxWidth = CGRectGetWidth(self.view.bounds);
|
|
301
302
|
CGFloat margin1 = self.minDrawerMargin;
|
|
302
303
|
if (margin1 > maxWidth) {
|
|
@@ -304,7 +305,7 @@
|
|
|
304
305
|
} else if (margin1 < 0) {
|
|
305
306
|
margin1 = 0;
|
|
306
307
|
}
|
|
307
|
-
if (self.maxDrawerWidth <=0 || self.maxDrawerWidth > maxWidth) {
|
|
308
|
+
if (self.maxDrawerWidth <= 0 || self.maxDrawerWidth > maxWidth) {
|
|
308
309
|
self.maxDrawerWidth = maxWidth;
|
|
309
310
|
}
|
|
310
311
|
CGFloat margin2 = maxWidth - self.maxDrawerWidth;
|
|
@@ -26,12 +26,12 @@ typedef NS_ENUM(NSUInteger, HBDModalAnimationStyle) {
|
|
|
26
26
|
/**
|
|
27
27
|
* 等同 contentViewController.view
|
|
28
28
|
*/
|
|
29
|
-
@property
|
|
29
|
+
@property(nonatomic, strong, readonly) UIView *contentView;
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* 黑色遮罩
|
|
33
33
|
*/
|
|
34
|
-
@property
|
|
34
|
+
@property(nonatomic, strong) UIView *dimmingView;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* 设置`contentView`布局时与外容器的间距,默认为(20, 20, 20, 20)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
#import "HBDRootView.h"
|
|
13
13
|
#import "HBDUtils.h"
|
|
14
14
|
|
|
15
|
-
@interface UIViewController()
|
|
15
|
+
@interface UIViewController ()
|
|
16
16
|
|
|
17
17
|
@property(nonatomic, weak, readwrite) HBDModalViewController *hbd_modalViewController;
|
|
18
18
|
@property(nonatomic, strong, readwrite) UIViewController *hbd_targetViewController;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
@property(nonatomic, assign, readwrite, getter=isBeingHidden) BOOL beingHidden;
|
|
26
26
|
|
|
27
|
-
@property
|
|
27
|
+
@property(nonatomic, strong, readwrite) UIView *contentView;
|
|
28
28
|
|
|
29
29
|
@property(nonatomic, strong) HBDModalWindow *modalWindow;
|
|
30
30
|
@property(nonatomic, weak, readwrite) UIWindow *previousKeyWindow;
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
if ([self.contentView isKindOfClass:[HBDRootView class]]) {
|
|
99
99
|
return self.view.bounds;
|
|
100
100
|
}
|
|
101
|
-
CGSize contentViewContainerSize = CGSizeMake(CGRectGetWidth(self.view.bounds) - self.contentViewMargins.left - self.contentViewMargins.right, CGRectGetHeight(self.view.bounds)
|
|
101
|
+
CGSize contentViewContainerSize = CGSizeMake(CGRectGetWidth(self.view.bounds) - self.contentViewMargins.left - self.contentViewMargins.right, CGRectGetHeight(self.view.bounds) - self.contentViewMargins.top - self.contentViewMargins.bottom);
|
|
102
102
|
CGSize contentViewLimitSize = CGSizeMake(fmin(self.maximumContentViewWidth, contentViewContainerSize.width), contentViewContainerSize.height);
|
|
103
103
|
CGSize contentViewSize = CGSizeZero;
|
|
104
104
|
if (self.measureBlock) {
|
|
@@ -108,14 +108,14 @@
|
|
|
108
108
|
}
|
|
109
109
|
contentViewSize.width = fmin(contentViewLimitSize.width, contentViewSize.width);
|
|
110
110
|
contentViewSize.height = fmin(contentViewLimitSize.height, contentViewSize.height);
|
|
111
|
-
CGRect contentViewFrame = CGRectMake((contentViewContainerSize.width - contentViewSize.width)/2 + self.contentViewMargins.left, (contentViewContainerSize.height-contentViewSize.height)/2 + self.contentViewMargins.top, contentViewSize.width, contentViewSize.height);
|
|
111
|
+
CGRect contentViewFrame = CGRectMake((contentViewContainerSize.width - contentViewSize.width) / 2 + self.contentViewMargins.left, (contentViewContainerSize.height - contentViewSize.height) / 2 + self.contentViewMargins.top, contentViewSize.width, contentViewSize.height);
|
|
112
112
|
contentViewFrame = CGRectApplyAffineTransform(contentViewFrame, self.contentView.transform);
|
|
113
113
|
return contentViewFrame;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
- (void)viewDidAppear:(BOOL)animated {
|
|
117
117
|
[super viewDidAppear:animated];
|
|
118
|
-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:)name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
118
|
+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
- (void)viewDidDisappear:(BOOL)animated {
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
- (void)statusBarFrameWillChange:(NSNotification*)notification {
|
|
126
|
+
- (void)statusBarFrameWillChange:(NSNotification *)notification {
|
|
127
127
|
[UIView animateWithDuration:0.35 animations:^{
|
|
128
128
|
CGFloat dy = [HBDUtils isInCall] ? -20 : 20;
|
|
129
129
|
self.dimmingView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds) + dy);
|
|
@@ -136,15 +136,15 @@
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
|
139
|
+
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator {
|
|
140
140
|
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
|
141
|
-
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>
|
|
141
|
+
[coordinator animateAlongsideTransition:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
142
142
|
if (!UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)) {
|
|
143
143
|
self.view.frame = CGRectMake(0, 0, size.width, size.height);
|
|
144
144
|
}
|
|
145
145
|
[self updateLayout];
|
|
146
|
-
}
|
|
147
|
-
|
|
146
|
+
} completion:^(id <UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
147
|
+
|
|
148
148
|
}];
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -178,11 +178,11 @@
|
|
|
178
178
|
if (!self.dimmingView) {
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
if (self.dimmingViewTapGestureRecognizer.view == self.dimmingView) {
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
|
|
186
186
|
if (!self.dimmingViewTapGestureRecognizer) {
|
|
187
187
|
self.dimmingViewTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDimmingViewTapGestureRecognizer:)];
|
|
188
188
|
}
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
- (void)setContentView:(UIView *)contentView {
|
|
209
209
|
_contentView = contentView;
|
|
210
210
|
if ([contentView isKindOfClass:[HBDRootView class]]) {
|
|
211
|
-
HBDRootView *rootView = (HBDRootView *)contentView;
|
|
211
|
+
HBDRootView *rootView = (HBDRootView *) contentView;
|
|
212
212
|
rootView.backgroundColor = UIColor.clearColor;
|
|
213
213
|
}
|
|
214
214
|
}
|
|
@@ -222,32 +222,32 @@
|
|
|
222
222
|
[UIView animateWithDuration:.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
223
223
|
self.dimmingView.alpha = 1.0;
|
|
224
224
|
self.contentView.alpha = 1.0;
|
|
225
|
-
}
|
|
225
|
+
} completion:^(BOOL finished) {
|
|
226
226
|
if (completion) {
|
|
227
227
|
completion(finished);
|
|
228
228
|
}
|
|
229
229
|
}];
|
|
230
|
-
|
|
230
|
+
|
|
231
231
|
} else if (self.animationStyle == HBDModalAnimationStylePopup) {
|
|
232
232
|
self.dimmingView.alpha = 0.0;
|
|
233
233
|
self.contentView.transform = CGAffineTransformMakeScale(0, 0);
|
|
234
234
|
[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
235
235
|
self.dimmingView.alpha = 1.0;
|
|
236
236
|
self.contentView.transform = CGAffineTransformMakeScale(1, 1);
|
|
237
|
-
}
|
|
237
|
+
} completion:^(BOOL finished) {
|
|
238
238
|
self.contentView.transform = CGAffineTransformIdentity;
|
|
239
239
|
if (completion) {
|
|
240
240
|
completion(finished);
|
|
241
241
|
}
|
|
242
242
|
}];
|
|
243
|
-
|
|
243
|
+
|
|
244
244
|
} else if (self.animationStyle == HBDModalAnimationStyleSlide) {
|
|
245
245
|
self.dimmingView.alpha = 0.0;
|
|
246
246
|
self.contentView.transform = CGAffineTransformMakeTranslation(0, CGRectGetHeight(self.view.bounds) - CGRectGetMinY(self.contentView.frame));
|
|
247
247
|
[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
248
248
|
self.dimmingView.alpha = 1.0;
|
|
249
249
|
self.contentView.transform = CGAffineTransformIdentity;
|
|
250
|
-
}
|
|
250
|
+
} completion:^(BOOL finished) {
|
|
251
251
|
if (completion) {
|
|
252
252
|
completion(finished);
|
|
253
253
|
}
|
|
@@ -260,7 +260,7 @@
|
|
|
260
260
|
[UIView animateWithDuration:.2 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
261
261
|
self.dimmingView.alpha = 0.0;
|
|
262
262
|
self.contentView.alpha = 0.0;
|
|
263
|
-
}
|
|
263
|
+
} completion:^(BOOL finished) {
|
|
264
264
|
if (completion) {
|
|
265
265
|
completion(finished);
|
|
266
266
|
}
|
|
@@ -269,7 +269,7 @@
|
|
|
269
269
|
[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
270
270
|
self.dimmingView.alpha = 0.0;
|
|
271
271
|
self.contentView.transform = CGAffineTransformMakeScale(0.0, 0.0);
|
|
272
|
-
}
|
|
272
|
+
} completion:^(BOOL finished) {
|
|
273
273
|
if (completion) {
|
|
274
274
|
self.contentView.transform = CGAffineTransformIdentity;
|
|
275
275
|
completion(finished);
|
|
@@ -279,7 +279,7 @@
|
|
|
279
279
|
[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
280
280
|
self.dimmingView.alpha = 0.0;
|
|
281
281
|
self.contentView.transform = CGAffineTransformMakeTranslation(0, CGRectGetHeight(self.view.bounds) - CGRectGetMinY(self.contentView.frame));
|
|
282
|
-
}
|
|
282
|
+
} completion:^(BOOL finished) {
|
|
283
283
|
if (completion) {
|
|
284
284
|
self.contentView.transform = CGAffineTransformIdentity;
|
|
285
285
|
completion(finished);
|
|
@@ -291,22 +291,22 @@
|
|
|
291
291
|
- (void)showWithAnimated:(BOOL)animated completion:(void (^)(BOOL))completion {
|
|
292
292
|
self.contentView = self.contentViewController.view;
|
|
293
293
|
self.previousKeyWindow = self.contentViewController.hbd_targetViewController.view.window;
|
|
294
|
-
|
|
294
|
+
|
|
295
295
|
if (!self.modalWindow) {
|
|
296
296
|
self.modalWindow = [[HBDModalWindow alloc] init];
|
|
297
297
|
self.modalWindow.windowLevel = UIWindowLevelAlert - 4.0;;
|
|
298
298
|
self.modalWindow.backgroundColor = UIColor.clearColor;// 避免横竖屏旋转时出现黑色
|
|
299
299
|
}
|
|
300
|
-
|
|
300
|
+
|
|
301
301
|
self.modalWindow.rootViewController = self;
|
|
302
302
|
[self.modalWindow makeKeyAndVisible];
|
|
303
|
-
|
|
303
|
+
|
|
304
304
|
void (^didShownCompletion)(BOOL finished) = ^(BOOL finished) {
|
|
305
305
|
if (completion) {
|
|
306
306
|
completion(finished);
|
|
307
307
|
}
|
|
308
308
|
};
|
|
309
|
-
|
|
309
|
+
|
|
310
310
|
if (animated) {
|
|
311
311
|
[self.view addSubview:self.contentView];
|
|
312
312
|
[self.view layoutIfNeeded];
|
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
- (void)hideWithAnimated:(BOOL)animated completion:(void (^)(BOOL))completion {
|
|
337
337
|
self.beingHidden = YES;
|
|
338
338
|
[self.view endEditing:YES];
|
|
339
|
-
|
|
339
|
+
|
|
340
340
|
if (RCTKeyWindow() == self.modalWindow) {
|
|
341
341
|
if (self.previousKeyWindow) {
|
|
342
342
|
[self.previousKeyWindow makeKeyWindow];
|
|
@@ -344,17 +344,17 @@
|
|
|
344
344
|
[[UIApplication sharedApplication].delegate.window makeKeyWindow];
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
|
|
348
348
|
if (self.contentViewController) {
|
|
349
349
|
[self.contentViewController beginAppearanceTransition:NO animated:animated];
|
|
350
350
|
}
|
|
351
|
-
|
|
351
|
+
|
|
352
352
|
void (^didHiddenCompletion)(BOOL finished) = ^(BOOL finished) {
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
if (self.contentViewController) {
|
|
355
355
|
[self.contentViewController endAppearanceTransition];
|
|
356
356
|
}
|
|
357
|
-
|
|
357
|
+
|
|
358
358
|
self.modalWindow.hidden = YES;
|
|
359
359
|
self.modalWindow.rootViewController = nil;
|
|
360
360
|
self.previousKeyWindow = nil;
|
|
@@ -362,11 +362,11 @@
|
|
|
362
362
|
if (self.willDismissBlock) {
|
|
363
363
|
self.willDismissBlock(self);
|
|
364
364
|
}
|
|
365
|
-
|
|
365
|
+
|
|
366
366
|
if (completion) {
|
|
367
367
|
completion(YES);
|
|
368
368
|
}
|
|
369
|
-
|
|
369
|
+
|
|
370
370
|
if (self.contentViewController) {
|
|
371
371
|
self.contentViewController.hbd_targetViewController.hbd_popupViewController = nil;
|
|
372
372
|
self.contentViewController.hbd_targetViewController = nil;
|
|
@@ -374,7 +374,7 @@
|
|
|
374
374
|
self.contentViewController = nil;
|
|
375
375
|
}
|
|
376
376
|
};
|
|
377
|
-
|
|
377
|
+
|
|
378
378
|
if (animated) {
|
|
379
379
|
if (self.hidingAnimation) {
|
|
380
380
|
self.hidingAnimation(self, didHiddenCompletion);
|
|
@@ -388,8 +388,9 @@
|
|
|
388
388
|
|
|
389
389
|
@end
|
|
390
390
|
|
|
391
|
-
@interface HBDModalViewController(Manager)
|
|
391
|
+
@interface HBDModalViewController (Manager)
|
|
392
392
|
- (void)showWithAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
|
|
393
|
+
|
|
393
394
|
- (void)hideWithAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion;
|
|
394
395
|
@end
|
|
395
396
|
|
|
@@ -430,21 +431,21 @@
|
|
|
430
431
|
- (void)hbd_showViewController:(UIViewController *)vc requestCode:(NSInteger)requestCode animated:(BOOL)animated completion:(void (^)(BOOL))completion {
|
|
431
432
|
if (![self canShowModal]) {
|
|
432
433
|
[self didReceiveResultCode:0 resultData:nil requestCode:requestCode];
|
|
433
|
-
|
|
434
|
+
|
|
434
435
|
if (completion) {
|
|
435
436
|
completion(NO);
|
|
436
437
|
}
|
|
437
438
|
return;
|
|
438
439
|
}
|
|
439
|
-
|
|
440
|
+
|
|
440
441
|
self.hbd_popupViewController = vc;
|
|
441
442
|
[self beginAppearanceTransition:NO animated:YES];
|
|
442
443
|
[self endAppearanceTransition];
|
|
443
|
-
|
|
444
|
+
|
|
444
445
|
vc.hbd_barStyle = self.hbd_barStyle;
|
|
445
446
|
vc.hbd_targetViewController = self;
|
|
446
447
|
vc.requestCode = requestCode;
|
|
447
|
-
|
|
448
|
+
|
|
448
449
|
HBDModalViewController *modalViewController = [[HBDModalViewController alloc] init];
|
|
449
450
|
modalViewController.contentViewController = vc;
|
|
450
451
|
[modalViewController showWithAnimated:animated completion:completion];
|
|
@@ -456,20 +457,20 @@
|
|
|
456
457
|
RCTLogWarn(@"[Navigator] Can't show modal since the scene had present another scene already.");
|
|
457
458
|
return NO;
|
|
458
459
|
}
|
|
459
|
-
|
|
460
|
+
|
|
460
461
|
UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
|
|
461
462
|
for (NSUInteger i = application.windows.count; i > 0; i--) {
|
|
462
|
-
UIWindow *window = application.windows[i-1];
|
|
463
|
+
UIWindow *window = application.windows[i - 1];
|
|
463
464
|
UIViewController *viewController = window.rootViewController;
|
|
464
465
|
if ([viewController isKindOfClass:[HBDModalViewController class]]) {
|
|
465
|
-
HBDModalViewController *modal = (HBDModalViewController *)viewController;
|
|
466
|
+
HBDModalViewController *modal = (HBDModalViewController *) viewController;
|
|
466
467
|
if (!modal.beingHidden && window != self.view.window) {
|
|
467
468
|
RCTLogWarn(@"[Navigator] Can't show modal since the scene had show another modal already.");
|
|
468
469
|
return NO;
|
|
469
470
|
}
|
|
470
471
|
}
|
|
471
472
|
}
|
|
472
|
-
|
|
473
|
+
|
|
473
474
|
return YES;
|
|
474
475
|
}
|
|
475
476
|
|
|
@@ -481,13 +482,13 @@
|
|
|
481
482
|
[parent hbd_hideViewControllerAnimated:animated completion:completion];
|
|
482
483
|
return;
|
|
483
484
|
}
|
|
484
|
-
|
|
485
|
+
|
|
485
486
|
[self.hbd_modalViewController hideWithAnimated:animated completion:^(BOOL finished) {
|
|
486
487
|
UIViewController *target = self.hbd_targetViewController;
|
|
487
488
|
[target beginAppearanceTransition:YES animated:YES];
|
|
488
489
|
[target endAppearanceTransition];
|
|
489
490
|
[target didReceiveResultCode:self.resultCode resultData:self.resultData requestCode:self.requestCode];
|
|
490
|
-
|
|
491
|
+
|
|
491
492
|
if (completion) {
|
|
492
493
|
completion(finished);
|
|
493
494
|
}
|