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.
- package/CHANGELOG.md +24 -0
- package/android/build.gradle +1 -1
- package/ios/HybridNavigation/Bridge/HBDEventEmitter.h +16 -16
- package/ios/HybridNavigation/Bridge/HBDEventEmitter.m +33 -33
- package/ios/HybridNavigation/Bridge/HBDGardenModule.m +43 -25
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +83 -58
- package/ios/HybridNavigation/Bridge/HBDReactBridgeManager.h +3 -3
- package/ios/HybridNavigation/Bridge/HBDReactBridgeManager.m +57 -61
- package/ios/HybridNavigation/GlobalStyle.h +7 -7
- package/ios/HybridNavigation/GlobalStyle.m +86 -86
- package/ios/HybridNavigation/HBDGarden.m +28 -28
- package/ios/HybridNavigation/HBDUtils.h +4 -4
- package/ios/HybridNavigation/HBDUtils.m +43 -49
- package/ios/HybridNavigation/Navigator/HBDDrawerNavigator.m +24 -24
- package/ios/HybridNavigation/Navigator/HBDNavigator.h +2 -2
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.h +4 -4
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +19 -20
- package/ios/HybridNavigation/Navigator/HBDScreenNavigator.m +24 -26
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +31 -30
- package/ios/HybridNavigation/Navigator/HBDTabNavigator.m +54 -56
- package/ios/HybridNavigation/View/HBDBarButtonItem.h +1 -1
- package/ios/HybridNavigation/View/HBDBarButtonItem.m +5 -5
- package/ios/HybridNavigation/View/HBDNavigationBar.h +4 -4
- package/ios/HybridNavigation/View/HBDNavigationBar.m +19 -20
- package/ios/HybridNavigation/View/HBDReactTabBar.m +3 -3
- package/ios/HybridNavigation/View/HBDRootView.m +3 -3
- package/ios/HybridNavigation/View/HBDTitleView.m +7 -7
- package/ios/HybridNavigation/View/UITabBar+Badge.h +1 -0
- package/ios/HybridNavigation/View/UITabBar+Badge.m +6 -6
- package/ios/HybridNavigation/ViewController/HBDDrawerController.h +8 -5
- package/ios/HybridNavigation/ViewController/HBDDrawerController.m +39 -38
- package/ios/HybridNavigation/ViewController/HBDModalViewController.h +2 -2
- package/ios/HybridNavigation/ViewController/HBDModalViewController.m +45 -44
- package/ios/HybridNavigation/ViewController/HBDNavigationController.h +1 -1
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +111 -113
- package/ios/HybridNavigation/ViewController/HBDPopAnimation.m +4 -4
- package/ios/HybridNavigation/ViewController/HBDPushAnimation.m +4 -4
- package/ios/HybridNavigation/ViewController/HBDReactViewController.m +24 -26
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +1 -1
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +25 -26
- package/ios/HybridNavigation/ViewController/HBDViewController.m +31 -32
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +5 -4
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +20 -19
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +35 -36
- package/lib/DeepLink.js +5 -5
- package/lib/hooks.d.ts +1 -1
- package/lib/hooks.js +4 -7
- package/package.json +1 -1
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
#import "HBDUtils.h"
|
|
13
13
|
#import "HBDModalViewController.h"
|
|
14
14
|
#import <React/RCTLog.h>
|
|
15
|
-
#import "HBDGarden.h"
|
|
16
15
|
#import "UITabBar+Badge.h"
|
|
17
16
|
|
|
18
17
|
@implementation UIViewController (HBD)
|
|
@@ -55,20 +54,20 @@
|
|
|
55
54
|
RCTLogWarn(@"[Navigator] Can't present since the scene had present another scene already.");
|
|
56
55
|
return NO;
|
|
57
56
|
}
|
|
58
|
-
|
|
57
|
+
|
|
59
58
|
UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
|
|
60
59
|
for (NSUInteger i = application.windows.count; i > 0; i--) {
|
|
61
|
-
UIWindow *window = application.windows[i-1];
|
|
60
|
+
UIWindow *window = application.windows[i - 1];
|
|
62
61
|
UIViewController *viewController = window.rootViewController;
|
|
63
62
|
if ([viewController isKindOfClass:[HBDModalViewController class]]) {
|
|
64
|
-
HBDModalViewController *modal = (HBDModalViewController *)viewController;
|
|
63
|
+
HBDModalViewController *modal = (HBDModalViewController *) viewController;
|
|
65
64
|
if (!modal.beingHidden) {
|
|
66
65
|
RCTLogWarn(@"[Navigator] Can't present a scene over a modal.");
|
|
67
66
|
return NO;
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
|
-
|
|
70
|
+
|
|
72
71
|
return YES;
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -79,12 +78,12 @@
|
|
|
79
78
|
presenting = self.presentingViewController;
|
|
80
79
|
presented = presenting.presentedViewController;
|
|
81
80
|
}
|
|
82
|
-
|
|
81
|
+
|
|
83
82
|
[self hbd_dismissViewControllerAnimated:animated completion:^{
|
|
84
83
|
if (![presented isKindOfClass:[UIAlertController class]]) {
|
|
85
84
|
[presenting didReceiveResultCode:presented.resultCode resultData:presented.resultData requestCode:presented.requestCode];
|
|
86
85
|
}
|
|
87
|
-
|
|
86
|
+
|
|
88
87
|
if (completion) {
|
|
89
88
|
completion();
|
|
90
89
|
}
|
|
@@ -97,7 +96,7 @@
|
|
|
97
96
|
obj = [[NSUUID UUID] UUIDString];
|
|
98
97
|
objc_setAssociatedObject(self, @selector(sceneId), obj, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
99
98
|
}
|
|
100
|
-
|
|
99
|
+
return obj;
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
- (UIBarStyle)hbd_barStyle {
|
|
@@ -116,26 +115,26 @@
|
|
|
116
115
|
if (self.hbd_barHidden) {
|
|
117
116
|
return UIColor.clearColor;
|
|
118
117
|
}
|
|
119
|
-
|
|
118
|
+
|
|
120
119
|
id obj = objc_getAssociatedObject(self, _cmd);
|
|
121
120
|
UIColor *color;
|
|
122
121
|
if (obj) {
|
|
123
122
|
color = obj;
|
|
124
123
|
}
|
|
125
|
-
|
|
124
|
+
|
|
126
125
|
UIColor *colorWithBarStyle = [[HBDGarden globalStyle] barTintColorWithBarStyle:self.hbd_barStyle];
|
|
127
126
|
if (color == nil && colorWithBarStyle != nil) {
|
|
128
127
|
color = colorWithBarStyle;
|
|
129
128
|
}
|
|
130
|
-
|
|
129
|
+
|
|
131
130
|
if (color == nil && [UINavigationBar appearance].barTintColor != nil) {
|
|
132
131
|
color = [UINavigationBar appearance].barTintColor;
|
|
133
132
|
}
|
|
134
|
-
|
|
133
|
+
|
|
135
134
|
if (color == nil) {
|
|
136
|
-
color = [UINavigationBar appearance].barStyle == UIBarStyleDefault ? [UIColor whiteColor]: [UIColor blackColor];
|
|
135
|
+
color = [UINavigationBar appearance].barStyle == UIBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor];
|
|
137
136
|
}
|
|
138
|
-
|
|
137
|
+
|
|
139
138
|
return color;
|
|
140
139
|
}
|
|
141
140
|
|
|
@@ -148,12 +147,12 @@
|
|
|
148
147
|
if (obj) {
|
|
149
148
|
return obj;
|
|
150
149
|
}
|
|
151
|
-
|
|
150
|
+
|
|
152
151
|
UIColor *colorWithBarStyle = [[HBDGarden globalStyle] tintColorWithBarStyle:self.hbd_barStyle];
|
|
153
152
|
if (colorWithBarStyle) {
|
|
154
153
|
return colorWithBarStyle;
|
|
155
154
|
}
|
|
156
|
-
|
|
155
|
+
|
|
157
156
|
return [UINavigationBar appearance].tintColor;
|
|
158
157
|
}
|
|
159
158
|
|
|
@@ -166,10 +165,10 @@
|
|
|
166
165
|
if (obj) {
|
|
167
166
|
return obj;
|
|
168
167
|
}
|
|
169
|
-
|
|
168
|
+
|
|
170
169
|
UIBarStyle barStyle = self.hbd_barStyle;
|
|
171
170
|
UIColor *colorWithBarStyle = [[HBDGarden globalStyle] titleTextColorWithBarStyle:barStyle];
|
|
172
|
-
NSDictionary *colorAttributes = @{
|
|
171
|
+
NSDictionary *colorAttributes = @{NSForegroundColorAttributeName: colorWithBarStyle};
|
|
173
172
|
NSDictionary *attributes = [UINavigationBar appearance].titleTextAttributes;
|
|
174
173
|
if (attributes) {
|
|
175
174
|
NSMutableDictionary *mutableAttributes = [attributes mutableCopy];
|
|
@@ -213,12 +212,12 @@
|
|
|
213
212
|
}
|
|
214
213
|
|
|
215
214
|
- (float)hbd_barShadowAlpha {
|
|
216
|
-
return
|
|
215
|
+
return self.hbd_barShadowHidden ? 0 : self.hbd_barAlpha;
|
|
217
216
|
}
|
|
218
217
|
|
|
219
218
|
- (BOOL)hbd_barShadowHidden {
|
|
220
219
|
id obj = objc_getAssociatedObject(self, _cmd);
|
|
221
|
-
return
|
|
220
|
+
return self.hbd_barHidden || obj ? [obj boolValue] : NO;
|
|
222
221
|
}
|
|
223
222
|
|
|
224
223
|
- (void)setHbd_barShadowHidden:(BOOL)hidden {
|
|
@@ -239,7 +238,7 @@
|
|
|
239
238
|
return obj ? [obj boolValue] : YES;
|
|
240
239
|
}
|
|
241
240
|
|
|
242
|
-
-(void)setHbd_backInteractive:(BOOL)interactive {
|
|
241
|
+
- (void)setHbd_backInteractive:(BOOL)interactive {
|
|
243
242
|
objc_setAssociatedObject(self, @selector(hbd_backInteractive), @(interactive), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
244
243
|
}
|
|
245
244
|
|
|
@@ -249,7 +248,7 @@
|
|
|
249
248
|
}
|
|
250
249
|
|
|
251
250
|
- (void)setHbd_swipeBackEnabled:(BOOL)enabled {
|
|
252
|
-
|
|
251
|
+
objc_setAssociatedObject(self, @selector(hbd_swipeBackEnabled), @(enabled), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
253
252
|
}
|
|
254
253
|
|
|
255
254
|
- (BOOL)hbd_viewAppeared {
|
|
@@ -288,7 +287,7 @@
|
|
|
288
287
|
|
|
289
288
|
- (void)hbd_setNeedsUpdateNavigationBar {
|
|
290
289
|
if (self.navigationController && [self.navigationController isKindOfClass:[HBDNavigationController class]]) {
|
|
291
|
-
HBDNavigationController *nav = (HBDNavigationController *)self.navigationController;
|
|
290
|
+
HBDNavigationController *nav = (HBDNavigationController *) self.navigationController;
|
|
292
291
|
if (self == nav.topViewController) {
|
|
293
292
|
[nav updateNavigationBarForViewController:self];
|
|
294
293
|
}
|
|
@@ -298,9 +297,9 @@
|
|
|
298
297
|
- (void)setResultCode:(NSInteger)resultCode {
|
|
299
298
|
UIViewController *presenting = self.presentingViewController;
|
|
300
299
|
if (presenting) {
|
|
301
|
-
objc_setAssociatedObject(presenting.presentedViewController, @selector(resultCode)
|
|
300
|
+
objc_setAssociatedObject(presenting.presentedViewController, @selector(resultCode), @(resultCode), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
302
301
|
}
|
|
303
|
-
objc_setAssociatedObject(self, @selector(resultCode)
|
|
302
|
+
objc_setAssociatedObject(self, @selector(resultCode), @(resultCode), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
304
303
|
}
|
|
305
304
|
|
|
306
305
|
- (NSInteger)resultCode {
|
|
@@ -336,13 +335,13 @@
|
|
|
336
335
|
|
|
337
336
|
- (void)didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
|
|
338
337
|
if ([self isKindOfClass:[UITabBarController class]]) {
|
|
339
|
-
UIViewController *child = ((UITabBarController *)self).selectedViewController;
|
|
338
|
+
UIViewController *child = ((UITabBarController *) self).selectedViewController;
|
|
340
339
|
[child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
341
340
|
} else if ([self isKindOfClass:[UINavigationController class]]) {
|
|
342
|
-
UIViewController *child = ((UINavigationController *)self).topViewController;
|
|
341
|
+
UIViewController *child = ((UINavigationController *) self).topViewController;
|
|
343
342
|
[child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
344
343
|
} else if ([self isKindOfClass:[HBDDrawerController class]]) {
|
|
345
|
-
UIViewController *child = ((HBDDrawerController *)self).contentController;
|
|
344
|
+
UIViewController *child = ((HBDDrawerController *) self).contentController;
|
|
346
345
|
[child didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
347
346
|
} else {
|
|
348
347
|
NSArray *children = self.childViewControllers;
|
|
@@ -356,16 +355,16 @@
|
|
|
356
355
|
|
|
357
356
|
- (HBDDrawerController *)drawerController {
|
|
358
357
|
UIViewController *vc = self;
|
|
359
|
-
|
|
358
|
+
|
|
360
359
|
if ([vc isKindOfClass:[HBDDrawerController class]]) {
|
|
361
|
-
return (HBDDrawerController *)vc;
|
|
360
|
+
return (HBDDrawerController *) vc;
|
|
362
361
|
}
|
|
363
|
-
|
|
362
|
+
|
|
364
363
|
UIViewController *parent = self.parentViewController;
|
|
365
364
|
if (parent) {
|
|
366
365
|
return [parent drawerController];
|
|
367
366
|
}
|
|
368
|
-
|
|
367
|
+
|
|
369
368
|
return nil;
|
|
370
369
|
}
|
|
371
370
|
|
|
@@ -378,7 +377,7 @@
|
|
|
378
377
|
if (title != nil) {
|
|
379
378
|
tabBarItem.title = title;
|
|
380
379
|
}
|
|
381
|
-
|
|
380
|
+
|
|
382
381
|
// icon
|
|
383
382
|
NSDictionary *icon = option[@"icon"];
|
|
384
383
|
if (icon != nil) {
|
|
@@ -392,13 +391,13 @@
|
|
|
392
391
|
}
|
|
393
392
|
}
|
|
394
393
|
|
|
395
|
-
|
|
394
|
+
// badge
|
|
396
395
|
NSDictionary *badge = option[@"badge"];
|
|
397
396
|
if (badge != nil) {
|
|
398
397
|
BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
|
|
399
398
|
NSString *text = hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
|
|
400
|
-
BOOL dot = hidden ?
|
|
401
|
-
|
|
399
|
+
BOOL dot = hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
|
|
400
|
+
|
|
402
401
|
tabBarItem.badgeValue = text;
|
|
403
402
|
UITabBar *tabBar = self.tabBarController.tabBar;
|
|
404
403
|
if (dot) {
|
package/lib/DeepLink.js
CHANGED
|
@@ -3,7 +3,7 @@ import { router } from './router';
|
|
|
3
3
|
let _active = 0;
|
|
4
4
|
let _uriPrefix = '';
|
|
5
5
|
let _hasHandleInitialURL = false;
|
|
6
|
-
let
|
|
6
|
+
let _linkingSubscription;
|
|
7
7
|
function activate(uriPrefix) {
|
|
8
8
|
if (!uriPrefix) {
|
|
9
9
|
throw new Error('must pass `uriPrefix` when activate router.');
|
|
@@ -22,16 +22,16 @@ function activate(uriPrefix) {
|
|
|
22
22
|
})
|
|
23
23
|
.catch(err => console.error('An error occurred', err));
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
_linkingSubscription = Linking.addEventListener('url', handleLinking);
|
|
26
26
|
}
|
|
27
27
|
_active++;
|
|
28
28
|
}
|
|
29
29
|
function deactivate() {
|
|
30
30
|
_active--;
|
|
31
31
|
if (_active === 0) {
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (_linkingSubscription) {
|
|
33
|
+
_linkingSubscription.remove();
|
|
34
|
+
_linkingSubscription = undefined;
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
37
|
Linking.removeEventListener('url', handleLinking);
|
package/lib/hooks.d.ts
CHANGED
package/lib/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { EventEmitter,
|
|
2
|
+
import { EVENT_NAVIGATION, EventEmitter, KEY_ON, KEY_SCENE_ID, ON_COMPONENT_APPEAR, ON_COMPONENT_DISAPPEAR, } from './NavigationModule';
|
|
3
3
|
import { NavigationContext } from './ReactRegistry';
|
|
4
4
|
export function useVisible() {
|
|
5
5
|
const visibility = useVisibility();
|
|
@@ -10,8 +10,7 @@ export function useVisibility() {
|
|
|
10
10
|
const [visibility, setVisibility] = useState(navigator.visibility);
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
const subscription = EventEmitter.addListener(EVENT_NAVIGATION, data => {
|
|
13
|
-
|
|
14
|
-
if (sceneId === data[KEY_SCENE_ID]) {
|
|
13
|
+
if (navigator.sceneId === data[KEY_SCENE_ID]) {
|
|
15
14
|
if (data[KEY_ON] === ON_COMPONENT_APPEAR) {
|
|
16
15
|
setVisibility('visible');
|
|
17
16
|
}
|
|
@@ -34,8 +33,7 @@ export function useVisibleEffect(effect) {
|
|
|
34
33
|
destructor.current = effect();
|
|
35
34
|
}
|
|
36
35
|
const subscription = EventEmitter.addListener(EVENT_NAVIGATION, data => {
|
|
37
|
-
|
|
38
|
-
if (sceneId === data[KEY_SCENE_ID]) {
|
|
36
|
+
if (navigator.sceneId === data[KEY_SCENE_ID]) {
|
|
39
37
|
if (data[KEY_ON] === ON_COMPONENT_APPEAR) {
|
|
40
38
|
destructor.current = effect();
|
|
41
39
|
}
|
|
@@ -57,8 +55,7 @@ export function useVisibleEffect(effect) {
|
|
|
57
55
|
}, [effect, navigator]);
|
|
58
56
|
}
|
|
59
57
|
export function useNavigator() {
|
|
60
|
-
|
|
61
|
-
return ctx;
|
|
58
|
+
return useContext(NavigationContext);
|
|
62
59
|
}
|
|
63
60
|
export function useGarden() {
|
|
64
61
|
const ctx = useContext(NavigationContext);
|