hybrid-navigation 2.7.4 → 2.7.7

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 +18 -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 +80 -54
  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 +29 -29
  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 +23 -25
  41. package/ios/HybridNavigation/ViewController/HBDViewController.m +31 -32
  42. package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +3 -3
  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 +3 -3
@@ -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
- return obj;
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 = @{ NSForegroundColorAttributeName: colorWithBarStyle };
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 self.hbd_barShadowHidden ? 0 : self.hbd_barAlpha;
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 self.hbd_barHidden || obj ? [obj boolValue] : NO;
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
- objc_setAssociatedObject(self, @selector(hbd_swipeBackEnabled), @(enabled), OBJC_ASSOCIATION_COPY_NONATOMIC);
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),@(resultCode), OBJC_ASSOCIATION_COPY_NONATOMIC);
300
+ objc_setAssociatedObject(presenting.presentedViewController, @selector(resultCode), @(resultCode), OBJC_ASSOCIATION_COPY_NONATOMIC);
302
301
  }
303
- objc_setAssociatedObject(self, @selector(resultCode),@(resultCode), OBJC_ASSOCIATION_COPY_NONATOMIC);
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
- // badge
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 ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
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 _linkingSucscription;
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
- _linkingSucscription = Linking.addEventListener('url', handleLinking);
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 (_linkingSucscription) {
33
- _linkingSucscription.remove();
34
- _linkingSucscription = undefined;
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
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { Navigator } from './Navigator';
3
3
  export declare type Visibility = 'visible' | 'invisible' | 'pending';
4
4
  export declare function useVisible(): boolean;
package/lib/hooks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useContext, useEffect, useRef, useState } from 'react';
2
- import { EventEmitter, EVENT_NAVIGATION, KEY_SCENE_ID, KEY_ON, ON_COMPONENT_DISAPPEAR, ON_COMPONENT_APPEAR, } from './NavigationModule';
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
- const sceneId = navigator.sceneId;
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
- const sceneId = navigator.sceneId;
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
- const ctx = useContext(NavigationContext);
61
- return ctx;
58
+ return useContext(NavigationContext);
62
59
  }
63
60
  export function useGarden() {
64
61
  const ctx = useContext(NavigationContext);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hybrid-navigation",
3
3
  "description": "React Native Navigation that supports seamless navigation between Native and React.",
4
- "version": "2.7.4",
4
+ "version": "2.7.7",
5
5
  "keywords": [
6
6
  "react-native",
7
7
  "navigation",
@@ -52,9 +52,9 @@
52
52
  "babel-jest": "^27.2.0",
53
53
  "babel-plugin-module-resolver": "^4.0.0",
54
54
  "jest": "^27.2.0",
55
- "metro-react-native-babel-preset": "^0.66.2",
55
+ "metro-react-native-babel-preset": "^0.68.0",
56
56
  "react": "17.0.2",
57
- "react-native": "^0.66.2",
57
+ "react-native": "^0.67.2",
58
58
  "react-native-fast-image": "^8.5.11",
59
59
  "react-native-iphone-x-helper": "^1.2.0",
60
60
  "react-native-keyboard-aware-scroll-view": "^0.9.5",