hybrid-navigation 2.12.4 → 2.13.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +6 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +29 -30
- package/android/src/main/java/com/reactnative/hybridnavigation/Navigator.java +2 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +4 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +24 -33
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +22 -22
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +8 -8
- package/ios/HybridNavigation/GlobalStyle.h +0 -8
- package/ios/HybridNavigation/GlobalStyle.m +2 -8
- package/ios/HybridNavigation/HBDAnimationObserver.h +24 -0
- package/ios/HybridNavigation/HBDAnimationObserver.m +45 -0
- package/ios/HybridNavigation/HBDUtils.h +5 -13
- package/ios/HybridNavigation/HBDUtils.m +26 -12
- package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.m +91 -67
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.h +2 -7
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +28 -26
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +132 -99
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +203 -142
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.h +0 -9
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.m +144 -124
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDEventEmitter.h +1 -11
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDEventEmitter.m +4 -10
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +6 -0
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +161 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.h +6 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +239 -0
- package/ios/HybridNavigation/ReactBridge/HBDNavigator.h +20 -0
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDReactBridgeManager.h +12 -20
- package/ios/HybridNavigation/{Bridge → ReactBridge}/HBDReactBridgeManager.m +91 -91
- package/ios/HybridNavigation/View/HBDBarButtonItem.h +0 -8
- package/ios/HybridNavigation/View/HBDBarButtonItem.m +1 -11
- package/ios/HybridNavigation/View/HBDNavigationBar.h +0 -8
- package/ios/HybridNavigation/View/HBDNavigationBar.m +3 -12
- package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -8
- package/ios/HybridNavigation/View/HBDReactTabBar.m +1 -8
- package/ios/HybridNavigation/View/HBDRootView.h +3 -10
- package/ios/HybridNavigation/View/HBDRootView.m +14 -25
- package/ios/HybridNavigation/View/HBDTitleView.h +0 -9
- package/ios/HybridNavigation/View/HBDTitleView.m +1 -26
- package/ios/HybridNavigation/View/UITabBar+Badge.h +0 -8
- package/ios/HybridNavigation/View/UITabBar+Badge.m +0 -7
- package/ios/HybridNavigation/ViewController/HBDDrawerController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDDrawerController.m +2 -9
- package/ios/HybridNavigation/ViewController/HBDFadeAnimation.h +9 -0
- package/ios/HybridNavigation/ViewController/HBDFadeAnimation.m +22 -0
- package/ios/HybridNavigation/ViewController/HBDNavigationController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +17 -120
- package/ios/HybridNavigation/ViewController/HBDPopAnimation.h +0 -7
- package/ios/HybridNavigation/ViewController/HBDPopAnimation.m +1 -8
- package/ios/HybridNavigation/ViewController/HBDPushAnimation.h +0 -7
- package/ios/HybridNavigation/ViewController/HBDPushAnimation.m +1 -8
- package/ios/HybridNavigation/ViewController/HBDReactViewController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDReactViewController.m +60 -27
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -8
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +15 -11
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.m +23 -33
- package/ios/HybridNavigation/ViewController/HBDViewController.h +1 -8
- package/ios/HybridNavigation/ViewController/HBDViewController.m +12 -25
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.h +0 -8
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -8
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +2 -16
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +32 -46
- package/lib/Garden.d.ts +3 -0
- package/lib/Garden.js +12 -1
- package/lib/NavigationModule.d.ts +0 -2
- package/lib/NavigationModule.js +0 -3
- package/lib/Navigator.d.ts +25 -25
- package/lib/Navigator.js +116 -73
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +4 -6
- package/src/Garden.ts +15 -1
- package/src/NavigationModule.ts +0 -4
- package/src/Navigator.ts +96 -58
- package/src/index.ts +1 -1
- package/ios/HybridNavigation/Bridge/HBDGardenModule.h +0 -14
- package/ios/HybridNavigation/Bridge/HBDGardenModule.m +0 -155
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.h +0 -15
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +0 -272
- package/ios/HybridNavigation/Navigator/HBDNavigator.h +0 -26
|
@@ -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 = [[
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
102
|
-
|
|
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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
131
|
-
|
|
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
|
-
|
|
145
|
-
|
|
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
|
-
|
|
159
|
-
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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,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 "
|
|
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 = [[
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 *)
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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 *)
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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 *)
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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 *)
|
|
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,12 @@
|
|
|
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"
|
|
5
|
+
#import "HBDAnimationObserver.h"
|
|
14
6
|
#import "GlobalStyle.h"
|
|
15
7
|
|
|
8
|
+
#import <React/RCTLog.h>
|
|
9
|
+
|
|
16
10
|
@interface HBDViewController ()
|
|
17
11
|
|
|
18
12
|
@property(nonatomic, copy, readwrite) NSDictionary *props;
|
|
@@ -67,8 +61,10 @@
|
|
|
67
61
|
UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"statusBarWindow"];
|
|
68
62
|
BOOL hidden = [self hbd_statusBarHidden] && ![HBDUtils isInCall];
|
|
69
63
|
CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
[UIView animateWithDuration:0.2 animations:^{
|
|
65
|
+
statusBar.transform = hidden ? CGAffineTransformTranslate(CGAffineTransformIdentity, 0, -statusBarHeight) : CGAffineTransformIdentity;
|
|
66
|
+
statusBar.alpha = hidden ? 0 : 1.0;
|
|
67
|
+
}];
|
|
72
68
|
return NO;
|
|
73
69
|
}
|
|
74
70
|
}
|
|
@@ -82,6 +78,7 @@
|
|
|
82
78
|
|
|
83
79
|
- (void)viewDidAppear:(BOOL)animated {
|
|
84
80
|
[super viewDidAppear:animated];
|
|
81
|
+
[[HBDAnimationObserver sharedObserver] endAnimation];
|
|
85
82
|
if (![HBDUtils isIphoneX]) {
|
|
86
83
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
|
|
87
84
|
}
|
|
@@ -247,17 +244,9 @@
|
|
|
247
244
|
NSNumber *backButtonHidden = options[@"backButtonHidden"];
|
|
248
245
|
if (backButtonHidden) {
|
|
249
246
|
if ([backButtonHidden boolValue]) {
|
|
250
|
-
|
|
251
|
-
[self.navigationItem setHidesBackButton:YES];
|
|
252
|
-
} else {
|
|
253
|
-
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[UIView new]];
|
|
254
|
-
}
|
|
247
|
+
[self.navigationItem setHidesBackButton:YES];
|
|
255
248
|
} else {
|
|
256
|
-
|
|
257
|
-
[self.navigationItem setHidesBackButton:NO];
|
|
258
|
-
} else {
|
|
259
|
-
self.navigationItem.leftBarButtonItem = nil;
|
|
260
|
-
}
|
|
249
|
+
[self.navigationItem setHidesBackButton:NO];
|
|
261
250
|
}
|
|
262
251
|
}
|
|
263
252
|
|
|
@@ -329,9 +318,7 @@
|
|
|
329
318
|
}
|
|
330
319
|
|
|
331
320
|
if (options[@"homeIndicatorAutoHiddenIOS"]) {
|
|
332
|
-
|
|
333
|
-
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
334
|
-
}
|
|
321
|
+
[self setNeedsUpdateOfHomeIndicatorAutoHidden];
|
|
335
322
|
}
|
|
336
323
|
|
|
337
324
|
NSNumber *passThroughTouches = options[@"passThroughTouches"];
|
|
@@ -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
|
-
|
|
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,
|
|
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
|
|
25
|
-
hbd_exchangeImplementations(
|
|
26
|
-
hbd_exchangeImplementations(
|
|
27
|
-
hbd_exchangeImplementations(
|
|
28
|
-
hbd_exchangeImplementations(
|
|
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
|
-
- (
|
|
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] :
|
|
250
|
+
return obj ? [obj boolValue] : YES;
|
|
270
251
|
}
|
|
271
252
|
|
|
272
|
-
- (void)
|
|
273
|
-
objc_setAssociatedObject(self, @selector(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
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;
|
package/lib/Garden.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
2
2
|
import { bindBarButtonItemClickEvent } from './utils';
|
|
3
3
|
const GardenModule = NativeModules.GardenModule;
|
|
4
|
+
const { STATUSBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE, TOOLBAR_HEIGHT } = GardenModule.getConstants();
|
|
5
|
+
if (Platform.OS === 'ios') {
|
|
6
|
+
const GardenEventEmitter = new NativeEventEmitter(GardenModule);
|
|
7
|
+
GardenEventEmitter.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
8
|
+
Garden.statusBarHeight = statusBarHeight;
|
|
9
|
+
Garden.topBarHeight = statusBarHeight + TOOLBAR_HEIGHT;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
4
12
|
export class Garden {
|
|
5
13
|
sceneId;
|
|
6
14
|
static setStyle(style = {}) {
|
|
7
15
|
GardenModule.setStyle(style);
|
|
8
16
|
}
|
|
17
|
+
static statusBarHeight = STATUSBAR_HEIGHT;
|
|
18
|
+
static toolbarHeight = TOOLBAR_HEIGHT;
|
|
19
|
+
static topBarHeight = TOOLBAR_HEIGHT + STATUSBAR_HEIGHT;
|
|
9
20
|
constructor(sceneId) {
|
|
10
21
|
this.sceneId = sceneId;
|
|
11
22
|
}
|
|
@@ -19,6 +19,4 @@ export declare const KEY_INDEX: string;
|
|
|
19
19
|
export declare const KEY_ACTION: string;
|
|
20
20
|
export declare const RESULT_OK: number;
|
|
21
21
|
export declare const RESULT_CANCEL: number;
|
|
22
|
-
export declare const toolbarHeight: number;
|
|
23
|
-
export declare const TOOLBAR_HEIGHT: number;
|
|
24
22
|
export { EventEmitter, NavigationModule };
|