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.
Files changed (48) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/android/build.gradle +1 -1
  3. package/ios/HybridNavigation/Bridge/HBDEventEmitter.h +16 -16
  4. package/ios/HybridNavigation/Bridge/HBDEventEmitter.m +33 -33
  5. package/ios/HybridNavigation/Bridge/HBDGardenModule.m +43 -25
  6. package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +83 -58
  7. package/ios/HybridNavigation/Bridge/HBDReactBridgeManager.h +3 -3
  8. package/ios/HybridNavigation/Bridge/HBDReactBridgeManager.m +57 -61
  9. package/ios/HybridNavigation/GlobalStyle.h +7 -7
  10. package/ios/HybridNavigation/GlobalStyle.m +86 -86
  11. package/ios/HybridNavigation/HBDGarden.m +28 -28
  12. package/ios/HybridNavigation/HBDUtils.h +4 -4
  13. package/ios/HybridNavigation/HBDUtils.m +43 -49
  14. package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.m +24 -24
  15. package/ios/HybridNavigation/Navigator/HBDNavigator.h +2 -2
  16. package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.h +4 -4
  17. package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +19 -20
  18. package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +24 -26
  19. package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +31 -30
  20. package/ios/HybridNavigation/Navigator/HBDTabNavigator.m +54 -56
  21. package/ios/HybridNavigation/View/HBDBarButtonItem.h +1 -1
  22. package/ios/HybridNavigation/View/HBDBarButtonItem.m +5 -5
  23. package/ios/HybridNavigation/View/HBDNavigationBar.h +4 -4
  24. package/ios/HybridNavigation/View/HBDNavigationBar.m +19 -20
  25. package/ios/HybridNavigation/View/HBDReactTabBar.m +3 -3
  26. package/ios/HybridNavigation/View/HBDRootView.m +3 -3
  27. package/ios/HybridNavigation/View/HBDTitleView.m +7 -7
  28. package/ios/HybridNavigation/View/UITabBar+Badge.h +1 -0
  29. package/ios/HybridNavigation/View/UITabBar+Badge.m +6 -6
  30. package/ios/HybridNavigation/ViewController/HBDDrawerController.h +8 -5
  31. package/ios/HybridNavigation/ViewController/HBDDrawerController.m +39 -38
  32. package/ios/HybridNavigation/ViewController/HBDModalViewController.h +2 -2
  33. package/ios/HybridNavigation/ViewController/HBDModalViewController.m +45 -44
  34. package/ios/HybridNavigation/ViewController/HBDNavigationController.h +1 -1
  35. package/ios/HybridNavigation/ViewController/HBDNavigationController.m +111 -113
  36. package/ios/HybridNavigation/ViewController/HBDPopAnimation.m +4 -4
  37. package/ios/HybridNavigation/ViewController/HBDPushAnimation.m +4 -4
  38. package/ios/HybridNavigation/ViewController/HBDReactViewController.m +24 -26
  39. package/ios/HybridNavigation/ViewController/HBDTabBarController.h +1 -1
  40. package/ios/HybridNavigation/ViewController/HBDTabBarController.m +25 -26
  41. package/ios/HybridNavigation/ViewController/HBDViewController.m +31 -32
  42. package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +5 -4
  43. package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +20 -19
  44. package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +35 -36
  45. package/lib/DeepLink.js +5 -5
  46. package/lib/hooks.d.ts +1 -1
  47. package/lib/hooks.js +4 -7
  48. package/package.json +1 -1
@@ -22,9 +22,9 @@
22
22
  }
23
23
 
24
24
  - (UIViewController *)createViewControllerWithLayout:(NSDictionary *)layout {
25
- NSDictionary *stack = [layout objectForKey:self.name];
25
+ NSDictionary *stack = layout[self.name];
26
26
  if (stack) {
27
- NSArray *children = [stack objectForKey:@"children"];
27
+ NSArray *children = stack[@"children"];
28
28
  UIViewController *root = [[HBDReactBridgeManager get] controllerWithLayout:children.firstObject];
29
29
  if (root) {
30
30
  return [[HBDNavigationController alloc] initWithRootViewController:root];
@@ -35,19 +35,19 @@
35
35
 
36
36
  - (NSDictionary *)buildRouteGraphWithViewController:(UIViewController *)vc {
37
37
  if ([vc isKindOfClass:[HBDNavigationController class]]) {
38
- HBDNavigationController *nav = (HBDNavigationController *)vc;
38
+ HBDNavigationController *nav = (HBDNavigationController *) vc;
39
39
  NSMutableArray *children = [[NSMutableArray alloc] init];
40
- for (NSInteger i = 0; i < nav.childViewControllers.count; i++) {
40
+ for (NSUInteger i = 0; i < nav.childViewControllers.count; i++) {
41
41
  UIViewController *child = nav.childViewControllers[i];
42
42
  NSDictionary *graph = [[HBDReactBridgeManager get] buildRouteGraphWithViewController:child];
43
43
  [children addObject:graph];
44
44
  }
45
-
45
+
46
46
  return @{
47
- @"layout": @"stack",
48
- @"sceneId": vc.sceneId,
49
- @"children": children,
50
- @"mode": [vc hbd_mode],
47
+ @"layout": @"stack",
48
+ @"sceneId": vc.sceneId,
49
+ @"children": children,
50
+ @"mode": [vc hbd_mode],
51
51
  };
52
52
  }
53
53
  return nil;
@@ -55,7 +55,7 @@
55
55
 
56
56
  - (HBDViewController *)primaryViewControllerWithViewController:(UIViewController *)vc {
57
57
  if ([vc isKindOfClass:[UINavigationController class]]) {
58
- UINavigationController *nav = (UINavigationController *)vc;
58
+ UINavigationController *nav = (UINavigationController *) vc;
59
59
  return [[HBDReactBridgeManager get] primaryViewControllerWithViewController:nav.topViewController];
60
60
  }
61
61
  return nil;
@@ -67,14 +67,14 @@
67
67
  resolve(@(NO));
68
68
  return;
69
69
  }
70
-
70
+
71
71
  if (!nav.hbd_viewAppeared) {
72
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
72
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
73
73
  [self handleNavigationWithViewController:target action:action extras:extras resolver:resolve rejecter:reject];
74
74
  });
75
75
  return;
76
76
  }
77
-
77
+
78
78
  UIViewController *viewController = nil;
79
79
 
80
80
  if ([action isEqualToString:@"push"]) {
@@ -95,20 +95,21 @@
95
95
  [nav popViewControllerAnimated:YES];
96
96
  } else if ([action isEqualToString:@"popTo"]) {
97
97
  NSArray *children = nav.childViewControllers;
98
- NSInteger count = children.count;
99
- NSString *moduleName = [extras objectForKey:@"moduleName"];
100
- BOOL inclusive = [[extras objectForKey:@"inclusive"] boolValue];
101
- for (NSInteger i = count - 1; i > -1; i--) {
102
- HBDViewController *vc = [children objectAtIndex:i];
98
+ NSUInteger count = children.count;
99
+ NSString *moduleName = extras[@"moduleName"];
100
+ BOOL inclusive = [extras[@"inclusive"] boolValue];
101
+ for (NSUInteger i = count; i > 0; i--) {
102
+ NSUInteger index = i - 1;
103
+ HBDViewController *vc = children[index];
103
104
  if ([moduleName isEqualToString:vc.moduleName] || [moduleName isEqualToString:vc.sceneId]) {
104
105
  viewController = vc;
105
- if (inclusive && i - 1 > -1) {
106
- viewController = [children objectAtIndex:(i - 1)];
106
+ if (inclusive && i > 0) {
107
+ viewController = children[index];
107
108
  }
108
109
  break;
109
110
  }
110
111
  }
111
-
112
+
112
113
  if (viewController) {
113
114
  nav.topViewController.didHideActionBlock = ^{
114
115
  resolve(@(YES));
@@ -133,7 +134,7 @@
133
134
  };
134
135
  [nav redirectToViewController:viewController target:target animated:YES];
135
136
  } else if ([action isEqualToString:@"pushLayout"]) {
136
- NSDictionary *layout = [extras objectForKey:@"layout"];
137
+ NSDictionary *layout = extras[@"layout"];
137
138
  viewController = [[HBDReactBridgeManager get] controllerWithLayout:layout];
138
139
  if (viewController) {
139
140
  viewController.hidesBottomBarWhenPushed = nav.hidesBottomBarWhenPushed;
@@ -148,11 +149,11 @@
148
149
  }
149
150
 
150
151
  - (UIViewController *)createViewControllerWithExtras:(NSDictionary *)extras {
151
- NSString *moduleName = [extras objectForKey:@"moduleName"];
152
+ NSString *moduleName = extras[@"moduleName"];
152
153
  HBDViewController *viewController = nil;
153
154
  if (moduleName) {
154
- NSDictionary *props = [extras objectForKey:@"props"];
155
- NSDictionary *options = [extras objectForKey:@"options"];
155
+ NSDictionary *props = extras[@"props"];
156
+ NSDictionary *options = extras[@"options"];
156
157
  viewController = [[HBDReactBridgeManager get] controllerWithModuleName:moduleName props:props options:options];
157
158
  }
158
159
  return viewController;
@@ -161,20 +162,20 @@
161
162
  - (UINavigationController *)navigationControllerForController:(UIViewController *)controller {
162
163
  UINavigationController *nav = nil;
163
164
  if ([controller isKindOfClass:[UINavigationController class]]) {
164
- nav = (UINavigationController *)controller;
165
+ nav = (UINavigationController *) controller;
165
166
  } else {
166
167
  nav = controller.navigationController;
167
168
  }
168
-
169
+
169
170
  if (!nav && controller.drawerController) {
170
171
  HBDDrawerController *drawer = controller.drawerController;
171
172
  if ([drawer.contentController isKindOfClass:[UITabBarController class]]) {
172
- UITabBarController *tabBar = (UITabBarController *)drawer.contentController;
173
+ UITabBarController *tabBar = (UITabBarController *) drawer.contentController;
173
174
  if ([tabBar.selectedViewController isKindOfClass:[UINavigationController class]]) {
174
175
  nav = tabBar.selectedViewController;
175
176
  }
176
- } else if ([drawer.contentController isKindOfClass:[UINavigationController class]]){
177
- nav = (UINavigationController *)drawer.contentController;
177
+ } else if ([drawer.contentController isKindOfClass:[UINavigationController class]]) {
178
+ nav = (UINavigationController *) drawer.contentController;
178
179
  } else {
179
180
  nav = drawer.contentController.navigationController;
180
181
  }
@@ -10,8 +10,6 @@
10
10
  #import "HBDTabBarController.h"
11
11
  #import "HBDReactBridgeManager.h"
12
12
  #import "HBDUtils.h"
13
- #import "HBDGarden.h"
14
- #import "GlobalStyle.h"
15
13
  #import <React/RCTUtils.h>
16
14
 
17
15
  @implementation HBDTabNavigator
@@ -21,18 +19,18 @@
21
19
  }
22
20
 
23
21
  - (NSArray<NSString *> *)supportActions {
24
- return @[ @"switchTab" ];
22
+ return @[@"switchTab"];
25
23
  }
26
24
 
27
25
  - (UIViewController *)createViewControllerWithLayout:(NSDictionary *)layout {
28
- NSDictionary *tabs = [layout objectForKey:self.name];
29
- NSArray *children = [tabs objectForKey:@"children"];
26
+ NSDictionary *tabs = layout[self.name];
27
+ NSArray *children = tabs[@"children"];
30
28
  if (children) {
31
- NSDictionary *options = [tabs objectForKey:@"options"];
29
+ NSDictionary *options = tabs[@"options"];
32
30
  NSMutableDictionary *tabBarOptions = [@{} mutableCopy];
33
- NSString *tabBarModuleName = [options objectForKey:@"tabBarModuleName"];
31
+ NSString *tabBarModuleName = options[@"tabBarModuleName"];
34
32
  BOOL hasCustomTabBar = tabBarModuleName.length > 0;
35
-
33
+
36
34
  NSMutableArray *controllers = [[NSMutableArray alloc] initWithCapacity:4];
37
35
  for (NSDictionary *tab in children) {
38
36
  UIViewController *vc = [[HBDReactBridgeManager get] controllerWithLayout:tab];
@@ -40,65 +38,65 @@
40
38
  [controllers addObject:vc];
41
39
  }
42
40
  }
43
-
41
+
44
42
  if (hasCustomTabBar) {
45
43
  NSArray *tabInfos = [self tabsInfoWithChildren:controllers];
46
44
  tabBarOptions[@"tabs"] = tabInfos;
47
45
  tabBarOptions[@"tabBarModuleName"] = tabBarModuleName;
48
- tabBarOptions[@"sizeIndeterminate"] = @([[options objectForKey:@"sizeIndeterminate"] boolValue]);
49
- tabBarOptions[@"selectedIndex"] = [options objectForKey:@"selectedIndex"] ?: @(0);
46
+ tabBarOptions[@"sizeIndeterminate"] = @([options[@"sizeIndeterminate"] boolValue]);
47
+ tabBarOptions[@"selectedIndex"] = options[@"selectedIndex"] ?: @(0);
50
48
  GlobalStyle *style = [HBDGarden globalStyle];
51
49
  tabBarOptions[@"tabBarItemColor"] = style.tabBarItemColorHexString;
52
50
  tabBarOptions[@"tabBarUnselectedItemColor"] = style.tabBarUnselectedItemColorHexString;
53
51
  tabBarOptions[@"badgeColor"] = style.badgeColorHexString;
54
52
  }
55
-
53
+
56
54
  HBDTabBarController *tabBarController = nil;
57
-
55
+
58
56
  if (hasCustomTabBar) {
59
57
  tabBarController = [[HBDTabBarController alloc] initWithTabBarOptions:tabBarOptions];
60
58
  } else {
61
59
  tabBarController = [[HBDTabBarController alloc] init];
62
60
  }
63
-
61
+
64
62
  [tabBarController setViewControllers:controllers];
65
-
63
+
66
64
  if (options) {
67
- NSNumber *selectedIndex = [options objectForKey:@"selectedIndex"];
65
+ NSNumber *selectedIndex = options[@"selectedIndex"];
68
66
  if (selectedIndex) {
69
67
  tabBarController.intercepted = NO;
70
- tabBarController.selectedIndex = [selectedIndex integerValue];
68
+ tabBarController.selectedIndex = (NSUInteger) [selectedIndex integerValue];
71
69
  tabBarController.intercepted = YES;
72
70
  }
73
71
  }
74
-
72
+
75
73
  return tabBarController;
76
74
  }
77
75
  return nil;
78
76
  }
79
77
 
80
78
  - (NSArray<NSDictionary *> *)tabsInfoWithChildren:(NSArray<UIViewController *> *)children {
81
- NSInteger count = children.count;
79
+ NSUInteger count = children.count;
82
80
  UIViewController *vc = nil;
83
81
  NSMutableArray *tabInfos = [[NSMutableArray alloc] initWithCapacity:4];
84
- for (NSInteger i = 0; i < count; i ++) {
82
+ for (NSUInteger i = 0; i < count; i++) {
85
83
  vc = children[i];
86
84
  if ([vc isKindOfClass:[UINavigationController class]]) {
87
- UINavigationController *nav = (UINavigationController *)vc;
85
+ UINavigationController *nav = (UINavigationController *) vc;
88
86
  vc = nav.childViewControllers[0];
89
87
  }
90
88
  if ([vc isKindOfClass:[HBDViewController class]]) {
91
- HBDViewController *hbdVC = (HBDViewController *)vc;
92
- NSDictionary *tabItem = [hbdVC.options objectForKey:@"tabItem"];
89
+ HBDViewController *hbdVC = (HBDViewController *) vc;
90
+ NSDictionary *tabItem = hbdVC.options[@"tabItem"];
93
91
  if (tabItem) {
94
92
  NSDictionary *tab = @{
95
- @"index": @(i),
96
- @"sceneId": hbdVC.sceneId,
97
- @"moduleName": RCTNullIfNil(hbdVC.moduleName),
98
- @"icon": RCTNullIfNil([HBDUtils iconUriFromUri:tabItem[@"icon"][@"uri"]]),
99
- @"unselectedIcon": RCTNullIfNil([HBDUtils iconUriFromUri:tabItem[@"unselectedIcon"][@"uri"]]),
100
- @"title": RCTNullIfNil(tabItem[@"title"]),
101
- };
93
+ @"index": @(i),
94
+ @"sceneId": hbdVC.sceneId,
95
+ @"moduleName": RCTNullIfNil(hbdVC.moduleName),
96
+ @"icon": RCTNullIfNil([HBDUtils iconUriFromUri:tabItem[@"icon"][@"uri"]]),
97
+ @"unselectedIcon": RCTNullIfNil([HBDUtils iconUriFromUri:tabItem[@"unselectedIcon"][@"uri"]]),
98
+ @"title": RCTNullIfNil(tabItem[@"title"]),
99
+ };
102
100
  [tabInfos addObject:tab];
103
101
  }
104
102
  }
@@ -108,19 +106,19 @@
108
106
 
109
107
  - (NSDictionary *)buildRouteGraphWithViewController:(UIViewController *)vc {
110
108
  if ([vc isKindOfClass:[HBDTabBarController class]]) {
111
- HBDTabBarController *tabBarController = (HBDTabBarController *)vc;
109
+ HBDTabBarController *tabBarController = (HBDTabBarController *) vc;
112
110
  NSMutableArray *children = [[NSMutableArray alloc] init];
113
- for (NSInteger i = 0; i < tabBarController.childViewControllers.count; i++) {
111
+ for (NSUInteger i = 0; i < tabBarController.childViewControllers.count; i++) {
114
112
  UIViewController *child = tabBarController.childViewControllers[i];
115
113
  NSDictionary *graph = [[HBDReactBridgeManager get] buildRouteGraphWithViewController:child];
116
114
  [children addObject:graph];
117
115
  }
118
116
  return @{
119
- @"layout": self.name,
120
- @"sceneId": vc.sceneId,
121
- @"children": children,
122
- @"mode": [vc hbd_mode],
123
- @"selectedIndex": @(tabBarController.selectedIndex)
117
+ @"layout": self.name,
118
+ @"sceneId": vc.sceneId,
119
+ @"children": children,
120
+ @"mode": [vc hbd_mode],
121
+ @"selectedIndex": @(tabBarController.selectedIndex)
124
122
  };
125
123
  }
126
124
  return nil;
@@ -128,59 +126,59 @@
128
126
 
129
127
  - (HBDViewController *)primaryViewControllerWithViewController:(UIViewController *)vc {
130
128
  if ([vc isKindOfClass:[UITabBarController class]]) {
131
- UITabBarController *tabBarVc = (UITabBarController *)vc;
129
+ UITabBarController *tabBarVc = (UITabBarController *) vc;
132
130
  return [[HBDReactBridgeManager get] primaryViewControllerWithViewController:tabBarVc.selectedViewController];
133
131
  }
134
132
  return nil;
135
133
  }
136
134
 
137
135
  - (void)handleNavigationWithViewController:(UIViewController *)vc action:(NSString *)action extras:(NSDictionary *)extras resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
138
-
136
+
139
137
  UITabBarController *tabBarController = nil;
140
138
  if ([vc isKindOfClass:[UITabBarController class]]) {
141
- tabBarController = (UITabBarController *)vc;
139
+ tabBarController = (UITabBarController *) vc;
142
140
  } else {
143
141
  tabBarController = vc.tabBarController;
144
142
  }
145
-
143
+
146
144
  if (!tabBarController) {
147
145
  resolve(@(NO));
148
146
  return;
149
147
  }
150
-
148
+
151
149
  if (!tabBarController.hbd_viewAppeared) {
152
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
150
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
153
151
  [self handleNavigationWithViewController:vc action:action extras:extras resolver:resolve rejecter:reject];
154
152
  });
155
153
  return;
156
154
  }
157
-
155
+
158
156
  if ([action isEqualToString:@"switchTab"]) {
159
- BOOL popToRoot = [[extras objectForKey:@"popToRoot"] boolValue];
160
- NSNumber *from = [extras objectForKey:@"from"];
161
- NSInteger to = [[extras objectForKey:@"to"] integerValue];
157
+ BOOL popToRoot = [extras[@"popToRoot"] boolValue];
158
+ NSNumber *from = extras[@"from"];
159
+ NSUInteger to = [extras[@"to"] integerValue];
162
160
 
163
161
  if (from && [from integerValue] == to) {
164
162
  resolve(@(YES));
165
163
  return;
166
164
  }
167
-
165
+
168
166
  if (popToRoot) {
169
- UIViewController *vc = [tabBarController selectedViewController];
167
+ UIViewController *selectedViewController = [tabBarController selectedViewController];
170
168
  UINavigationController *nav = nil;
171
- if ([vc isKindOfClass:[UINavigationController class]]) {
172
- nav = (UINavigationController *)vc;
169
+ if ([selectedViewController isKindOfClass:[UINavigationController class]]) {
170
+ nav = (UINavigationController *) selectedViewController;
173
171
  } else {
174
- nav = vc.navigationController;
172
+ nav = selectedViewController.navigationController;
175
173
  }
176
-
174
+
177
175
  if (nav && nav.childViewControllers.count > 1) {
178
176
  [nav popToRootViewControllerAnimated:NO];
179
177
  }
180
178
  }
181
-
179
+
182
180
  if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
183
- HBDTabBarController *hbdTabBarVC = (HBDTabBarController *)tabBarController;
181
+ HBDTabBarController *hbdTabBarVC = (HBDTabBarController *) tabBarController;
184
182
  hbdTabBarVC.intercepted = NO;
185
183
  tabBarController.selectedIndex = to;
186
184
  hbdTabBarVC.intercepted = YES;
@@ -188,7 +186,7 @@
188
186
  tabBarController.selectedIndex = to;
189
187
  }
190
188
  }
191
-
189
+
192
190
  resolve(@(YES));
193
191
  }
194
192
 
@@ -23,6 +23,6 @@ typedef void(^HBDButtonActionBlock)(void);
23
23
 
24
24
  @interface HBDBarButton : UIButton
25
25
 
26
- @property (nonatomic) UIEdgeInsets alignmentRectInsetsOverride;
26
+ @property(nonatomic) UIEdgeInsets alignmentRectInsetsOverride;
27
27
 
28
28
  @end
@@ -15,10 +15,10 @@
15
15
  }
16
16
 
17
17
  - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
18
- CGSize acturalSize = self.frame.size;
18
+ CGSize intrinsicSize = self.frame.size;
19
19
  CGSize minimumSize = CGSizeMake(40, 40);
20
- CGFloat verticalMargin = acturalSize.height - minimumSize.height >= 0 ? 0 : ((minimumSize.height - acturalSize.height ) / 2);
21
- CGFloat horizontalMargin = acturalSize.width - minimumSize.width >= 0 ? 0 : ((minimumSize.width - acturalSize.width ) / 2);
20
+ CGFloat verticalMargin = intrinsicSize.height - minimumSize.height >= 0 ? 0 : ((minimumSize.height - intrinsicSize.height) / 2);
21
+ CGFloat horizontalMargin = intrinsicSize.width - minimumSize.width >= 0 ? 0 : ((minimumSize.width - intrinsicSize.width) / 2);
22
22
  CGRect newArea = CGRectMake(self.bounds.origin.x - horizontalMargin, self.bounds.origin.y - verticalMargin, self.bounds.size.width + 2 * horizontalMargin, self.bounds.size.height + 2 * verticalMargin);
23
23
  return CGRectContainsPoint(newArea, point);
24
24
  }
@@ -33,7 +33,7 @@
33
33
 
34
34
  @end
35
35
 
36
- @interface HBDBarButtonItem()
36
+ @interface HBDBarButtonItem ()
37
37
 
38
38
  @end
39
39
 
@@ -41,7 +41,7 @@
41
41
 
42
42
  - (instancetype)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style {
43
43
  HBDBarButton *button = [HBDBarButton buttonWithType:UIButtonTypeSystem];
44
- if(@available(iOS 11, *)){
44
+ if (@available(iOS 11, *)) {
45
45
  button.translatesAutoresizingMaskIntoConstraints = NO;
46
46
  }
47
47
  [button setFrame:CGRectMake(0, 0, 32, 32)];
@@ -10,10 +10,10 @@
10
10
 
11
11
  @interface HBDNavigationBar : UINavigationBar
12
12
 
13
- @property (nonatomic, strong, readonly) UIImageView *shadowImageView;
14
- @property (nonatomic, strong, readonly) UIVisualEffectView *fakeView;
15
- @property (nonatomic, strong, readonly) UILabel *backButtonLabel;
16
- @property (nonatomic, strong, readonly) UIView *hbd_backgroundView;
13
+ @property(nonatomic, strong, readonly) UIImageView *shadowImageView;
14
+ @property(nonatomic, strong, readonly) UIVisualEffectView *fakeView;
15
+ @property(nonatomic, strong, readonly) UILabel *backButtonLabel;
16
+ @property(nonatomic, strong, readonly) UIView *hbd_backgroundView;
17
17
 
18
18
  @end
19
19
 
@@ -7,13 +7,12 @@
7
7
  //
8
8
 
9
9
  #import "HBDNavigationBar.h"
10
- #import "HBDTitleView.h"
11
10
  #import "HBDUtils.h"
12
11
 
13
- @interface HBDNavigationBar()
12
+ @interface HBDNavigationBar ()
14
13
 
15
- @property (nonatomic, strong, readwrite) UIImageView *shadowImageView;
16
- @property (nonatomic, strong, readwrite) UIVisualEffectView *fakeView;
14
+ @property(nonatomic, strong, readwrite) UIImageView *shadowImageView;
15
+ @property(nonatomic, strong, readwrite) UIVisualEffectView *fakeView;
17
16
 
18
17
  @end
19
18
 
@@ -23,14 +22,14 @@
23
22
  if (!self.isUserInteractionEnabled || self.isHidden || self.alpha <= 0.01) {
24
23
  return nil;
25
24
  }
26
-
25
+
27
26
  UIView *view = [super hitTest:point withEvent:event];
28
27
  NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
29
-
28
+
30
29
  if (view && [viewName isEqualToString:@"HBDNavigationBar"]) {
31
30
  for (UIView *subview in self.subviews) {
32
31
  NSString *viewName = [[[subview classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
33
- NSArray *array = @[ @"UINavigationItemButtonView" ];
32
+ NSArray *array = @[@"UINavigationItemButtonView"];
34
33
  if ([array containsObject:viewName]) {
35
34
  CGPoint convertedPoint = [self convertPoint:point toView:subview];
36
35
  CGRect bounds = subview.bounds;
@@ -43,18 +42,18 @@
43
42
  }
44
43
  }
45
44
  }
46
-
47
- NSArray *array = @[ @"UINavigationBarContentView", @"UIButtonBarStackView", @"HBDNavigationBar" ];
45
+
46
+ NSArray *array = @[@"UINavigationBarContentView", @"UIButtonBarStackView", @"HBDNavigationBar"];
48
47
  if ([array containsObject:viewName]) {
49
48
  if (self.fakeView.alpha < 0.01) {
50
49
  return nil;
51
50
  }
52
51
  }
53
-
52
+
54
53
  if (CGRectEqualToRect(view.bounds, CGRectZero)) {
55
54
  return nil;
56
55
  }
57
-
56
+
58
57
  return view;
59
58
  }
60
59
 
@@ -70,11 +69,11 @@
70
69
 
71
70
  - (void)setBarTintColor:(UIColor *)barTintColor {
72
71
  [super setBarTintColor:barTintColor];
73
- self.fakeView.subviews.lastObject.backgroundColor = barTintColor;
72
+ self.fakeView.subviews.lastObject.backgroundColor = barTintColor;
74
73
  [self makeSureFakeView];
75
74
  }
76
75
 
77
- - (UIView *)fakeView {
76
+ - (UIVisualEffectView *)fakeView {
78
77
  if (!_fakeView) {
79
78
  [super setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
80
79
  _fakeView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
@@ -91,7 +90,7 @@
91
90
  }
92
91
 
93
92
  - (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics {
94
-
93
+
95
94
  }
96
95
 
97
96
  - (void)setShadowImage:(UIImage *)shadowImage {
@@ -99,7 +98,7 @@
99
98
  if (shadowImage) {
100
99
  self.shadowImageView.backgroundColor = nil;
101
100
  } else {
102
- self.shadowImageView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:77.0/255];
101
+ self.shadowImageView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:77.0 / 255];
103
102
  }
104
103
  }
105
104
 
@@ -120,7 +119,7 @@
120
119
  [[self.subviews firstObject] insertSubview:_fakeView atIndex:0];
121
120
  self.fakeView.frame = self.fakeView.superview.bounds;
122
121
  }
123
-
122
+
124
123
  if (!self.shadowImageView.superview) {
125
124
  [[self.subviews firstObject] insertSubview:_shadowImageView aboveSubview:self.fakeView];
126
125
  self.shadowImageView.frame = CGRectMake(0, CGRectGetHeight(self.shadowImageView.superview.bounds), CGRectGetWidth(self.shadowImageView.superview.bounds), 0.5);
@@ -129,10 +128,10 @@
129
128
  }
130
129
 
131
130
  - (UILabel *)backButtonLabel {
132
- if (@available(iOS 11, *)) ; else return nil;
131
+ if (@available(iOS 11, *)); else return nil;
133
132
  UIView *navigationBarContentView = [self valueForKeyPath:@"visualProvider.contentView"];
134
133
  __block UILabel *backButtonLabel = nil;
135
- [navigationBarContentView.subviews enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(__kindof UIView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) {
134
+ [navigationBarContentView.subviews enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(__kindof UIView *_Nonnull subview, NSUInteger idx, BOOL *_Nonnull stop) {
136
135
  if ([subview isKindOfClass:NSClassFromString(@"_UIButtonBarButton")]) {
137
136
  UIButton *titleButton = [subview valueForKeyPath:@"visualProvider.titleButton"];
138
137
  backButtonLabel = titleButton.titleLabel;
@@ -155,7 +154,7 @@
155
154
  }
156
155
 
157
156
  + (void)load {
158
- if (@available(iOS 11, *)) ; else return;
157
+ if (@available(iOS 11, *)); else return;
159
158
  static dispatch_once_t onceToken;
160
159
  dispatch_once(&onceToken, ^{
161
160
  Class class = [self class];
@@ -166,7 +165,7 @@
166
165
  - (void)hbd_setAttributedText:(NSAttributedString *)attributedText {
167
166
  if (self.hbd_specifiedTextColor) {
168
167
  NSMutableAttributedString *mutableAttributedText = [attributedText isKindOfClass:NSMutableAttributedString.class] ? attributedText : [attributedText mutableCopy];
169
- [mutableAttributedText addAttributes:@{ NSForegroundColorAttributeName : self.hbd_specifiedTextColor} range:NSMakeRange(0, mutableAttributedText.length)];
168
+ [mutableAttributedText addAttributes:@{NSForegroundColorAttributeName: self.hbd_specifiedTextColor} range:NSMakeRange(0, mutableAttributedText.length)];
170
169
  attributedText = mutableAttributedText;
171
170
  }
172
171
  [self hbd_setAttributedText:attributedText];
@@ -11,7 +11,7 @@
11
11
 
12
12
  @interface HBDReactTabBar ()
13
13
 
14
- @property (nonatomic, strong) RCTRootView *rootView;
14
+ @property(nonatomic, strong) RCTRootView *rootView;
15
15
 
16
16
  @end
17
17
 
@@ -21,7 +21,7 @@
21
21
  if (!self.isUserInteractionEnabled || self.isHidden || self.alpha <= 0.01) {
22
22
  return nil;
23
23
  }
24
-
24
+
25
25
  UIView *hitView = [super hitTest:point withEvent:event];
26
26
  if (hitView == self.rootView) {
27
27
  return hitView;
@@ -35,7 +35,7 @@
35
35
 
36
36
  - (void)addSubview:(UIView *)view {
37
37
  if ([view isKindOfClass:[RCTRootView class]]) {
38
- self.rootView = (RCTRootView *)view;
38
+ self.rootView = (RCTRootView *) view;
39
39
  }
40
40
  [super addSubview:view];
41
41
  }
@@ -16,7 +16,7 @@
16
16
  UIView *view = self.contentView.subviews.firstObject;
17
17
  while (view) {
18
18
  if (view == hitView) {
19
- if (CGRectEqualToRect(view.frame, self.bounds)) {
19
+ if (CGRectEqualToRect(view.frame, self.bounds)) {
20
20
  return nil;
21
21
  } else {
22
22
  break;
@@ -26,11 +26,11 @@
26
26
  }
27
27
  }
28
28
  }
29
-
29
+
30
30
  if (!hitView.window) {
31
31
  return nil;
32
32
  }
33
-
33
+
34
34
  return hitView;
35
35
  }
36
36
 
@@ -9,11 +9,11 @@
9
9
  #import "HBDTitleView.h"
10
10
  #import <React/RCTRootViewDelegate.h>
11
11
 
12
- @interface HBDTitleView() <RCTRootViewDelegate>
12
+ @interface HBDTitleView () <RCTRootViewDelegate>
13
13
 
14
- @property (nonatomic, assign) CGSize fittingSize;
15
- @property (nonatomic, strong) RCTRootView *rootView;
16
- @property (nonatomic, assign) CGRect barBounds;
14
+ @property(nonatomic, assign) CGSize fittingSize;
15
+ @property(nonatomic, strong) RCTRootView *rootView;
16
+ @property(nonatomic, assign) CGRect barBounds;
17
17
 
18
18
  @end
19
19
 
@@ -57,7 +57,7 @@
57
57
  self.bounds = CGRectMake(0, 0, rootView.intrinsicContentSize.width, rootView.intrinsicContentSize.height);
58
58
  self.rootView.frame = CGRectMake(0, 0, rootView.intrinsicContentSize.width, rootView.intrinsicContentSize.height);
59
59
  self.center = center;
60
-
60
+
61
61
  // 修正版本在 10.0 的情况
62
62
  NSString *version = [UIDevice currentDevice].systemVersion;
63
63
  if (version.doubleValue < 11.0) {
@@ -66,7 +66,7 @@
66
66
  for (UIView *subview in bar.subviews) {
67
67
  NSString *viewName = [[[subview classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
68
68
  if ([viewName isEqualToString:@"UINavigationItemButtonView"]) {
69
- CGFloat dx = subview.frame.origin.x + subview.frame.size.width + self.bounds.size.width /2 + 6 - center.x;
69
+ CGFloat dx = subview.frame.origin.x + subview.frame.size.width + self.bounds.size.width / 2 + 6 - center.x;
70
70
  if (dx > 0) {
71
71
  self.center = CGPointMake(center.x + dx, center.y);
72
72
  }
@@ -82,7 +82,7 @@
82
82
  return nil;
83
83
  }
84
84
  if ([view isKindOfClass:[UINavigationBar class]]) {
85
- return (UINavigationBar *)view;
85
+ return (UINavigationBar *) view;
86
86
  } else {
87
87
  return [self navigationBarInView:view.superview];
88
88
  }
@@ -11,6 +11,7 @@
11
11
  @interface UITabBar (DotBadge)
12
12
 
13
13
  - (void)showDotBadgeAtIndex:(NSInteger)index;
14
+
14
15
  - (void)hideDotBadgeAtIndex:(NSInteger)index;
15
16
 
16
17
  @end