hybrid-navigation 2.7.11 → 2.8.2
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 +16 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +4 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +6 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +3 -3
- package/ios/HybridNavigation/Bridge/HBDGardenModule.m +2 -1
- package/ios/HybridNavigation/GlobalStyle.h +4 -0
- package/ios/HybridNavigation/GlobalStyle.m +13 -0
- package/ios/HybridNavigation/HybridNavigation.h +1 -1
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +12 -1
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.m +2 -1
- package/ios/HybridNavigation/View/HBDNavigationBar.h +2 -3
- package/ios/HybridNavigation/View/HBDNavigationBar.m +31 -35
- package/ios/HybridNavigation/ViewController/HBDModalViewController.m +7 -0
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +18 -26
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.h +21 -0
- package/ios/HybridNavigation/{HBDGarden.m → ViewController/HBDViewController+Garden.m} +19 -45
- package/ios/HybridNavigation/ViewController/HBDViewController.h +1 -5
- package/ios/HybridNavigation/ViewController/HBDViewController.m +17 -14
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +5 -8
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +10 -7
- package/lib/typing.d.ts +1 -0
- package/package.json +1 -1
- package/ios/HybridNavigation/HBDGarden.h +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 2.8.2 (2022-04-27)
|
|
2
|
+
|
|
3
|
+
### iOS specific
|
|
4
|
+
|
|
5
|
+
- 修复由于隐藏 back title 而导致 back icon 在转场时表现异常的问题
|
|
6
|
+
|
|
7
|
+
## 2.8.1 (2022-04-25)
|
|
8
|
+
|
|
9
|
+
### iOS specific
|
|
10
|
+
|
|
11
|
+
- 优化 `redirectTo` 路由实现,避免在转场过程中执行新的路由动作
|
|
12
|
+
|
|
13
|
+
## 2.8.0 (2022-04-13)
|
|
14
|
+
|
|
15
|
+
- 添加 `forceTransparentDialogWindow` 配置项,用于设置当页面是 Dialog 时,是否强制背景透明
|
|
16
|
+
|
|
1
17
|
## 2.7.11 (2022-04-13)
|
|
2
18
|
|
|
3
19
|
### Android specific
|
package/android/build.gradle
CHANGED
|
@@ -33,5 +33,5 @@ dependencies {
|
|
|
33
33
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
34
34
|
implementation 'com.facebook.react:react-native:+'
|
|
35
35
|
// api project(':navigation')
|
|
36
|
-
api 'io.github.listenzz:AndroidNavigation:12.0
|
|
36
|
+
api 'io.github.listenzz:AndroidNavigation:12.1.0'
|
|
37
37
|
}
|
|
@@ -62,6 +62,8 @@ public class Garden {
|
|
|
62
62
|
|
|
63
63
|
boolean extendedLayoutIncludesTopBar;
|
|
64
64
|
|
|
65
|
+
boolean forceTransparentDialogWindow;
|
|
66
|
+
|
|
65
67
|
Garden(@NonNull HybridFragment fragment, Style style) {
|
|
66
68
|
// 构造 garden 实例时,Toolbar 还没有被创建
|
|
67
69
|
|
|
@@ -81,6 +83,8 @@ public class Garden {
|
|
|
81
83
|
if (!TextUtils.isEmpty(screenColor)) {
|
|
82
84
|
style.setScreenBackgroundColor(Color.parseColor(screenColor));
|
|
83
85
|
}
|
|
86
|
+
|
|
87
|
+
this.forceTransparentDialogWindow = options.getBoolean("forceTransparentDialogWindow");
|
|
84
88
|
|
|
85
89
|
applyOptions(options);
|
|
86
90
|
}
|
|
@@ -2,6 +2,7 @@ package com.reactnative.hybridnavigation;
|
|
|
2
2
|
|
|
3
3
|
import android.os.Bundle;
|
|
4
4
|
import android.view.View;
|
|
5
|
+
import android.view.Window;
|
|
5
6
|
|
|
6
7
|
import androidx.annotation.CallSuper;
|
|
7
8
|
import androidx.annotation.NonNull;
|
|
@@ -90,6 +91,11 @@ public class HybridFragment extends AwesomeFragment {
|
|
|
90
91
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
91
92
|
super.onViewCreated(view, savedInstanceState);
|
|
92
93
|
garden.configureToolbar();
|
|
94
|
+
if (getShowsDialog() && garden.forceTransparentDialogWindow) {
|
|
95
|
+
Window window = getWindow();
|
|
96
|
+
assert window != null;
|
|
97
|
+
window.setDimAmount(0);
|
|
98
|
+
}
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
public Garden getGarden() {
|
|
@@ -208,7 +208,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
208
208
|
} else {
|
|
209
209
|
promise.resolve(null);
|
|
210
210
|
}
|
|
211
|
-
}
|
|
211
|
+
});
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
|
|
@@ -268,7 +268,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
268
268
|
} else {
|
|
269
269
|
UiThreadUtil.runOnUiThread(this, 16);
|
|
270
270
|
}
|
|
271
|
-
}
|
|
271
|
+
});
|
|
272
272
|
}
|
|
273
273
|
};
|
|
274
274
|
|
|
@@ -300,7 +300,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
300
300
|
} else {
|
|
301
301
|
UiThreadUtil.runOnUiThread(this, 16);
|
|
302
302
|
}
|
|
303
|
-
}
|
|
303
|
+
});
|
|
304
304
|
}
|
|
305
305
|
};
|
|
306
306
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#import "HBDGardenModule.h"
|
|
10
10
|
#import "HBDReactBridgeManager.h"
|
|
11
11
|
#import "HBDTabBarController.h"
|
|
12
|
+
#import "GlobalStyle.h"
|
|
12
13
|
#import <React/RCTLog.h>
|
|
13
14
|
|
|
14
15
|
@interface HBDGardenModule ()
|
|
@@ -42,7 +43,7 @@ RCT_EXPORT_MODULE(GardenModule)
|
|
|
42
43
|
|
|
43
44
|
RCT_EXPORT_METHOD(setStyle:
|
|
44
45
|
(NSDictionary *) style) {
|
|
45
|
-
[
|
|
46
|
+
[GlobalStyle createWithOptions:style];
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
RCT_EXPORT_METHOD(setTitleItem:
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
@interface GlobalStyle : NSObject
|
|
12
12
|
|
|
13
|
+
+ (void)createWithOptions:(NSDictionary *)options;
|
|
14
|
+
|
|
15
|
+
+ (GlobalStyle *)globalStyle;
|
|
16
|
+
|
|
13
17
|
@property(nonatomic, strong, readonly) UIColor *screenBackgroundColor;
|
|
14
18
|
|
|
15
19
|
@property(nonatomic, assign, readonly, getter=isBackTitleHidden) BOOL backTitleHidden;
|
|
@@ -40,6 +40,19 @@
|
|
|
40
40
|
|
|
41
41
|
@implementation GlobalStyle
|
|
42
42
|
|
|
43
|
+
static GlobalStyle *globalStyle;
|
|
44
|
+
|
|
45
|
+
+ (void)createWithOptions:(NSDictionary *)options {
|
|
46
|
+
globalStyle = [[GlobalStyle alloc] initWithOptions:options];
|
|
47
|
+
[globalStyle inflateNavigationBar:[UINavigationBar appearance]];
|
|
48
|
+
[globalStyle inflateBarButtonItem:[UIBarButtonItem appearance]];
|
|
49
|
+
[globalStyle inflateTabBar:[UITabBar appearance]];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
+ (GlobalStyle *)globalStyle {
|
|
53
|
+
return globalStyle;
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
- (instancetype)initWithOptions:(NSDictionary *)options {
|
|
44
57
|
if (self = [super init]) {
|
|
45
58
|
_options = options;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
#import "HBDBarButtonItem.h"
|
|
5
5
|
#import "HBDNavigationBar.h"
|
|
6
|
-
#import "HBDGarden.h"
|
|
7
6
|
#import "HBDReactBridgeManager.h"
|
|
8
7
|
|
|
9
8
|
#import "HBDViewController.h"
|
|
9
|
+
#import "HBDViewController+Garden.h"
|
|
10
10
|
#import "HBDNavigationController.h"
|
|
11
11
|
#import "HBDTabBarController.h"
|
|
12
12
|
#import "HBDDrawerController.h"
|
|
@@ -67,10 +67,21 @@
|
|
|
67
67
|
resolve(@(NO));
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
+
|
|
71
|
+
if (nav.transitionCoordinator) {
|
|
72
|
+
__weak typeof(self) selfObj = self;
|
|
73
|
+
[nav.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
74
|
+
|
|
75
|
+
} completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
|
76
|
+
[selfObj handleNavigationWithViewController:target action:action extras:extras resolver:resolve rejecter:reject];
|
|
77
|
+
}];
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
70
80
|
|
|
71
81
|
if (!nav.hbd_viewAppeared) {
|
|
82
|
+
__weak typeof(self) selfObj = self;
|
|
72
83
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
73
|
-
[
|
|
84
|
+
[selfObj handleNavigationWithViewController:target action:action extras:extras resolver:resolve rejecter:reject];
|
|
74
85
|
});
|
|
75
86
|
return;
|
|
76
87
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#import "HBDTabBarController.h"
|
|
11
11
|
#import "HBDReactBridgeManager.h"
|
|
12
12
|
#import "HBDUtils.h"
|
|
13
|
+
#import "GlobalStyle.h"
|
|
13
14
|
#import <React/RCTUtils.h>
|
|
14
15
|
|
|
15
16
|
@implementation HBDTabNavigator
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
tabBarOptions[@"tabBarModuleName"] = tabBarModuleName;
|
|
46
47
|
tabBarOptions[@"sizeIndeterminate"] = @([options[@"sizeIndeterminate"] boolValue]);
|
|
47
48
|
tabBarOptions[@"selectedIndex"] = options[@"selectedIndex"] ?: @(0);
|
|
48
|
-
GlobalStyle *style = [
|
|
49
|
+
GlobalStyle *style = [GlobalStyle globalStyle];
|
|
49
50
|
tabBarOptions[@"tabBarItemColor"] = style.tabBarItemColorHexString;
|
|
50
51
|
tabBarOptions[@"tabBarUnselectedItemColor"] = style.tabBarUnselectedItemColorHexString;
|
|
51
52
|
tabBarOptions[@"badgeColor"] = style.badgeColorHexString;
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
@interface HBDNavigationBar : UINavigationBar
|
|
12
12
|
|
|
13
|
-
@property(nonatomic, strong, readonly) UIImageView *
|
|
14
|
-
@property(nonatomic, strong, readonly)
|
|
13
|
+
@property(nonatomic, strong, readonly) UIImageView *fakeShadowView;
|
|
14
|
+
@property(nonatomic, strong, readonly) UIView *fakeBackgroundView;
|
|
15
15
|
@property(nonatomic, strong, readonly) UILabel *backButtonLabel;
|
|
16
|
-
@property(nonatomic, strong, readonly) UIView *hbd_backgroundView;
|
|
17
16
|
|
|
18
17
|
@end
|
|
19
18
|
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
@interface HBDNavigationBar ()
|
|
13
13
|
|
|
14
|
-
@property(nonatomic, strong, readwrite) UIImageView *
|
|
15
|
-
@property(nonatomic, strong, readwrite)
|
|
14
|
+
@property(nonatomic, strong, readwrite) UIImageView *fakeShadowView;
|
|
15
|
+
@property(nonatomic, strong, readwrite) UIView *fakeBackgroundView;
|
|
16
16
|
|
|
17
17
|
@end
|
|
18
18
|
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
NSArray *array = @[@"UINavigationBarContentView", @"UIButtonBarStackView", @"HBDNavigationBar"];
|
|
47
47
|
if ([array containsObject:viewName]) {
|
|
48
|
-
if (self.
|
|
48
|
+
if (self.fakeBackgroundView.alpha < 0.01) {
|
|
49
49
|
return nil;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -59,29 +59,25 @@
|
|
|
59
59
|
|
|
60
60
|
- (void)layoutSubviews {
|
|
61
61
|
[super layoutSubviews];
|
|
62
|
-
self.
|
|
63
|
-
self.
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
- (UIView *)hbd_backgroundView {
|
|
67
|
-
return [self valueForKey:@"_backgroundView"];
|
|
62
|
+
self.fakeBackgroundView.frame = self.fakeBackgroundView.superview.bounds;
|
|
63
|
+
self.fakeShadowView.frame = CGRectMake(0, CGRectGetHeight(self.fakeShadowView.superview.bounds), CGRectGetWidth(self.fakeShadowView.superview.bounds), 0.5);
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
- (void)setBarTintColor:(UIColor *)barTintColor {
|
|
71
67
|
[super setBarTintColor:barTintColor];
|
|
72
|
-
self.
|
|
73
|
-
[self
|
|
68
|
+
self.fakeBackgroundView.backgroundColor = barTintColor;
|
|
69
|
+
[self makesureFakeBackgroundView];
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
- (
|
|
77
|
-
if (!
|
|
72
|
+
- (UIView *)fakeBackgroundView {
|
|
73
|
+
if (!_fakeBackgroundView) {
|
|
78
74
|
[super setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
[[self.subviews firstObject] insertSubview:
|
|
75
|
+
_fakeBackgroundView = [[UIView alloc] init];
|
|
76
|
+
_fakeBackgroundView.userInteractionEnabled = NO;
|
|
77
|
+
_fakeBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
78
|
+
[[self.subviews firstObject] insertSubview:_fakeBackgroundView atIndex:0];
|
|
83
79
|
}
|
|
84
|
-
return
|
|
80
|
+
return _fakeBackgroundView;
|
|
85
81
|
}
|
|
86
82
|
|
|
87
83
|
- (void)setTranslucent:(BOOL)translucent {
|
|
@@ -94,35 +90,35 @@
|
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
- (void)setShadowImage:(UIImage *)shadowImage {
|
|
97
|
-
self.
|
|
93
|
+
self.fakeShadowView.image = shadowImage;
|
|
98
94
|
if (shadowImage) {
|
|
99
|
-
self.
|
|
95
|
+
self.fakeShadowView.backgroundColor = nil;
|
|
100
96
|
} else {
|
|
101
|
-
self.
|
|
97
|
+
self.fakeShadowView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:77.0 / 255];
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
|
|
105
|
-
- (UIImageView *)
|
|
106
|
-
if (!
|
|
101
|
+
- (UIImageView *)fakeShadowView {
|
|
102
|
+
if (!_fakeShadowView) {
|
|
107
103
|
[super setShadowImage:[UIImage new]];
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
[[self.subviews firstObject] insertSubview:
|
|
104
|
+
_fakeShadowView = [[UIImageView alloc] init];
|
|
105
|
+
_fakeShadowView.userInteractionEnabled = NO;
|
|
106
|
+
_fakeShadowView.contentScaleFactor = 1;
|
|
107
|
+
[[self.subviews firstObject] insertSubview:_fakeShadowView aboveSubview:self.fakeBackgroundView];
|
|
112
108
|
}
|
|
113
|
-
return
|
|
109
|
+
return _fakeShadowView;
|
|
114
110
|
}
|
|
115
111
|
|
|
116
|
-
- (void)
|
|
112
|
+
- (void)makesureFakeBackgroundView {
|
|
117
113
|
[UIView setAnimationsEnabled:NO];
|
|
118
|
-
if (!self.
|
|
119
|
-
[[self.subviews firstObject] insertSubview:
|
|
120
|
-
self.
|
|
114
|
+
if (!self.fakeBackgroundView.superview) {
|
|
115
|
+
[[self.subviews firstObject] insertSubview:_fakeBackgroundView atIndex:0];
|
|
116
|
+
self.fakeBackgroundView.frame = self.fakeBackgroundView.superview.bounds;
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
if (!self.
|
|
124
|
-
[[self.subviews firstObject] insertSubview:
|
|
125
|
-
self.
|
|
119
|
+
if (!self.fakeShadowView.superview) {
|
|
120
|
+
[[self.subviews firstObject] insertSubview:_fakeShadowView aboveSubview:self.fakeBackgroundView];
|
|
121
|
+
self.fakeShadowView.frame = CGRectMake(0, CGRectGetHeight(self.fakeShadowView.superview.bounds), CGRectGetWidth(self.fakeShadowView.superview.bounds), 0.5);
|
|
126
122
|
}
|
|
127
123
|
[UIView setAnimationsEnabled:YES];
|
|
128
124
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#import "HBDModalViewController.h"
|
|
12
12
|
#import "HBDRootView.h"
|
|
13
13
|
#import "HBDUtils.h"
|
|
14
|
+
#import "HBDViewController+Garden.h"
|
|
14
15
|
|
|
15
16
|
@interface UIViewController ()
|
|
16
17
|
|
|
@@ -448,6 +449,12 @@
|
|
|
448
449
|
|
|
449
450
|
HBDModalViewController *modalViewController = [[HBDModalViewController alloc] init];
|
|
450
451
|
modalViewController.contentViewController = vc;
|
|
452
|
+
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
453
|
+
HBDViewController *hbdvc = (HBDViewController *)vc;
|
|
454
|
+
if (hbdvc.forceTransparentDialogWindow) {
|
|
455
|
+
modalViewController.dimmingView.backgroundColor = UIColor.clearColor;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
451
458
|
[modalViewController showWithAnimated:animated completion:completion];
|
|
452
459
|
}
|
|
453
460
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#import "HBDViewController.h"
|
|
11
11
|
#import "HBDNavigationBar.h"
|
|
12
12
|
#import "HBDUtils.h"
|
|
13
|
+
#import "GlobalStyle.h"
|
|
13
14
|
#import "HBDPushAnimation.h"
|
|
14
15
|
#import "HBDPopAnimation.h"
|
|
15
16
|
#import <React/RCTLog.h>
|
|
@@ -79,8 +80,8 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
79
80
|
@interface HBDNavigationController ()
|
|
80
81
|
|
|
81
82
|
@property(nonatomic, readonly) HBDNavigationBar *navigationBar;
|
|
82
|
-
@property(nonatomic, strong)
|
|
83
|
-
@property(nonatomic, strong)
|
|
83
|
+
@property(nonatomic, strong) UIView *fromFakeBar;
|
|
84
|
+
@property(nonatomic, strong) UIView *toFakeBar;
|
|
84
85
|
@property(nonatomic, strong) UIImageView *fromFakeShadow;
|
|
85
86
|
@property(nonatomic, strong) UIImageView *toFakeShadow;
|
|
86
87
|
@property(nonatomic, weak) UIViewController *poppingViewController;
|
|
@@ -402,7 +403,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
402
403
|
}
|
|
403
404
|
|
|
404
405
|
- (BOOL)shouldShowFakeBarFrom:(UIViewController *)from to:(UIViewController *)to viewController:(UIViewController *_Nonnull)viewController {
|
|
405
|
-
if ([
|
|
406
|
+
if ([GlobalStyle globalStyle].alwaysSplitNavigationBarTransition && to == viewController) {
|
|
406
407
|
return YES;
|
|
407
408
|
}
|
|
408
409
|
|
|
@@ -635,14 +636,8 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
635
636
|
}
|
|
636
637
|
|
|
637
638
|
- (void)updateNavigationBarAlphaForViewController:(UIViewController *)vc {
|
|
638
|
-
self.navigationBar.
|
|
639
|
-
self.navigationBar.
|
|
640
|
-
|
|
641
|
-
if (vc.hbd_barAlpha == 0) {
|
|
642
|
-
self.navigationBar.hbd_backgroundView.layer.mask = [CALayer new];
|
|
643
|
-
} else {
|
|
644
|
-
self.navigationBar.hbd_backgroundView.layer.mask = nil;
|
|
645
|
-
}
|
|
639
|
+
self.navigationBar.fakeBackgroundView.alpha = vc.hbd_barAlpha;
|
|
640
|
+
self.navigationBar.fakeShadowView.alpha = vc.hbd_barShadowAlpha;
|
|
646
641
|
}
|
|
647
642
|
|
|
648
643
|
- (void)updateNavigationBarBackgroundForViewController:(UIViewController *)vc {
|
|
@@ -651,19 +646,16 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
651
646
|
|
|
652
647
|
- (void)showFakeBarFrom:(UIViewController *)from to:(UIViewController *_Nonnull)to {
|
|
653
648
|
[UIView setAnimationsEnabled:NO];
|
|
654
|
-
self.navigationBar.
|
|
655
|
-
self.navigationBar.
|
|
649
|
+
self.navigationBar.fakeBackgroundView.alpha = 0;
|
|
650
|
+
self.navigationBar.fakeShadowView.alpha = 0;
|
|
656
651
|
[self showFakeBarFrom:from];
|
|
657
652
|
[self showFakeBarTo:to];
|
|
658
653
|
[UIView setAnimationsEnabled:YES];
|
|
659
654
|
}
|
|
660
655
|
|
|
661
656
|
- (void)showFakeBarFrom:(UIViewController *)from {
|
|
662
|
-
self.fromFakeBar.
|
|
657
|
+
self.fromFakeBar.backgroundColor = from.hbd_barTintColor;
|
|
663
658
|
self.fromFakeBar.alpha = from.hbd_barAlpha;
|
|
664
|
-
if (from.hbd_barAlpha == 0) {
|
|
665
|
-
self.fromFakeBar.subviews.lastObject.layer.mask = [CALayer new];
|
|
666
|
-
}
|
|
667
659
|
self.fromFakeBar.frame = [self fakeBarFrameForViewController:from];
|
|
668
660
|
[from.view addSubview:self.fromFakeBar];
|
|
669
661
|
self.fromFakeShadow.alpha = from.hbd_barShadowAlpha;
|
|
@@ -672,7 +664,7 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
672
664
|
}
|
|
673
665
|
|
|
674
666
|
- (void)showFakeBarTo:(UIViewController *_Nonnull)to {
|
|
675
|
-
self.toFakeBar.
|
|
667
|
+
self.toFakeBar.backgroundColor = to.hbd_barTintColor;
|
|
676
668
|
self.toFakeBar.alpha = to.hbd_barAlpha;
|
|
677
669
|
self.toFakeBar.frame = [self fakeBarFrameForViewController:to];
|
|
678
670
|
[to.view addSubview:self.toFakeBar];
|
|
@@ -681,32 +673,32 @@ void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
|
681
673
|
[to.view addSubview:self.toFakeShadow];
|
|
682
674
|
}
|
|
683
675
|
|
|
684
|
-
- (
|
|
676
|
+
- (UIView *)fromFakeBar {
|
|
685
677
|
if (!_fromFakeBar) {
|
|
686
|
-
_fromFakeBar = [[
|
|
678
|
+
_fromFakeBar = [[UIView alloc] init];
|
|
687
679
|
}
|
|
688
680
|
return _fromFakeBar;
|
|
689
681
|
}
|
|
690
682
|
|
|
691
|
-
- (
|
|
683
|
+
- (UIView *)toFakeBar {
|
|
692
684
|
if (!_toFakeBar) {
|
|
693
|
-
_toFakeBar = [[
|
|
685
|
+
_toFakeBar = [[UIView alloc] init];
|
|
694
686
|
}
|
|
695
687
|
return _toFakeBar;
|
|
696
688
|
}
|
|
697
689
|
|
|
698
690
|
- (UIImageView *)fromFakeShadow {
|
|
699
691
|
if (!_fromFakeShadow) {
|
|
700
|
-
_fromFakeShadow = [[UIImageView alloc] initWithImage:self.navigationBar.
|
|
701
|
-
_fromFakeShadow.backgroundColor = self.navigationBar.
|
|
692
|
+
_fromFakeShadow = [[UIImageView alloc] initWithImage:self.navigationBar.fakeShadowView.image];
|
|
693
|
+
_fromFakeShadow.backgroundColor = self.navigationBar.fakeShadowView.backgroundColor;
|
|
702
694
|
}
|
|
703
695
|
return _fromFakeShadow;
|
|
704
696
|
}
|
|
705
697
|
|
|
706
698
|
- (UIImageView *)toFakeShadow {
|
|
707
699
|
if (!_toFakeShadow) {
|
|
708
|
-
_toFakeShadow = [[UIImageView alloc] initWithImage:self.navigationBar.
|
|
709
|
-
_toFakeShadow.backgroundColor = self.navigationBar.
|
|
700
|
+
_toFakeShadow = [[UIImageView alloc] initWithImage:self.navigationBar.fakeShadowView.image];
|
|
701
|
+
_toFakeShadow.backgroundColor = self.navigationBar.fakeShadowView.backgroundColor;
|
|
710
702
|
}
|
|
711
703
|
return _toFakeShadow;
|
|
712
704
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#import "HBDViewController.h"
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
@interface HBDViewController (Garden)
|
|
6
|
+
|
|
7
|
+
@property(nonatomic, assign) BOOL forceTransparentDialogWindow;
|
|
8
|
+
|
|
9
|
+
- (void)setLeftBarButtonItem:(NSDictionary *)item;
|
|
10
|
+
|
|
11
|
+
- (void)setRightBarButtonItem:(NSDictionary *)item;
|
|
12
|
+
|
|
13
|
+
- (void)setLeftBarButtonItems:(NSArray *)items;
|
|
14
|
+
|
|
15
|
+
- (void)setRightBarButtonItems:(NSArray *)items;
|
|
16
|
+
|
|
17
|
+
- (void)setPassThroughTouches:(BOOL)passThrough;
|
|
18
|
+
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -1,49 +1,24 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDGarden.m
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/26.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import "HBDGarden.h"
|
|
10
1
|
#import <React/RCTConvert.h>
|
|
11
2
|
#import <React/RCTRootView.h>
|
|
12
3
|
|
|
4
|
+
#import "HBDViewController+Garden.h"
|
|
5
|
+
|
|
13
6
|
#import "HBDBarButtonItem.h"
|
|
14
7
|
#import "HBDUtils.h"
|
|
15
8
|
#import "HBDEventEmitter.h"
|
|
16
9
|
|
|
10
|
+
@implementation HBDViewController (Garden)
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
@end
|
|
23
|
-
|
|
24
|
-
@implementation HBDGarden
|
|
25
|
-
|
|
26
|
-
static GlobalStyle *globalStyle;
|
|
27
|
-
|
|
28
|
-
+ (void)createGlobalStyleWithOptions:(NSDictionary *)options {
|
|
29
|
-
globalStyle = [[GlobalStyle alloc] initWithOptions:options];
|
|
30
|
-
[globalStyle inflateNavigationBar:[UINavigationBar appearance]];
|
|
31
|
-
[globalStyle inflateBarButtonItem:[UIBarButtonItem appearance]];
|
|
32
|
-
[globalStyle inflateTabBar:[UITabBar appearance]];
|
|
12
|
+
- (BOOL)forceTransparentDialogWindow {
|
|
13
|
+
id obj = objc_getAssociatedObject(self, _cmd);
|
|
14
|
+
return obj ? [obj boolValue] : NO;
|
|
33
15
|
}
|
|
34
16
|
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
- (void)setForceTransparentDialogWindow:(BOOL)transparent {
|
|
18
|
+
objc_setAssociatedObject(self, @selector(forceTransparentDialogWindow), @(transparent), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
37
19
|
}
|
|
38
20
|
|
|
39
|
-
- (
|
|
40
|
-
if (self = [super init]) {
|
|
41
|
-
_viewController = vc;
|
|
42
|
-
}
|
|
43
|
-
return self;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
- (void)setLeftBarButtonItem:(NSDictionary *__nullable)item {
|
|
21
|
+
- (void)setLeftBarButtonItem:(NSDictionary *)item {
|
|
47
22
|
if (item) {
|
|
48
23
|
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
49
24
|
if (@available(iOS 11.0, *)) {
|
|
@@ -61,13 +36,13 @@ static GlobalStyle *globalStyle;
|
|
|
61
36
|
}
|
|
62
37
|
[array addObject:buttonItem];
|
|
63
38
|
|
|
64
|
-
self.
|
|
39
|
+
self.navigationItem.leftBarButtonItems = array;
|
|
65
40
|
} else {
|
|
66
|
-
self.
|
|
41
|
+
self.navigationItem.leftBarButtonItems = nil;
|
|
67
42
|
}
|
|
68
43
|
}
|
|
69
44
|
|
|
70
|
-
- (void)setRightBarButtonItem:(NSDictionary *
|
|
45
|
+
- (void)setRightBarButtonItem:(NSDictionary *)item {
|
|
71
46
|
if (item) {
|
|
72
47
|
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
73
48
|
if (@available(iOS 11.0, *)) {
|
|
@@ -85,9 +60,9 @@ static GlobalStyle *globalStyle;
|
|
|
85
60
|
}
|
|
86
61
|
[array addObject:buttonItem];
|
|
87
62
|
|
|
88
|
-
self.
|
|
63
|
+
self.navigationItem.rightBarButtonItems = array;
|
|
89
64
|
} else {
|
|
90
|
-
self.
|
|
65
|
+
self.navigationItem.rightBarButtonItems = nil;
|
|
91
66
|
}
|
|
92
67
|
}
|
|
93
68
|
|
|
@@ -113,7 +88,7 @@ static GlobalStyle *globalStyle;
|
|
|
113
88
|
}
|
|
114
89
|
}
|
|
115
90
|
|
|
116
|
-
self.
|
|
91
|
+
self.navigationItem.leftBarButtonItems = array;
|
|
117
92
|
}
|
|
118
93
|
}
|
|
119
94
|
|
|
@@ -138,7 +113,7 @@ static GlobalStyle *globalStyle;
|
|
|
138
113
|
}
|
|
139
114
|
}
|
|
140
115
|
|
|
141
|
-
self.
|
|
116
|
+
self.navigationItem.rightBarButtonItems = array;
|
|
142
117
|
}
|
|
143
118
|
}
|
|
144
119
|
|
|
@@ -181,7 +156,7 @@ static GlobalStyle *globalStyle;
|
|
|
181
156
|
}
|
|
182
157
|
|
|
183
158
|
NSString *action = item[@"action"];
|
|
184
|
-
NSString *sceneId = self.
|
|
159
|
+
NSString *sceneId = self.sceneId;
|
|
185
160
|
|
|
186
161
|
NSString *tintColor = item[@"tintColor"];
|
|
187
162
|
if (tintColor) {
|
|
@@ -206,11 +181,10 @@ static GlobalStyle *globalStyle;
|
|
|
206
181
|
}
|
|
207
182
|
|
|
208
183
|
- (void)setPassThroughTouches:(BOOL)passThrough {
|
|
209
|
-
if ([self.
|
|
210
|
-
RCTRootView *rootView = (RCTRootView *) self.
|
|
184
|
+
if ([self.view isKindOfClass:[RCTRootView class]]) {
|
|
185
|
+
RCTRootView *rootView = (RCTRootView *) self.view;
|
|
211
186
|
rootView.passThroughTouches = passThrough;
|
|
212
187
|
}
|
|
213
188
|
}
|
|
214
189
|
|
|
215
190
|
@end
|
|
216
|
-
|
|
@@ -8,16 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
#import <UIKit/UIKit.h>
|
|
10
10
|
#import "UIViewController+HBD.h"
|
|
11
|
-
#import "HBDGarden.h"
|
|
12
|
-
|
|
13
|
-
@class HBDGarden;
|
|
14
11
|
|
|
15
12
|
@interface HBDViewController : UIViewController
|
|
16
13
|
|
|
17
14
|
@property(nonatomic, copy, readonly) NSString *moduleName;
|
|
18
15
|
@property(nonatomic, copy, readonly) NSDictionary *props;
|
|
19
|
-
@property(nonatomic, copy) NSDictionary *options;
|
|
20
|
-
@property(nonatomic, strong, readonly) HBDGarden *garden;
|
|
16
|
+
@property(nonatomic, copy, readonly) NSDictionary *options;
|
|
21
17
|
|
|
22
18
|
- (instancetype)initWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options NS_DESIGNATED_INITIALIZER;
|
|
23
19
|
|
|
@@ -6,14 +6,17 @@
|
|
|
6
6
|
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
+
#import <React/RCTLog.h>
|
|
10
|
+
|
|
9
11
|
#import "HBDViewController.h"
|
|
12
|
+
#import "HBDViewController+Garden.h"
|
|
10
13
|
#import "HBDUtils.h"
|
|
11
|
-
#import
|
|
14
|
+
#import "GlobalStyle.h"
|
|
12
15
|
|
|
13
16
|
@interface HBDViewController ()
|
|
14
17
|
|
|
15
18
|
@property(nonatomic, copy, readwrite) NSDictionary *props;
|
|
16
|
-
@property(nonatomic,
|
|
19
|
+
@property(nonatomic, copy, readwrite) NSDictionary *options;
|
|
17
20
|
|
|
18
21
|
@end
|
|
19
22
|
|
|
@@ -36,8 +39,8 @@
|
|
|
36
39
|
_moduleName = moduleName;
|
|
37
40
|
_options = options;
|
|
38
41
|
_props = props;
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
|
|
43
|
+
self.forceTransparentDialogWindow = [options[@"forceTransparentDialogWindow"] boolValue];
|
|
41
44
|
[self applyNavigationBarOptions:options];
|
|
42
45
|
[self applyTabBarOptions:options];
|
|
43
46
|
}
|
|
@@ -100,7 +103,7 @@
|
|
|
100
103
|
if (screenColor) {
|
|
101
104
|
self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
|
|
102
105
|
} else {
|
|
103
|
-
self.view.backgroundColor = [
|
|
106
|
+
self.view.backgroundColor = [GlobalStyle globalStyle].screenBackgroundColor;
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
|
|
@@ -170,15 +173,15 @@
|
|
|
170
173
|
self.hbd_barHidden = YES;
|
|
171
174
|
}
|
|
172
175
|
|
|
173
|
-
if ([
|
|
174
|
-
|
|
176
|
+
if ([GlobalStyle globalStyle].isBackTitleHidden) {
|
|
177
|
+
UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:NULL];
|
|
178
|
+
self.navigationItem.backBarButtonItem = buttonItem;
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
NSDictionary *backItem = options[@"backItemIOS"];
|
|
178
182
|
if (backItem) {
|
|
179
|
-
NSString *title = backItem[@"title"];
|
|
180
183
|
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] init];
|
|
181
|
-
backButton.title = title;
|
|
184
|
+
backButton.title = backItem[@"title"];
|
|
182
185
|
NSString *tintColor = backItem[@"tintColor"];
|
|
183
186
|
if (tintColor) {
|
|
184
187
|
backButton.tintColor = [HBDUtils colorWithHexString:tintColor];
|
|
@@ -238,22 +241,22 @@
|
|
|
238
241
|
|
|
239
242
|
id rightBarButtonItem = options[@"rightBarButtonItem"];
|
|
240
243
|
if (rightBarButtonItem) {
|
|
241
|
-
[self
|
|
244
|
+
[self setRightBarButtonItem:RCTNilIfNull(rightBarButtonItem)];
|
|
242
245
|
}
|
|
243
246
|
|
|
244
247
|
id leftBarButtonItem = options[@"leftBarButtonItem"];
|
|
245
248
|
if (leftBarButtonItem) {
|
|
246
|
-
[self
|
|
249
|
+
[self setLeftBarButtonItem:RCTNilIfNull(leftBarButtonItem)];
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
NSArray *rightBarButtonItems = options[@"rightBarButtonItems"];
|
|
250
253
|
if (rightBarButtonItems) {
|
|
251
|
-
[self
|
|
254
|
+
[self setRightBarButtonItems:rightBarButtonItems];
|
|
252
255
|
}
|
|
253
256
|
|
|
254
257
|
NSArray *leftBarButtonItems = options[@"leftBarButtonItems"];
|
|
255
258
|
if (leftBarButtonItems) {
|
|
256
|
-
[self
|
|
259
|
+
[self setLeftBarButtonItems:leftBarButtonItems];
|
|
257
260
|
}
|
|
258
261
|
}
|
|
259
262
|
|
|
@@ -303,7 +306,7 @@
|
|
|
303
306
|
|
|
304
307
|
NSNumber *passThroughTouches = options[@"passThroughTouches"];
|
|
305
308
|
if (passThroughTouches) {
|
|
306
|
-
[self
|
|
309
|
+
[self setPassThroughTouches:[passThroughTouches boolValue]];
|
|
307
310
|
}
|
|
308
311
|
|
|
309
312
|
if ([self shouldUpdateNavigationBar:options compareTo:previous]) {
|
|
@@ -16,15 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
- (void)redirectToViewController:(UIViewController *)controller target:(UIViewController *)target animated:(BOOL)animated {
|
|
18
18
|
NSMutableArray *children = [self.childViewControllers mutableCopy];
|
|
19
|
-
NSUInteger
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
UIViewController *child = children[index];
|
|
23
|
-
[children removeObjectAtIndex:index];
|
|
24
|
-
if (child == target) {
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
19
|
+
NSUInteger index = [children indexOfObject:target];
|
|
20
|
+
if (index == NSNotFound) {
|
|
21
|
+
return;
|
|
27
22
|
}
|
|
23
|
+
NSUInteger count = self.childViewControllers.count;
|
|
24
|
+
[children removeObjectsInRange:NSMakeRange(index, count - index)];
|
|
28
25
|
[children addObject:controller];
|
|
29
26
|
if (children.count > 1) {
|
|
30
27
|
controller.hidesBottomBarWhenPushed = self.hidesBottomBarWhenPushed;
|
|
@@ -6,14 +6,17 @@
|
|
|
6
6
|
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
#import "UIViewController+HBD.h"
|
|
10
9
|
#import <objc/runtime.h>
|
|
11
|
-
#import "HBDNavigationController.h"
|
|
12
|
-
#import "HBDUtils.h"
|
|
13
|
-
#import "HBDModalViewController.h"
|
|
14
10
|
#import <React/RCTLog.h>
|
|
11
|
+
|
|
12
|
+
#import "UIViewController+HBD.h"
|
|
15
13
|
#import "UITabBar+Badge.h"
|
|
16
14
|
|
|
15
|
+
#import "HBDNavigationController.h"
|
|
16
|
+
#import "HBDModalViewController.h"
|
|
17
|
+
#import "HBDUtils.h"
|
|
18
|
+
#import "GlobalStyle.h"
|
|
19
|
+
|
|
17
20
|
@implementation UIViewController (HBD)
|
|
18
21
|
|
|
19
22
|
+ (void)load {
|
|
@@ -122,7 +125,7 @@
|
|
|
122
125
|
color = obj;
|
|
123
126
|
}
|
|
124
127
|
|
|
125
|
-
UIColor *colorWithBarStyle = [[
|
|
128
|
+
UIColor *colorWithBarStyle = [[GlobalStyle globalStyle] barTintColorWithBarStyle:self.hbd_barStyle];
|
|
126
129
|
if (color == nil && colorWithBarStyle != nil) {
|
|
127
130
|
color = colorWithBarStyle;
|
|
128
131
|
}
|
|
@@ -148,7 +151,7 @@
|
|
|
148
151
|
return obj;
|
|
149
152
|
}
|
|
150
153
|
|
|
151
|
-
UIColor *colorWithBarStyle = [[
|
|
154
|
+
UIColor *colorWithBarStyle = [[GlobalStyle globalStyle] tintColorWithBarStyle:self.hbd_barStyle];
|
|
152
155
|
if (colorWithBarStyle) {
|
|
153
156
|
return colorWithBarStyle;
|
|
154
157
|
}
|
|
@@ -167,7 +170,7 @@
|
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
UIBarStyle barStyle = self.hbd_barStyle;
|
|
170
|
-
UIColor *colorWithBarStyle = [[
|
|
173
|
+
UIColor *colorWithBarStyle = [[GlobalStyle globalStyle] titleTextColorWithBarStyle:barStyle];
|
|
171
174
|
NSDictionary *colorAttributes = @{NSForegroundColorAttributeName: colorWithBarStyle};
|
|
172
175
|
NSDictionary *attributes = [UINavigationBar appearance].titleTextAttributes;
|
|
173
176
|
if (attributes) {
|
package/lib/typing.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export interface NavigationOption {
|
|
|
58
58
|
}
|
|
59
59
|
export interface NavigationItem extends NavigationOption {
|
|
60
60
|
screenBackgroundColor?: Color;
|
|
61
|
+
forceTransparentDialogWindow?: boolean;
|
|
61
62
|
topBarHidden?: boolean;
|
|
62
63
|
extendedLayoutIncludesTopBar?: boolean;
|
|
63
64
|
swipeBackEnabled?: boolean;
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// HBDGarden.h
|
|
3
|
-
// HybridNavigation
|
|
4
|
-
//
|
|
5
|
-
// Created by Listen on 2017/11/26.
|
|
6
|
-
// Copyright © 2018年 Listen. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <UIKit/UIKit.h>
|
|
10
|
-
#import "HBDViewController.h"
|
|
11
|
-
#import "GlobalStyle.h"
|
|
12
|
-
|
|
13
|
-
@class HBDViewController;
|
|
14
|
-
|
|
15
|
-
@interface HBDGarden : NSObject
|
|
16
|
-
|
|
17
|
-
+ (void)createGlobalStyleWithOptions:(NSDictionary *)options;
|
|
18
|
-
|
|
19
|
-
+ (GlobalStyle *)globalStyle;
|
|
20
|
-
|
|
21
|
-
// ------
|
|
22
|
-
|
|
23
|
-
- (instancetype)initWithViewController:(HBDViewController *)vc;
|
|
24
|
-
|
|
25
|
-
- (void)setLeftBarButtonItem:(NSDictionary *)item;
|
|
26
|
-
|
|
27
|
-
- (void)setRightBarButtonItem:(NSDictionary *)item;
|
|
28
|
-
|
|
29
|
-
- (void)setLeftBarButtonItems:(NSArray *)items;
|
|
30
|
-
|
|
31
|
-
- (void)setRightBarButtonItems:(NSArray *)items;
|
|
32
|
-
|
|
33
|
-
- (void)setPassThroughTouches:(BOOL)passThrough;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@end
|