hybrid-navigation 2.12.3 → 2.13.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +63 -0
  2. package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +6 -2
  3. package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +29 -30
  4. package/android/src/main/java/com/reactnative/hybridnavigation/Navigator.java +2 -3
  5. package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +4 -4
  6. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +6 -6
  7. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +24 -33
  8. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +22 -22
  9. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +8 -8
  10. package/ios/HybridNavigation/GlobalStyle.h +0 -8
  11. package/ios/HybridNavigation/GlobalStyle.m +2 -8
  12. package/ios/HybridNavigation/HBDUtils.h +5 -13
  13. package/ios/HybridNavigation/HBDUtils.m +2 -12
  14. package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.h +0 -9
  15. package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.m +91 -67
  16. package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.h +2 -7
  17. package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +28 -26
  18. package/ios/HybridNavigation/Navigator/HBDScreenNavigator.h +0 -9
  19. package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +127 -99
  20. package/ios/HybridNavigation/Navigator/HBDStackNavigator.h +0 -9
  21. package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +199 -142
  22. package/ios/HybridNavigation/Navigator/HBDTabNavigator.h +0 -9
  23. package/ios/HybridNavigation/Navigator/HBDTabNavigator.m +144 -124
  24. package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDEventEmitter.h +1 -11
  25. package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDEventEmitter.m +4 -10
  26. package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +6 -0
  27. package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +161 -0
  28. package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.h +6 -0
  29. package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +237 -0
  30. package/ios/HybridNavigation/ReactBridge/HBDNavigator.h +20 -0
  31. package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDReactBridgeManager.h +12 -20
  32. package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDReactBridgeManager.m +91 -91
  33. package/ios/HybridNavigation/View/HBDBarButtonItem.h +0 -8
  34. package/ios/HybridNavigation/View/HBDBarButtonItem.m +1 -11
  35. package/ios/HybridNavigation/View/HBDNavigationBar.h +0 -8
  36. package/ios/HybridNavigation/View/HBDNavigationBar.m +13 -20
  37. package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -8
  38. package/ios/HybridNavigation/View/HBDReactTabBar.m +1 -8
  39. package/ios/HybridNavigation/View/HBDRootView.h +3 -10
  40. package/ios/HybridNavigation/View/HBDRootView.m +14 -25
  41. package/ios/HybridNavigation/View/HBDTitleView.h +0 -9
  42. package/ios/HybridNavigation/View/HBDTitleView.m +1 -26
  43. package/ios/HybridNavigation/View/UITabBar+Badge.h +0 -8
  44. package/ios/HybridNavigation/View/UITabBar+Badge.m +0 -7
  45. package/ios/HybridNavigation/ViewController/HBDDrawerController.h +0 -8
  46. package/ios/HybridNavigation/ViewController/HBDDrawerController.m +2 -9
  47. package/ios/HybridNavigation/ViewController/HBDFadeAnimation.h +9 -0
  48. package/ios/HybridNavigation/ViewController/HBDFadeAnimation.m +22 -0
  49. package/ios/HybridNavigation/ViewController/HBDNavigationController.h +0 -8
  50. package/ios/HybridNavigation/ViewController/HBDNavigationController.m +17 -120
  51. package/ios/HybridNavigation/ViewController/HBDPopAnimation.h +0 -7
  52. package/ios/HybridNavigation/ViewController/HBDPopAnimation.m +1 -8
  53. package/ios/HybridNavigation/ViewController/HBDPushAnimation.h +0 -7
  54. package/ios/HybridNavigation/ViewController/HBDPushAnimation.m +1 -8
  55. package/ios/HybridNavigation/ViewController/HBDReactViewController.h +0 -8
  56. package/ios/HybridNavigation/ViewController/HBDReactViewController.m +60 -27
  57. package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -8
  58. package/ios/HybridNavigation/ViewController/HBDTabBarController.m +15 -11
  59. package/ios/HybridNavigation/ViewController/HBDViewController+Garden.m +23 -33
  60. package/ios/HybridNavigation/ViewController/HBDViewController.h +1 -8
  61. package/ios/HybridNavigation/ViewController/HBDViewController.m +6 -23
  62. package/ios/HybridNavigation/ViewController/UINavigationController+HBD.h +0 -8
  63. package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -8
  64. package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +2 -16
  65. package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +32 -46
  66. package/lib/Garden.d.ts +3 -0
  67. package/lib/Garden.js +12 -1
  68. package/lib/NavigationModule.d.ts +0 -2
  69. package/lib/NavigationModule.js +0 -3
  70. package/lib/Navigator.d.ts +25 -25
  71. package/lib/Navigator.js +116 -73
  72. package/lib/index.d.ts +1 -1
  73. package/lib/index.js +1 -1
  74. package/package.json +4 -6
  75. package/src/Garden.ts +15 -1
  76. package/src/NavigationModule.ts +0 -4
  77. package/src/Navigator.ts +96 -58
  78. package/src/index.ts +1 -1
  79. package/ios/HybridNavigation/Bridge/HBDGardenModule.h +0 -14
  80. package/ios/HybridNavigation/Bridge/HBDGardenModule.m +0 -155
  81. package/ios/HybridNavigation/Bridge/HBDNavigationModule.h +0 -15
  82. package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +0 -272
  83. package/ios/HybridNavigation/Navigator/HBDNavigator.h +0 -26
@@ -1,10 +1,3 @@
1
- //
2
- // HBDPushAnimation.h
3
- // HybridNavigation
4
- //
5
- // Created by 李生 on 2019/9/26.
6
- //
7
-
8
1
  #import <UIKit/UIKit.h>
9
2
 
10
3
  NS_ASSUME_NONNULL_BEGIN
@@ -1,10 +1,3 @@
1
- //
2
- // HBDPushAnimation.m
3
- // HybridNavigation
4
- //
5
- // Created by 李生 on 2019/9/26.
6
- //
7
-
8
1
  #import "HBDPushAnimation.h"
9
2
 
10
3
  @implementation HBDPushAnimation
@@ -25,7 +18,7 @@
25
18
  [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
26
19
  fromView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -transitionContext.containerView.bounds.size.width, 0);
27
20
  toView.transform = CGAffineTransformIdentity;
28
- } completion:^(BOOL finished) {
21
+ } completion:^(BOOL finished) {
29
22
  fromView.transform = CGAffineTransformIdentity;
30
23
  toView.transform = CGAffineTransformIdentity;
31
24
  [transitionContext completeTransition:!transitionContext.transitionWasCancelled];
@@ -1,11 +1,3 @@
1
- //
2
- // HBDReactViewController.h
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2017/11/26.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
1
  #import "HBDViewController.h"
10
2
 
11
3
  @class RCTRootView;
@@ -1,16 +1,10 @@
1
- //
2
- // HBDReactViewController.m
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2017/11/26.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
1
  #import "HBDReactViewController.h"
2
+
10
3
  #import "HBDReactBridgeManager.h"
11
4
  #import "HBDTitleView.h"
12
5
  #import "HBDRootView.h"
13
6
  #import "HBDEventEmitter.h"
7
+ #import "HBDUtils.h"
14
8
 
15
9
  #import <React/RCTConvert.h>
16
10
 
@@ -22,7 +16,9 @@
22
16
 
23
17
  @end
24
18
 
25
- @implementation HBDReactViewController
19
+ @implementation HBDReactViewController {
20
+ NSArray *_reactViewConstraints;
21
+ }
26
22
 
27
23
  - (void)dealloc {
28
24
  [[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillReloadNotification object:nil];
@@ -41,15 +37,21 @@
41
37
  }
42
38
 
43
39
  - (void)loadView {
44
- RCTRootView *rootView = [[HBDRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:self.moduleName initialProperties:[self propsWithSceneId]];
40
+ RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:self.moduleName initialProperties:[self propsWithSceneId]];
41
+ self.rootView = rootView;
42
+
45
43
  BOOL passThroughTouches = [self.options[@"passThroughTouches"] boolValue];
46
44
  rootView.passThroughTouches = passThroughTouches;
47
- self.view = rootView;
48
- self.rootView = rootView;
45
+ rootView.backgroundColor = UIColor.clearColor;
46
+ rootView.translatesAutoresizingMaskIntoConstraints = NO;
47
+ self.view = [[HBDRootView alloc] initWithRootView:rootView];
48
+ [self.view addSubview:rootView];
49
+ [self updateReactViewConstraints];
49
50
  }
50
51
 
51
52
  - (void)viewDidLoad {
52
53
  [super viewDidLoad];
54
+
53
55
  NSDictionary *titleItem = self.options[@"titleItem"];
54
56
  if (titleItem && self.navigationController) {
55
57
  if (self.hbd_barHidden) {
@@ -71,6 +73,34 @@
71
73
  }
72
74
  }
73
75
 
76
+ - (void)viewSafeAreaInsetsDidChange {
77
+ [super viewSafeAreaInsetsDidChange];
78
+ [self updateReactViewConstraints];
79
+ }
80
+
81
+ - (void)updateReactViewConstraints {
82
+ if (self.isViewLoaded && self.rootView) {
83
+ [NSLayoutConstraint deactivateConstraints:_reactViewConstraints];
84
+ _reactViewConstraints = @[
85
+ [self.rootView.topAnchor
86
+ constraintEqualToAnchor:self.shouldFitWindowInsetTop ? self.view.topAnchor : self.view.safeAreaLayoutGuide.topAnchor],
87
+ [self.rootView.bottomAnchor
88
+ constraintEqualToAnchor:self.view.bottomAnchor],
89
+ [self.rootView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
90
+ [self.rootView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor]
91
+ ];
92
+ [NSLayoutConstraint activateConstraints:_reactViewConstraints];
93
+ }
94
+ }
95
+
96
+ - (BOOL)shouldFitWindowInsetTop {
97
+ if (![self.parentViewController isKindOfClass:UINavigationController.class]) {
98
+ return YES;
99
+ }
100
+ BOOL isTranslucent = self.hbd_barHidden || self.hbd_barAlpha < 1.0 || colorHasAlphaComponent(self.hbd_barTintColor);
101
+ return isTranslucent || self.extendedLayoutIncludesOpaqueBars;
102
+ }
103
+
74
104
  - (NSDictionary *)propsWithSceneId {
75
105
  NSMutableDictionary *props;
76
106
  if (self.props) {
@@ -91,15 +121,18 @@
91
121
 
92
122
  - (void)viewWillAppear:(BOOL)animated {
93
123
  [super viewWillAppear:animated];
124
+ #pragma clang diagnostic push
125
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
94
126
  self.automaticallyAdjustsScrollViewInsets = NO;
127
+ #pragma clang diagnostic pop
95
128
  id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
96
129
  if (coordinator && !coordinator.interactive) {
97
130
  if (!self.viewAppeared) {
98
131
  self.viewAppeared = YES;
99
132
  if (self.firstRenderCompleted) {
100
133
  [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
101
- KEY_SCENE_ID: self.sceneId,
102
- KEY_ON: ON_COMPONENT_APPEAR
134
+ KEY_SCENE_ID: self.sceneId,
135
+ KEY_ON: ON_COMPONENT_APPEAR
103
136
  }];
104
137
  }
105
138
  }
@@ -112,8 +145,8 @@
112
145
  self.viewAppeared = YES;
113
146
  if (self.firstRenderCompleted) {
114
147
  [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
115
- KEY_SCENE_ID: self.sceneId,
116
- KEY_ON: ON_COMPONENT_APPEAR
148
+ KEY_SCENE_ID: self.sceneId,
149
+ KEY_ON: ON_COMPONENT_APPEAR
117
150
  }];
118
151
  }
119
152
  }
@@ -127,8 +160,8 @@
127
160
  self.viewAppeared = NO;
128
161
  if (self.firstRenderCompleted) {
129
162
  [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
130
- KEY_SCENE_ID: self.sceneId,
131
- KEY_ON: ON_COMPONENT_DISAPPEAR
163
+ KEY_SCENE_ID: self.sceneId,
164
+ KEY_ON: ON_COMPONENT_DISAPPEAR
132
165
  }];
133
166
  }
134
167
  }
@@ -141,8 +174,8 @@
141
174
  self.viewAppeared = NO;
142
175
  if (self.firstRenderCompleted) {
143
176
  [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
144
- KEY_SCENE_ID: self.sceneId,
145
- KEY_ON: ON_COMPONENT_DISAPPEAR
177
+ KEY_SCENE_ID: self.sceneId,
178
+ KEY_ON: ON_COMPONENT_DISAPPEAR
146
179
  }];
147
180
  }
148
181
  }
@@ -155,8 +188,8 @@
155
188
  self.firstRenderCompleted = YES;
156
189
  if (self.viewAppeared) {
157
190
  [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
158
- KEY_SCENE_ID: self.sceneId,
159
- KEY_ON: ON_COMPONENT_APPEAR
191
+ KEY_SCENE_ID: self.sceneId,
192
+ KEY_ON: ON_COMPONENT_APPEAR
160
193
  }];
161
194
  }
162
195
  }
@@ -164,11 +197,11 @@
164
197
  - (void)didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
165
198
  [super didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
166
199
  [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
167
- KEY_ON: ON_COMPONENT_RESULT,
168
- KEY_REQUEST_CODE: @(requestCode),
169
- KEY_RESULT_CODE: @(resultCode),
170
- KEY_RESULT_DATA: RCTNullIfNil(data),
171
- KEY_SCENE_ID: self.sceneId,
200
+ KEY_ON: ON_COMPONENT_RESULT,
201
+ KEY_REQUEST_CODE: @(requestCode),
202
+ KEY_RESULT_CODE: @(resultCode),
203
+ KEY_RESULT_DATA: RCTNullIfNil(data),
204
+ KEY_SCENE_ID: self.sceneId,
172
205
  }];
173
206
  }
174
207
 
@@ -1,11 +1,3 @@
1
- //
2
- // HBDTabBarController.h
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2018/1/30.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
1
  #import <UIKit/UIKit.h>
10
2
 
11
3
  @interface HBDTabBarController : UITabBarController
@@ -1,22 +1,17 @@
1
- //
2
- // HBDTabBarController.m
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2018/1/30.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
1
  #import "HBDTabBarController.h"
2
+
10
3
  #import "HBDReactViewController.h"
11
4
  #import "HBDReactBridgeManager.h"
12
5
  #import "HBDUtils.h"
13
6
  #import "HBDEventEmitter.h"
14
7
  #import "HBDReactTabBar.h"
15
- #import "HBDRootView.h"
8
+ #import "HBDFadeAnimation.h"
16
9
 
10
+ #import <React/RCTRootView.h>
17
11
  #import <React/RCTRootViewDelegate.h>
18
12
  #import <React/RCTLog.h>
19
13
 
14
+
20
15
  @interface HBDTabBarController () <UITabBarControllerDelegate, RCTRootViewDelegate>
21
16
 
22
17
  @property(nonatomic, strong) RCTRootView *rootView;
@@ -64,7 +59,7 @@
64
59
  NSString *moduleName = self.tabBarOptions[@"tabBarModuleName"];
65
60
  NSMutableDictionary *props = [[self props] mutableCopy];
66
61
  props[@"selectedIndex"] = self.tabBarOptions[@"selectedIndex"];
67
- RCTRootView *rootView = [[HBDRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:moduleName initialProperties:props];
62
+ RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:moduleName initialProperties:props];
68
63
  rootView.backgroundColor = UIColor.clearColor;
69
64
 
70
65
  BOOL sizeIndeterminate = [self.tabBarOptions[@"sizeIndeterminate"] boolValue];
@@ -117,7 +112,7 @@
117
112
 
118
113
  - (void)setTabItem:(NSArray<NSDictionary *> *)options {
119
114
  for (NSDictionary *option in options) {
120
- NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
115
+ NSUInteger index = (NSUInteger) (option[@"index"] ? [option[@"index"] integerValue] : 0);
121
116
  if (self.hasCustomTabBar) {
122
117
  [self updateCustomTabItem:option atIndex:index];
123
118
  } else {
@@ -258,4 +253,13 @@
258
253
  return YES;
259
254
  }
260
255
 
256
+ - (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
257
+
258
+ if (toVC.viewLoaded) {
259
+ return nil;
260
+ }
261
+
262
+ return [[HBDFadeAnimation alloc] init];
263
+ }
264
+
261
265
  @end
@@ -1,12 +1,12 @@
1
- #import <React/RCTConvert.h>
2
- #import <React/RCTRootView.h>
3
-
4
1
  #import "HBDViewController+Garden.h"
5
2
 
6
3
  #import "HBDBarButtonItem.h"
7
4
  #import "HBDUtils.h"
8
5
  #import "HBDEventEmitter.h"
9
6
 
7
+ #import <React/RCTConvert.h>
8
+ #import <React/RCTRootView.h>
9
+
10
10
  @implementation HBDViewController (Garden)
11
11
 
12
12
  - (void)setLeftBarButtonItem:(NSDictionary *)item {
@@ -16,16 +16,14 @@
16
16
 
17
17
  if (item) {
18
18
  NSMutableArray *array = [[NSMutableArray alloc] init];
19
- if (@available(iOS 11.0, *)) {
20
- UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
21
- spacer.width = -8;
22
- [array addObject:spacer];
23
- }
24
-
19
+ UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
20
+ spacer.width = -8;
21
+ [array addObject:spacer];
22
+
25
23
  UIBarButtonItem *buttonItem = [self createBarButtonItem:item];
26
24
  UIView *customView = buttonItem.customView;
27
25
  if ([customView isKindOfClass:[HBDBarButton class]]) {
28
- HBDBarButton *button = (HBDBarButton *) customView;
26
+ HBDBarButton *button = (HBDBarButton *)customView;
29
27
  button.imageEdgeInsets = buttonItem.imageInsets;
30
28
  button.alignmentRectInsetsOverride = UIEdgeInsetsMake(0, 4, 0, -4);
31
29
  }
@@ -44,16 +42,14 @@
44
42
 
45
43
  if (item) {
46
44
  NSMutableArray *array = [[NSMutableArray alloc] init];
47
- if (@available(iOS 11.0, *)) {
48
- UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
49
- spacer.width = -8;
50
- [array addObject:spacer];
51
- }
52
-
45
+ UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
46
+ spacer.width = -8;
47
+ [array addObject:spacer];
48
+
53
49
  UIBarButtonItem *buttonItem = [self createBarButtonItem:item];
54
50
  UIView *customView = buttonItem.customView;
55
51
  if ([customView isKindOfClass:[HBDBarButton class]]) {
56
- HBDBarButton *button = (HBDBarButton *) customView;
52
+ HBDBarButton *button = (HBDBarButton *)customView;
57
53
  button.imageEdgeInsets = buttonItem.imageInsets;
58
54
  button.alignmentRectInsetsOverride = UIEdgeInsetsMake(0, -4, 0, 4);
59
55
  }
@@ -73,19 +69,16 @@
73
69
  if (items) {
74
70
  NSArray *barButtonItems = [self createBarButtonItems:items];
75
71
  NSMutableArray *array = [[NSMutableArray alloc] init];
76
-
77
- if (@available(iOS 11.0, *)) {
78
- UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
79
- spacer.width = -8;
80
- [array addObject:spacer];
81
- }
82
-
72
+ UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
73
+ spacer.width = -8;
74
+ [array addObject:spacer];
75
+
83
76
  [array addObjectsFromArray:barButtonItems];
84
77
  for (NSUInteger i = 0; i < barButtonItems.count; i++) {
85
78
  UIBarButtonItem *buttonItem = barButtonItems[i];
86
79
  UIView *customView = buttonItem.customView;
87
80
  if ([customView isKindOfClass:[HBDBarButton class]]) {
88
- HBDBarButton *button = (HBDBarButton *) customView;
81
+ HBDBarButton *button = (HBDBarButton *)customView;
89
82
  button.imageEdgeInsets = buttonItem.imageInsets;
90
83
  button.alignmentRectInsetsOverride = UIEdgeInsetsMake(0, 4, 0, -4);
91
84
  }
@@ -103,18 +96,16 @@
103
96
  if (items) {
104
97
  NSArray *barButtonItems = [self createBarButtonItems:items];
105
98
  NSMutableArray *array = [[NSMutableArray alloc] init];
106
- if (@available(iOS 11.0, *)) {
107
- UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
108
- spacer.width = -8;
109
- [array addObject:spacer];
110
- }
111
-
99
+ UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:NULL];
100
+ spacer.width = -8;
101
+ [array addObject:spacer];
102
+
112
103
  [array addObjectsFromArray:barButtonItems];
113
104
  for (NSUInteger i = 0; i < barButtonItems.count; i++) {
114
105
  UIBarButtonItem *buttonItem = barButtonItems[i];
115
106
  UIView *customView = buttonItem.customView;
116
107
  if ([customView isKindOfClass:[HBDBarButton class]]) {
117
- HBDBarButton *button = (HBDBarButton *) customView;
108
+ HBDBarButton *button = (HBDBarButton *)customView;
118
109
  button.imageEdgeInsets = buttonItem.imageInsets;
119
110
  button.alignmentRectInsetsOverride = UIEdgeInsetsMake(0, -4, 0, 4);
120
111
  }
@@ -135,7 +126,6 @@
135
126
 
136
127
  - (HBDBarButtonItem *)createBarButtonItem:(NSDictionary *)item {
137
128
  HBDBarButtonItem *barButtonItem;
138
-
139
129
  NSDictionary *insetsOption = item[@"insetsIOS"];
140
130
  UIEdgeInsets insets = UIEdgeInsetsZero;
141
131
  if (insetsOption) {
@@ -1,13 +1,6 @@
1
- //
2
- // HBDViewController.h
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2017/11/25.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
1
+ #import "UIViewController+HBD.h"
8
2
 
9
3
  #import <UIKit/UIKit.h>
10
- #import "UIViewController+HBD.h"
11
4
 
12
5
  @interface HBDViewController : UIViewController
13
6
 
@@ -1,18 +1,11 @@
1
- //
2
- // HBDViewController.m
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2017/11/25.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
- #import <React/RCTLog.h>
10
-
11
1
  #import "HBDViewController.h"
2
+
12
3
  #import "HBDViewController+Garden.h"
13
4
  #import "HBDUtils.h"
14
5
  #import "GlobalStyle.h"
15
6
 
7
+ #import <React/RCTLog.h>
8
+
16
9
  @interface HBDViewController ()
17
10
 
18
11
  @property(nonatomic, copy, readwrite) NSDictionary *props;
@@ -247,17 +240,9 @@
247
240
  NSNumber *backButtonHidden = options[@"backButtonHidden"];
248
241
  if (backButtonHidden) {
249
242
  if ([backButtonHidden boolValue]) {
250
- if (@available(iOS 11, *)) {
251
- [self.navigationItem setHidesBackButton:YES];
252
- } else {
253
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[UIView new]];
254
- }
243
+ [self.navigationItem setHidesBackButton:YES];
255
244
  } else {
256
- if (@available(iOS 11, *)) {
257
- [self.navigationItem setHidesBackButton:NO];
258
- } else {
259
- self.navigationItem.leftBarButtonItem = nil;
260
- }
245
+ [self.navigationItem setHidesBackButton:NO];
261
246
  }
262
247
  }
263
248
 
@@ -329,9 +314,7 @@
329
314
  }
330
315
 
331
316
  if (options[@"homeIndicatorAutoHiddenIOS"]) {
332
- if (@available(iOS 11.0, *)) {
333
- [self setNeedsUpdateOfHomeIndicatorAutoHidden];
334
- }
317
+ [self setNeedsUpdateOfHomeIndicatorAutoHidden];
335
318
  }
336
319
 
337
320
  NSNumber *passThroughTouches = options[@"passThroughTouches"];
@@ -1,11 +1,3 @@
1
- //
2
- // UINavigationController+HBD.h
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2018/6/4.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
1
  #import <UIKit/UIKit.h>
10
2
 
11
3
  @interface UINavigationController (HBD)
@@ -1,11 +1,3 @@
1
- //
2
- // UINavigationController+HBD.m
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2018/6/4.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
1
  #import "UINavigationController+HBD.h"
10
2
 
11
3
  @implementation UINavigationController (HBD)
@@ -1,17 +1,6 @@
1
- //
2
- // UIViewController+HBD.h
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2018/1/22.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
- #import <UIKit/UIKit.h>
10
1
  #import "HBDDrawerController.h"
11
2
 
12
- typedef void(^HBDDidShowActionBlock)(void);
13
-
14
- typedef void(^HBDDidHideActionBlock)(void);
3
+ #import <UIKit/UIKit.h>
15
4
 
16
5
  @interface UIViewController (HBD)
17
6
 
@@ -28,13 +17,10 @@ typedef void(^HBDDidHideActionBlock)(void);
28
17
  @property(nonatomic, assign) BOOL hbd_statusBarHidden;
29
18
 
30
19
  @property(nonatomic, assign) BOOL hbd_viewAppeared;
31
- @property(nonatomic, copy) HBDDidShowActionBlock didShowActionBlock;
32
- @property(nonatomic, copy) HBDDidHideActionBlock didHideActionBlock;
20
+ @property(nonatomic, assign) BOOL hbd_inViewHierarchy;
33
21
 
34
22
  - (void)hbd_setNeedsUpdateNavigationBar;
35
23
 
36
- @property(nonatomic, assign) BOOL hbd_extendedLayoutDidSet;
37
-
38
24
  @property(nonatomic, copy, readonly) NSString *sceneId;
39
25
  @property(nonatomic, assign) NSInteger resultCode;
40
26
  @property(nonatomic, assign) NSInteger requestCode;
@@ -1,34 +1,31 @@
1
- //
2
- // UIViewController+HBD.m
3
- // HybridNavigation
4
- //
5
- // Created by Listen on 2018/1/22.
6
- // Copyright © 2018年 Listen. All rights reserved.
7
- //
8
-
9
- #import <objc/runtime.h>
10
- #import <React/RCTLog.h>
11
-
12
1
  #import "UIViewController+HBD.h"
13
- #import "UITabBar+Badge.h"
14
2
 
15
3
  #import "HBDNavigationController.h"
16
4
  #import "HBDUtils.h"
17
5
  #import "GlobalStyle.h"
6
+ #import "UITabBar+Badge.h"
7
+
8
+ #import <React/RCTLog.h>
18
9
 
19
10
  @implementation UIViewController (HBD)
20
11
 
21
12
  + (void)load {
22
13
  static dispatch_once_t onceToken;
23
14
  dispatch_once(&onceToken, ^{
24
- Class class = [self class];
25
- hbd_exchangeImplementations(class, @selector(presentViewController:animated:completion:), @selector(hbd_presentViewController:animated:completion:));
26
- hbd_exchangeImplementations(class, @selector(dismissViewControllerAnimated:completion:), @selector(hbd_dismissViewControllerAnimated:completion:));
27
- hbd_exchangeImplementations(class, @selector(viewDidAppear:), @selector(hbd_viewDidAppear:));
28
- hbd_exchangeImplementations(class, @selector(viewDidDisappear:), @selector(hbd_viewDidDisappear:));
15
+ Class clazz = [self class];
16
+ hbd_exchangeImplementations(clazz, @selector(presentViewController:animated:completion:), @selector(hbd_presentViewController:animated:completion:));
17
+ hbd_exchangeImplementations(clazz, @selector(dismissViewControllerAnimated:completion:), @selector(hbd_dismissViewControllerAnimated:completion:));
18
+ hbd_exchangeImplementations(clazz, @selector(viewDidAppear:), @selector(hbd_viewDidAppear:));
19
+ hbd_exchangeImplementations(clazz, @selector(viewDidDisappear:), @selector(hbd_viewDidDisappear:));
20
+ hbd_exchangeImplementations(clazz, @selector(didMoveToParentViewController:), @selector(hbd_didMoveToParentViewController:));
29
21
  });
30
22
  }
31
23
 
24
+ - (void)hbd_didMoveToParentViewController:(UIViewController *)parent {
25
+ [self hbd_didMoveToParentViewController:parent];
26
+ self.hbd_inViewHierarchy = parent != nil;
27
+ }
28
+
32
29
  - (void)hbd_viewDidAppear:(BOOL)animated {
33
30
  [self hbd_viewDidAppear:animated];
34
31
  self.hbd_viewAppeared = YES;
@@ -248,29 +245,13 @@
248
245
  objc_setAssociatedObject(self, @selector(hbd_viewAppeared), @(viewAppeared), OBJC_ASSOCIATION_COPY_NONATOMIC);
249
246
  }
250
247
 
251
- - (HBDDidShowActionBlock)didShowActionBlock {
252
- return objc_getAssociatedObject(self, _cmd);
253
- }
254
-
255
- - (void)setDidShowActionBlock:(HBDDidShowActionBlock)actionBlock {
256
- objc_setAssociatedObject(self, @selector(didShowActionBlock), actionBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
257
- }
258
-
259
- - (HBDDidHideActionBlock)didHideActionBlock {
260
- return objc_getAssociatedObject(self, _cmd);
261
- }
262
-
263
- - (void)setDidHideActionBlock:(HBDDidHideActionBlock)actionBlock {
264
- objc_setAssociatedObject(self, @selector(didHideActionBlock), actionBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
265
- }
266
-
267
- - (BOOL)hbd_extendedLayoutDidSet {
248
+ - (BOOL)hbd_inViewHierarchy {
268
249
  id obj = objc_getAssociatedObject(self, _cmd);
269
- return obj ? [obj boolValue] : NO;
250
+ return obj ? [obj boolValue] : YES;
270
251
  }
271
252
 
272
- - (void)setHbd_extendedLayoutDidSet:(BOOL)didSet {
273
- objc_setAssociatedObject(self, @selector(hbd_extendedLayoutDidSet), @(didSet), OBJC_ASSOCIATION_COPY_NONATOMIC);
253
+ - (void)setHbd_inViewHierarchy:(BOOL)inViewHierarchy {
254
+ objc_setAssociatedObject(self, @selector(hbd_inViewHierarchy), @(inViewHierarchy), OBJC_ASSOCIATION_COPY_NONATOMIC);
274
255
  }
275
256
 
276
257
  - (void)hbd_setNeedsUpdateNavigationBar {
@@ -325,19 +306,24 @@
325
306
  if ([self isKindOfClass:[UITabBarController class]]) {
326
307
  UIViewController *child = ((UITabBarController *) self).selectedViewController;
327
308
  [child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
328
- } else if ([self isKindOfClass:[UINavigationController class]]) {
309
+ return;
310
+ }
311
+
312
+ if ([self isKindOfClass:[UINavigationController class]]) {
329
313
  UIViewController *child = ((UINavigationController *) self).topViewController;
330
314
  [child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
331
- } else if ([self isKindOfClass:[HBDDrawerController class]]) {
315
+ return;
316
+ }
317
+
318
+ if ([self isKindOfClass:[HBDDrawerController class]]) {
332
319
  UIViewController *child = ((HBDDrawerController *) self).contentController;
333
320
  [child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
334
- } else {
335
- NSArray *children = self.childViewControllers;
336
- if (children) {
337
- for (UIViewController *vc in children) {
338
- [vc didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
339
- }
340
- }
321
+ return;
322
+ }
323
+
324
+ NSArray *children = self.childViewControllers;
325
+ for (UIViewController *vc in children) {
326
+ [vc didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
341
327
  }
342
328
  }
343
329
 
package/lib/Garden.d.ts CHANGED
@@ -65,6 +65,9 @@ declare type Nullable<T> = {
65
65
  export declare class Garden {
66
66
  sceneId: string;
67
67
  static setStyle(style?: Style): void;
68
+ static statusBarHeight: number;
69
+ static toolbarHeight: number;
70
+ static topBarHeight: number;
68
71
  constructor(sceneId: string);
69
72
  setLeftBarButtonItem(buttonItem: Nullable<BarButtonItem> | null): void;
70
73
  setRightBarButtonItem(buttonItem: Nullable<BarButtonItem> | null): void;