hybrid-navigation 3.1.5 → 4.0.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 +4 -4
- package/android/build.gradle +1 -2
- package/android/src/main/java/androidx/fragment/app/InternalFragment.java +22 -0
- package/android/src/main/java/com/navigation/androidx/AppUtils.java +54 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +211 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +685 -0
- package/android/src/main/java/com/navigation/androidx/BarStyle.java +7 -0
- package/android/src/main/java/com/navigation/androidx/DefaultTabBarProvider.java +89 -0
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +57 -0
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +392 -0
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +318 -0
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +86 -0
- package/android/src/main/java/com/navigation/androidx/PresentableActivity.java +23 -0
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +195 -0
- package/android/src/main/java/com/navigation/androidx/PresentationStyle.java +5 -0
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +111 -0
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +287 -0
- package/android/src/main/java/com/navigation/androidx/StackLayoutInflater.java +34 -0
- package/android/src/main/java/com/navigation/androidx/Style.java +141 -0
- package/android/src/main/java/com/navigation/androidx/SystemUI.java +240 -0
- package/android/src/main/java/com/navigation/androidx/SystemUI30.java +87 -0
- package/android/src/main/java/com/navigation/androidx/TabBar.java +353 -0
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +313 -0
- package/android/src/main/java/com/navigation/androidx/TabBarItem.java +102 -0
- package/android/src/main/java/com/navigation/androidx/TabBarProvider.java +30 -0
- package/android/src/main/java/com/navigation/androidx/TabView.java +226 -0
- package/android/src/main/java/com/navigation/androidx/TransitionAnimation.java +31 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +6 -243
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +8 -141
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +33 -71
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +12 -61
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +0 -47
- package/android/src/main/java/com/reactnative/hybridnavigation/Parameters.java +3 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +2 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +3 -89
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +0 -5
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +0 -18
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactSurfaceCleanup.java +54 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +1 -10
- package/android/src/main/res/anim/{nav_push_translucent_enter.xml → nav_delay.xml} +1 -1
- package/android/src/main/res/anim/{nav_pop_translucent_enter.xml → nav_dismiss_enter.xml} +1 -1
- package/android/src/main/res/anim/nav_dismiss_exit.xml +6 -0
- package/android/src/main/res/anim/nav_fade_in.xml +5 -0
- package/android/src/main/res/anim/nav_fade_out.xml +5 -0
- package/android/src/main/res/anim/nav_pop_enter.xml +6 -0
- package/android/src/main/res/anim/nav_pop_exit.xml +6 -0
- package/android/src/main/res/anim/nav_present_enter.xml +6 -0
- package/android/src/main/res/anim/{nav_pop_translucent_exit.xml → nav_present_exit.xml} +1 -1
- package/android/src/main/res/anim/nav_push_enter.xml +6 -0
- package/android/src/main/res/anim/{nav_push_translucent_exit.xml → nav_push_exit.xml} +2 -1
- package/android/src/main/res/drawable/nav_dot_badge_background.xml +5 -0
- package/android/src/main/res/drawable/nav_text_badge_background.xml +5 -0
- package/android/src/main/res/drawable-v21/nav_toolbar_button_item_background.xml +24 -0
- package/android/src/main/res/layout/nav_fragment_drawer.xml +23 -0
- package/android/src/main/res/layout/nav_fragment_navigation.xml +7 -0
- package/android/src/main/res/layout/nav_fragment_tabbar.xml +13 -0
- package/android/src/main/res/layout/nav_tab_bar_container.xml +15 -0
- package/android/src/main/res/layout/nav_tab_bar_item.xml +49 -0
- package/android/src/main/res/values/dimens.xml +11 -0
- package/android/src/main/res/values/strings.xml +1 -0
- package/dist/NativeEvent.d.ts +0 -5
- package/dist/NativeGarden.d.ts +0 -5
- package/dist/Navigation.d.ts +1 -11
- package/dist/Navigation.js +1 -31
- package/dist/Navigator.js +0 -4
- package/dist/Options.d.ts +2 -70
- package/dist/Options.js +0 -4
- package/ios/GlobalStyle.h +1 -9
- package/ios/GlobalStyle.mm +48 -310
- package/ios/HBDUtils.h +0 -14
- package/ios/HBDUtils.mm +1 -116
- package/ios/HybridNavigation.h +0 -3
- package/ios/Navigator/HBDScreenNavigator.mm +12 -4
- package/ios/Navigator/HBDStackNavigator.mm +36 -39
- package/ios/React/HBDNativeGarden.mm +0 -40
- package/ios/React/HBDNativeNavigation.mm +21 -16
- package/ios/View/HBDRootView.h +0 -2
- package/ios/View/HBDRootView.mm +0 -21
- package/ios/ViewController/HBDDrawerController.mm +3 -11
- package/ios/ViewController/HBDFadeAnimation.mm +10 -26
- package/ios/ViewController/HBDNavigationController.h +0 -6
- package/ios/ViewController/HBDNavigationController.mm +42 -661
- package/ios/ViewController/HBDReactViewController.mm +7 -101
- package/ios/ViewController/HBDTabBarController.mm +10 -6
- package/ios/ViewController/HBDViewController.mm +58 -182
- package/ios/ViewController/UINavigationController+HBD.mm +0 -3
- package/ios/ViewController/UIViewController+HBD.h +0 -9
- package/ios/ViewController/UIViewController+HBD.mm +1 -131
- package/package.json +1 -1
- package/src/NativeEvent.ts +0 -6
- package/src/NativeGarden.ts +0 -11
- package/src/Navigation.ts +2 -68
- package/src/Navigator.ts +0 -5
- package/src/Options.ts +2 -76
- package/dist/handler/BarButtonEventHandler.d.ts +0 -10
- package/dist/handler/BarButtonEventHandler.js +0 -38
- package/ios/View/HBDBackBarButtonItem.h +0 -9
- package/ios/View/HBDBackBarButtonItem.mm +0 -13
- package/ios/View/HBDBarButtonItem.h +0 -24
- package/ios/View/HBDBarButtonItem.mm +0 -69
- package/ios/View/HBDNavigationBar.h +0 -15
- package/ios/View/HBDNavigationBar.mm +0 -207
- package/ios/View/HBDTitleView.h +0 -7
- package/ios/View/HBDTitleView.mm +0 -66
- package/ios/ViewController/HBDPopAnimation.h +0 -9
- package/ios/ViewController/HBDPopAnimation.mm +0 -27
- package/ios/ViewController/HBDPushAnimation.h +0 -9
- package/ios/ViewController/HBDPushAnimation.mm +0 -28
- package/ios/ViewController/HBDViewController+Garden.h +0 -17
- package/ios/ViewController/HBDViewController+Garden.mm +0 -183
- package/src/handler/BarButtonEventHandler.ts +0 -50
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
#import "HBDNavigationBar.h"
|
|
2
|
-
|
|
3
|
-
#import "HBDUtils.h"
|
|
4
|
-
#import <React/RCTLog.h>
|
|
5
|
-
|
|
6
|
-
#define hairlineWidth (1.f/[UIScreen mainScreen].scale)
|
|
7
|
-
|
|
8
|
-
@interface HBDNavigationBar ()
|
|
9
|
-
|
|
10
|
-
@property(nonatomic, strong, readwrite) UIImageView *fakeShadowView;
|
|
11
|
-
@property(nonatomic, strong, readwrite) UIView *fakeBackgroundView;
|
|
12
|
-
|
|
13
|
-
@end
|
|
14
|
-
|
|
15
|
-
@implementation HBDNavigationBar
|
|
16
|
-
|
|
17
|
-
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
|
|
18
|
-
if (!self.isUserInteractionEnabled || self.isHidden || self.alpha < 0.01) {
|
|
19
|
-
return nil;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
UIView *view = [super hitTest:point withEvent:event];
|
|
23
|
-
NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
24
|
-
|
|
25
|
-
// RCTLogInfo(@"viewName:%@", viewName);
|
|
26
|
-
|
|
27
|
-
NSArray *array = @[@"UINavigationBarContentView", @"UIButtonBarStackView", @"UIKit.NavigationBarContentView", NSStringFromClass([self class])];
|
|
28
|
-
if ([array containsObject:viewName] && self.fakeBackgroundView.alpha < 0.01) {
|
|
29
|
-
return nil;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return view;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
- (void)layoutSubviews {
|
|
36
|
-
[super layoutSubviews];
|
|
37
|
-
self.fakeBackgroundView.frame = self.fakeBackgroundView.superview.bounds;
|
|
38
|
-
self.fakeShadowView.frame = CGRectMake(0, CGRectGetHeight(self.fakeShadowView.superview.bounds) - hairlineWidth, CGRectGetWidth(self.fakeShadowView.superview.bounds), hairlineWidth);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
- (void)setBarTintColor:(UIColor *)barTintColor {
|
|
42
|
-
[super setBarTintColor:barTintColor];
|
|
43
|
-
self.fakeBackgroundView.backgroundColor = barTintColor;
|
|
44
|
-
[self makesureFakeView];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
- (UIView *)fakeBackgroundView {
|
|
48
|
-
if (!_fakeBackgroundView) {
|
|
49
|
-
[super setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
50
|
-
_fakeBackgroundView = [[UIView alloc] init];
|
|
51
|
-
_fakeBackgroundView.userInteractionEnabled = NO;
|
|
52
|
-
_fakeBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
53
|
-
}
|
|
54
|
-
return _fakeBackgroundView;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
- (void)setTranslucent:(BOOL)translucent {
|
|
58
|
-
// prevent default behavior
|
|
59
|
-
[super setTranslucent:YES];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics {
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
- (void)setShadowImage:(UIImage *)shadowImage {
|
|
67
|
-
self.fakeShadowView.image = shadowImage;
|
|
68
|
-
if (shadowImage) {
|
|
69
|
-
self.fakeShadowView.backgroundColor = nil;
|
|
70
|
-
} else {
|
|
71
|
-
self.fakeShadowView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:77.0 / 255];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
- (UIImageView *)fakeShadowView {
|
|
77
|
-
if (!_fakeShadowView) {
|
|
78
|
-
[super setShadowImage:[UIImage new]];
|
|
79
|
-
_fakeShadowView = [[UIImageView alloc] init];
|
|
80
|
-
_fakeShadowView.userInteractionEnabled = NO;
|
|
81
|
-
_fakeShadowView.contentScaleFactor = 1;
|
|
82
|
-
_fakeShadowView.layer.allowsEdgeAntialiasing = YES;
|
|
83
|
-
}
|
|
84
|
-
return _fakeShadowView;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
- (void)makesureFakeView {
|
|
88
|
-
[UIView setAnimationsEnabled:NO];
|
|
89
|
-
if (!self.fakeBackgroundView.superview) {
|
|
90
|
-
[[self.subviews firstObject] insertSubview:self.fakeBackgroundView atIndex:0];
|
|
91
|
-
self.fakeBackgroundView.frame = self.fakeBackgroundView.superview.bounds;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (!self.fakeShadowView.superview) {
|
|
95
|
-
[[self.subviews firstObject] insertSubview:self.fakeShadowView aboveSubview:self.fakeBackgroundView];
|
|
96
|
-
self.fakeShadowView.frame = CGRectMake(0, CGRectGetHeight(self.fakeShadowView.superview.bounds) - hairlineWidth, CGRectGetWidth(self.fakeShadowView.superview.bounds), hairlineWidth);
|
|
97
|
-
}
|
|
98
|
-
[UIView setAnimationsEnabled:YES];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
- (UILabel *)backButtonLabel {
|
|
102
|
-
UIView *navigationBarContentView = [self getViewFromContext:self withKeyPath:@"visualProvider.contentView"];
|
|
103
|
-
__block UILabel *backButtonLabel = nil;
|
|
104
|
-
[navigationBarContentView.subviews enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(__kindof UIView *_Nonnull subview, NSUInteger idx, BOOL *_Nonnull stop) {
|
|
105
|
-
if ([subview isKindOfClass:NSClassFromString(@"_UIButtonBarButton")]) {
|
|
106
|
-
UIButton *titleButton = (UIButton *)[self getViewFromContext:subview withKeyPath:@"visualProvider.titleButton"];
|
|
107
|
-
backButtonLabel = titleButton.titleLabel;
|
|
108
|
-
*stop = YES;
|
|
109
|
-
}
|
|
110
|
-
}];
|
|
111
|
-
return backButtonLabel;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 兼容 iOS26
|
|
115
|
-
- (UIView *)getViewFromContext:(id)context withKeyPath:(NSString *)keyPath {
|
|
116
|
-
if (!context || !keyPath) {
|
|
117
|
-
return nil;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (@available(iOS 26.0, *)) {
|
|
121
|
-
// 如果 context 是 UIView,先尝试通过遍历 subviews 查找包含 "ContentView" 的视图
|
|
122
|
-
if ([context isKindOfClass:[UIView class]]) {
|
|
123
|
-
UIView *view = (UIView *)context;
|
|
124
|
-
__block UIView *contentView = nil;
|
|
125
|
-
|
|
126
|
-
// 使用标准的 enumerateObjectsUsingBlock 替代 qmui_firstMatchWithBlock
|
|
127
|
-
[view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull item, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
128
|
-
if ([NSStringFromClass(item.class) containsString:@"ContentView"]) {
|
|
129
|
-
contentView = item;
|
|
130
|
-
*stop = YES;
|
|
131
|
-
}
|
|
132
|
-
}];
|
|
133
|
-
|
|
134
|
-
if (contentView) return contentView;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Xcode 26 编译在 iOS 26 上时,无法用以前的 KVC 方式获取 contentView,所以改为通过 Ivar 获取
|
|
138
|
-
// 解析 keyPath,获取 provider key(例如从 "visualProvider.contentView" 中获取 "visualProvider")
|
|
139
|
-
NSArray *components = [keyPath componentsSeparatedByString:@"."];
|
|
140
|
-
if (components.count > 0) {
|
|
141
|
-
NSString *providerKey = components.firstObject;
|
|
142
|
-
NSObject *provider = [context valueForKey:providerKey];
|
|
143
|
-
|
|
144
|
-
if (provider && components.count > 1) {
|
|
145
|
-
NSString *targetKey = components.lastObject;
|
|
146
|
-
__block UIView *result = nil;
|
|
147
|
-
|
|
148
|
-
// 使用 Runtime API 直接获取 Ivar 列表,替代 qmui_enumrateIvarsUsingBlock
|
|
149
|
-
unsigned int ivarCount = 0;
|
|
150
|
-
Ivar *ivars = class_copyIvarList([provider class], &ivarCount);
|
|
151
|
-
|
|
152
|
-
if (ivars) {
|
|
153
|
-
for (unsigned int i = 0; i < ivarCount && !result; i++) {
|
|
154
|
-
Ivar ivar = ivars[i];
|
|
155
|
-
const char *ivarName = ivar_getName(ivar);
|
|
156
|
-
|
|
157
|
-
if (ivarName) {
|
|
158
|
-
NSString *ivarNameString = [NSString stringWithUTF8String:ivarName];
|
|
159
|
-
// 检查 ivar 名称是否包含 targetKey
|
|
160
|
-
if ([ivarNameString containsString:targetKey]) {
|
|
161
|
-
// 直接使用 object_getIvar 获取 Ivar 值,替代 getObjectIvarValue
|
|
162
|
-
result = object_getIvar(provider, ivar);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
free(ivars);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return result;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// 在 iOS 26.0 以下,直接通过 KVC 获取
|
|
175
|
-
return [context valueForKeyPath:keyPath];
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@end
|
|
179
|
-
|
|
180
|
-
@implementation UILabel (NavigationBarTransition)
|
|
181
|
-
|
|
182
|
-
- (UIColor *)hbd_specifiedTextColor {
|
|
183
|
-
return objc_getAssociatedObject(self, _cmd);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
- (void)setHbd_specifiedTextColor:(UIColor *)color {
|
|
187
|
-
objc_setAssociatedObject(self, @selector(hbd_specifiedTextColor), color, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
+ (void)load {
|
|
191
|
-
static dispatch_once_t onceToken;
|
|
192
|
-
dispatch_once(&onceToken, ^{
|
|
193
|
-
Class clazz = [self class];
|
|
194
|
-
hbd_exchangeImplementations(clazz, @selector(setAttributedText:), @selector(hbd_setAttributedText:));
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
- (void)hbd_setAttributedText:(NSAttributedString *)attributedText {
|
|
199
|
-
if (self.hbd_specifiedTextColor) {
|
|
200
|
-
NSMutableAttributedString *mutableAttributedText = [attributedText isKindOfClass:NSMutableAttributedString.class] ? attributedText : [attributedText mutableCopy];
|
|
201
|
-
[mutableAttributedText addAttributes:@{NSForegroundColorAttributeName: self.hbd_specifiedTextColor} range:NSMakeRange(0, mutableAttributedText.length)];
|
|
202
|
-
attributedText = mutableAttributedText;
|
|
203
|
-
}
|
|
204
|
-
[self hbd_setAttributedText:attributedText];
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
@end
|
package/ios/View/HBDTitleView.h
DELETED
package/ios/View/HBDTitleView.mm
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
#import "HBDTitleView.h"
|
|
2
|
-
|
|
3
|
-
#import <React/RCTRootViewDelegate.h>
|
|
4
|
-
|
|
5
|
-
@interface HBDTitleView () <RCTRootViewDelegate>
|
|
6
|
-
|
|
7
|
-
@property(nonatomic, assign) CGSize fittingSize;
|
|
8
|
-
@property(nonatomic, strong) RCTSurfaceHostingProxyRootView *rootView;
|
|
9
|
-
@property(nonatomic, assign) CGRect barBounds;
|
|
10
|
-
|
|
11
|
-
@end
|
|
12
|
-
|
|
13
|
-
@implementation HBDTitleView
|
|
14
|
-
|
|
15
|
-
- (instancetype)initWithRootView:(RCTSurfaceHostingProxyRootView *)rootView layoutFittingSize:(CGSize)fittingSize navigationBarBounds:(CGRect)bounds {
|
|
16
|
-
if (self = [super init]) {
|
|
17
|
-
rootView.backgroundColor = [UIColor clearColor];
|
|
18
|
-
_rootView = rootView;
|
|
19
|
-
_fittingSize = fittingSize;
|
|
20
|
-
_barBounds = bounds;
|
|
21
|
-
if (CGSizeEqualToSize(fittingSize, UILayoutFittingCompressedSize)) {
|
|
22
|
-
rootView.delegate = self;
|
|
23
|
-
rootView.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
|
|
24
|
-
} else {
|
|
25
|
-
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
26
|
-
rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
27
|
-
rootView.frame = bounds;
|
|
28
|
-
self.bounds = bounds;
|
|
29
|
-
}
|
|
30
|
-
[self addSubview:rootView];
|
|
31
|
-
}
|
|
32
|
-
return self;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
- (CGSize)intrinsicContentSize {
|
|
36
|
-
return self.fittingSize;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
- (void)setFrame:(CGRect)frame {
|
|
40
|
-
CGFloat d = self.barBounds.size.width - frame.size.width;
|
|
41
|
-
if (d <= 40 && CGSizeEqualToSize(self.fittingSize, UILayoutFittingExpandedSize)) {
|
|
42
|
-
[super setFrame:CGRectInset(frame, -d / 2, 0)];
|
|
43
|
-
} else {
|
|
44
|
-
[super setFrame:frame];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
- (void)rootViewDidChangeIntrinsicSize:(RCTSurfaceHostingProxyRootView *)rootView {
|
|
49
|
-
CGPoint center = self.center;
|
|
50
|
-
self.bounds = CGRectMake(0, 0, rootView.intrinsicContentSize.width, rootView.intrinsicContentSize.height);
|
|
51
|
-
self.rootView.frame = CGRectMake(0, 0, rootView.intrinsicContentSize.width, rootView.intrinsicContentSize.height);
|
|
52
|
-
self.center = center;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
- (UINavigationBar *)navigationBarInView:(UIView *)view {
|
|
56
|
-
if (!view) {
|
|
57
|
-
return nil;
|
|
58
|
-
}
|
|
59
|
-
if ([view isKindOfClass:[UINavigationBar class]]) {
|
|
60
|
-
return (UINavigationBar *) view;
|
|
61
|
-
} else {
|
|
62
|
-
return [self navigationBarInView:view.superview];
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
#import "HBDPopAnimation.h"
|
|
2
|
-
|
|
3
|
-
@implementation HBDPopAnimation
|
|
4
|
-
|
|
5
|
-
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
|
|
6
|
-
return 0.25f;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
|
|
10
|
-
UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
|
|
11
|
-
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
|
|
12
|
-
|
|
13
|
-
[[transitionContext containerView] insertSubview:toView belowSubview:fromView];
|
|
14
|
-
|
|
15
|
-
toView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -transitionContext.containerView.bounds.size.width, 0);
|
|
16
|
-
|
|
17
|
-
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
|
|
18
|
-
toView.transform = CGAffineTransformIdentity;
|
|
19
|
-
fromView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, transitionContext.containerView.bounds.size.width, 0);
|
|
20
|
-
} completion:^(BOOL finished) {
|
|
21
|
-
toView.transform = CGAffineTransformIdentity;
|
|
22
|
-
fromView.transform = CGAffineTransformIdentity;
|
|
23
|
-
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
|
|
24
|
-
}];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#import "HBDPushAnimation.h"
|
|
2
|
-
|
|
3
|
-
@implementation HBDPushAnimation
|
|
4
|
-
|
|
5
|
-
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
|
|
6
|
-
return 0.3f;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
|
|
10
|
-
|
|
11
|
-
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
|
|
12
|
-
[transitionContext.containerView addSubview:toView];
|
|
13
|
-
|
|
14
|
-
toView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, transitionContext.containerView.bounds.size.width, 0);
|
|
15
|
-
|
|
16
|
-
UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
|
|
17
|
-
|
|
18
|
-
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
|
|
19
|
-
fromView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -transitionContext.containerView.bounds.size.width, 0);
|
|
20
|
-
toView.transform = CGAffineTransformIdentity;
|
|
21
|
-
} completion:^(BOOL finished) {
|
|
22
|
-
fromView.transform = CGAffineTransformIdentity;
|
|
23
|
-
toView.transform = CGAffineTransformIdentity;
|
|
24
|
-
[transitionContext completeTransition:!transitionContext.transitionWasCancelled];
|
|
25
|
-
}];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#import "HBDViewController.h"
|
|
2
|
-
|
|
3
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
-
|
|
5
|
-
@interface HBDViewController (Garden)
|
|
6
|
-
|
|
7
|
-
- (void)setLeftBarButtonItem:(NSDictionary *)item;
|
|
8
|
-
|
|
9
|
-
- (void)setRightBarButtonItem:(NSDictionary *)item;
|
|
10
|
-
|
|
11
|
-
- (void)setLeftBarButtonItems:(NSArray *)items;
|
|
12
|
-
|
|
13
|
-
- (void)setRightBarButtonItems:(NSArray *)items;
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
#import "HBDViewController+Garden.h"
|
|
2
|
-
|
|
3
|
-
#import "HBDBarButtonItem.h"
|
|
4
|
-
#import "HBDUtils.h"
|
|
5
|
-
#import "HBDNativeEvent.h"
|
|
6
|
-
|
|
7
|
-
#import <React/RCTConvert.h>
|
|
8
|
-
|
|
9
|
-
@implementation HBDViewController (Garden)
|
|
10
|
-
|
|
11
|
-
- (void)applyImageInsetsForButtonItem:(UIBarButtonItem *)buttonItem
|
|
12
|
-
button:(HBDImageBarButton *)button
|
|
13
|
-
alignmentRectInsets:(UIEdgeInsets)alignmentRectInsets {
|
|
14
|
-
UIEdgeInsets imageInsets = buttonItem.imageInsets;
|
|
15
|
-
if (!UIEdgeInsetsEqualToEdgeInsets(imageInsets, UIEdgeInsetsZero)) {
|
|
16
|
-
UIButtonConfiguration *configuration = button.configuration ? [button.configuration copy] : [UIButtonConfiguration plainButtonConfiguration];
|
|
17
|
-
if (!configuration.image) {
|
|
18
|
-
UIImage *currentImage = [button imageForState:UIControlStateNormal];
|
|
19
|
-
if (currentImage) {
|
|
20
|
-
configuration.image = currentImage;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
configuration.contentInsets = NSDirectionalEdgeInsetsMake(imageInsets.top, imageInsets.left, imageInsets.bottom, imageInsets.right);
|
|
24
|
-
button.configuration = configuration;
|
|
25
|
-
}
|
|
26
|
-
button.alignmentRectInsetsOverride = alignmentRectInsets;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
- (void)setLeftBarButtonItem:(NSDictionary *)item {
|
|
30
|
-
if (self.hbd_barHidden) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (item) {
|
|
35
|
-
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
36
|
-
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
|
|
37
|
-
spacer.width = -8;
|
|
38
|
-
[array addObject:spacer];
|
|
39
|
-
|
|
40
|
-
UIBarButtonItem *buttonItem = [self createBarButtonItem:item];
|
|
41
|
-
UIView *customView = buttonItem.customView;
|
|
42
|
-
if ([customView isKindOfClass:[HBDImageBarButton class]]) {
|
|
43
|
-
HBDImageBarButton *button = (HBDImageBarButton *)customView;
|
|
44
|
-
[self applyImageInsetsForButtonItem:buttonItem button:button alignmentRectInsets:UIEdgeInsetsMake(0, 4, 0, -4)];
|
|
45
|
-
}
|
|
46
|
-
[array addObject:buttonItem];
|
|
47
|
-
|
|
48
|
-
self.navigationItem.leftBarButtonItems = array;
|
|
49
|
-
} else {
|
|
50
|
-
self.navigationItem.leftBarButtonItems = nil;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
- (void)setRightBarButtonItem:(NSDictionary *)item {
|
|
55
|
-
if (self.hbd_barHidden) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (item) {
|
|
60
|
-
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
61
|
-
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
|
|
62
|
-
spacer.width = -8;
|
|
63
|
-
[array addObject:spacer];
|
|
64
|
-
|
|
65
|
-
UIBarButtonItem *buttonItem = [self createBarButtonItem:item];
|
|
66
|
-
UIView *customView = buttonItem.customView;
|
|
67
|
-
if ([customView isKindOfClass:[HBDImageBarButton class]]) {
|
|
68
|
-
HBDImageBarButton *button = (HBDImageBarButton *)customView;
|
|
69
|
-
[self applyImageInsetsForButtonItem:buttonItem button:button alignmentRectInsets:UIEdgeInsetsMake(0, -4, 0, 4)];
|
|
70
|
-
}
|
|
71
|
-
[array addObject:buttonItem];
|
|
72
|
-
|
|
73
|
-
self.navigationItem.rightBarButtonItems = array;
|
|
74
|
-
} else {
|
|
75
|
-
self.navigationItem.rightBarButtonItems = nil;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
- (void)setLeftBarButtonItems:(NSArray *)items {
|
|
80
|
-
if (self.hbd_barHidden) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (items) {
|
|
85
|
-
NSArray *barButtonItems = [self createBarButtonItems:items];
|
|
86
|
-
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
87
|
-
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
|
|
88
|
-
spacer.width = -8;
|
|
89
|
-
[array addObject:spacer];
|
|
90
|
-
|
|
91
|
-
[array addObjectsFromArray:barButtonItems];
|
|
92
|
-
for (NSUInteger i = 0; i < barButtonItems.count; i++) {
|
|
93
|
-
UIBarButtonItem *buttonItem = barButtonItems[i];
|
|
94
|
-
UIView *customView = buttonItem.customView;
|
|
95
|
-
if ([customView isKindOfClass:[HBDImageBarButton class]]) {
|
|
96
|
-
HBDImageBarButton *button = (HBDImageBarButton *)customView;
|
|
97
|
-
[self applyImageInsetsForButtonItem:buttonItem button:button alignmentRectInsets:UIEdgeInsetsMake(0, 4, 0, -4)];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
self.navigationItem.leftBarButtonItems = array;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
- (void)setRightBarButtonItems:(NSArray *)items {
|
|
106
|
-
if (self.hbd_barHidden) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (items) {
|
|
111
|
-
NSArray *barButtonItems = [self createBarButtonItems:items];
|
|
112
|
-
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
113
|
-
UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
|
|
114
|
-
spacer.width = -8;
|
|
115
|
-
[array addObject:spacer];
|
|
116
|
-
|
|
117
|
-
[array addObjectsFromArray:barButtonItems];
|
|
118
|
-
for (NSUInteger i = 0; i < barButtonItems.count; i++) {
|
|
119
|
-
UIBarButtonItem *buttonItem = barButtonItems[i];
|
|
120
|
-
UIView *customView = buttonItem.customView;
|
|
121
|
-
if ([customView isKindOfClass:[HBDImageBarButton class]]) {
|
|
122
|
-
HBDImageBarButton *button = (HBDImageBarButton *)customView;
|
|
123
|
-
[self applyImageInsetsForButtonItem:buttonItem button:button alignmentRectInsets:UIEdgeInsetsMake(0, -4, 0, 4)];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
self.navigationItem.rightBarButtonItems = array;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
- (NSArray *)createBarButtonItems:(NSArray *)items {
|
|
132
|
-
NSMutableArray *array = [[NSMutableArray alloc] init];
|
|
133
|
-
for (NSUInteger i = 0; i < items.count; i++) {
|
|
134
|
-
NSDictionary *item = items[i];
|
|
135
|
-
[array addObject:[self createBarButtonItem:item]];
|
|
136
|
-
}
|
|
137
|
-
return array;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
- (HBDBarButtonItem *)createBarButtonItem:(NSDictionary *)item {
|
|
141
|
-
HBDBarButtonItem *barButtonItem;
|
|
142
|
-
NSDictionary *icon = item[@"icon"];
|
|
143
|
-
if (RCTNilIfNull(icon)) {
|
|
144
|
-
UIImage *iconImage = [HBDUtils UIImage:icon];
|
|
145
|
-
if (item[@"renderOriginal"] && [item[@"renderOriginal"] boolValue]) {
|
|
146
|
-
iconImage = [iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
147
|
-
}
|
|
148
|
-
barButtonItem = [[HBDBarButtonItem alloc] initWithImage:iconImage style:UIBarButtonItemStylePlain];
|
|
149
|
-
} else {
|
|
150
|
-
NSString *title = item[@"title"];
|
|
151
|
-
barButtonItem = [[HBDBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain];
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
NSNumber *enabled = item[@"enabled"];
|
|
155
|
-
if (enabled) {
|
|
156
|
-
barButtonItem.enabled = [enabled boolValue];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
NSString *tintColor = item[@"tintColor"];
|
|
161
|
-
if (tintColor) {
|
|
162
|
-
barButtonItem.tintColor = [HBDUtils colorWithHexString:tintColor];
|
|
163
|
-
UIView *customView = barButtonItem.customView;
|
|
164
|
-
if ([customView isKindOfClass:[HBDImageBarButton class]] || [customView isKindOfClass:[HBDTextBarButton class]]) {
|
|
165
|
-
UIButton *button = (UIButton *)customView;
|
|
166
|
-
button.tintColor = [HBDUtils colorWithHexString:tintColor];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
NSString *action = item[@"action"];
|
|
171
|
-
NSString *sceneId = self.sceneId;
|
|
172
|
-
if (action) {
|
|
173
|
-
barButtonItem.actionBlock = ^{
|
|
174
|
-
[[HBDNativeEvent getInstance] emitOnBarButtonItemClick:@{
|
|
175
|
-
@"action": action,
|
|
176
|
-
@"sceneId": sceneId,
|
|
177
|
-
}];
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
return barButtonItem;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
@end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import NativeEvent from '../NativeEvent';
|
|
2
|
-
|
|
3
|
-
type BarButtonClickEventListener = (sceneId: string, value: Function) => void;
|
|
4
|
-
|
|
5
|
-
export default class BarButtonEventHandler {
|
|
6
|
-
private actions: Record<string, Function> = {};
|
|
7
|
-
private keyPairs: Record<string, string[]> = {};
|
|
8
|
-
private actionIdGenerator = 0;
|
|
9
|
-
|
|
10
|
-
bindBarButtonClickEvent(sceneId: string, item: object | null | undefined): object | null {
|
|
11
|
-
if (item === null || item === undefined) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return JSON.parse(
|
|
16
|
-
JSON.stringify(item, (key, value) => {
|
|
17
|
-
if (key !== 'action' || typeof value !== 'function') {
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const actionKey = 'ON_BAR_BUTTON_ITEM_CLICK_' + this.actionIdGenerator++;
|
|
22
|
-
|
|
23
|
-
if (!this.keyPairs[sceneId]) {
|
|
24
|
-
this.keyPairs[sceneId] = [];
|
|
25
|
-
}
|
|
26
|
-
this.keyPairs[sceneId].push(actionKey);
|
|
27
|
-
this.actions[actionKey] = value;
|
|
28
|
-
|
|
29
|
-
return actionKey;
|
|
30
|
-
}),
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
unbindBarButtonClickEvent(sceneId: string): void {
|
|
35
|
-
const keys = this.keyPairs[sceneId];
|
|
36
|
-
delete this.keyPairs[sceneId];
|
|
37
|
-
if (keys) {
|
|
38
|
-
keys.forEach(key => delete this.actions[key]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setBarButtonClickEventListener(handler: BarButtonClickEventListener) {
|
|
43
|
-
NativeEvent.onBarButtonItemClick(({ sceneId, action }) => {
|
|
44
|
-
const listeners = this.actions;
|
|
45
|
-
if (listeners[action]) {
|
|
46
|
-
handler(sceneId, listeners[action]);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|