hybrid-navigation 2.7.5 → 2.7.6

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 +6 -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 +1 -1
@@ -10,19 +10,15 @@
10
10
  #import <React/RCTLog.h>
11
11
  #import "HBDUtils.h"
12
12
  #import "HBDReactViewController.h"
13
- #import "HBDNavigationController.h"
14
- #import "HBDTabBarController.h"
15
- #import "HBDDrawerController.h"
16
13
  #import "HBDModalViewController.h"
17
- #import "HBDViewController.h"
18
14
  #import "HBDNavigatorRegistry.h"
19
15
  #import "HBDEventEmitter.h"
20
16
 
21
- NSString * const ReactModuleRegistryDidCompletedNotification = @"ReactModuleRegistryDidCompletedNotification";
17
+ NSString *const ReactModuleRegistryDidCompletedNotification = @"ReactModuleRegistryDidCompletedNotification";
22
18
  const NSInteger ResultOK = -1;
23
19
  const NSInteger ResultCancel = 0;
24
20
 
25
- @interface HBDReactBridgeManager() <RCTBridgeDelegate>
21
+ @interface HBDReactBridgeManager () <RCTBridgeDelegate>
26
22
 
27
23
  @property(nonatomic, copy) NSURL *jsCodeLocation;
28
24
  @property(nonatomic, strong) NSMutableDictionary *nativeModules;
@@ -72,17 +68,17 @@ const NSInteger ResultCancel = 0;
72
68
  - (void)handleReload {
73
69
  self.viewHierarchyReady = NO;
74
70
  self.reactModuleRegisterCompleted = NO;
75
-
71
+
76
72
  UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
77
73
  for (NSUInteger i = application.windows.count; i > 0; i--) {
78
- UIWindow *window = application.windows[i-1];
74
+ UIWindow *window = application.windows[i - 1];
79
75
  UIViewController *controller = window.rootViewController;
80
76
  if ([controller isKindOfClass:[HBDModalViewController class]]) {
81
- HBDModalViewController *modal = (HBDModalViewController *)controller;
77
+ HBDModalViewController *modal = (HBDModalViewController *) controller;
82
78
  [modal.contentViewController hbd_hideViewControllerAnimated:NO completion:nil];
83
79
  }
84
80
  }
85
-
81
+
86
82
  UIWindow *mainWindow = [self mainWindow];
87
83
  UIViewController *presentedViewController = mainWindow.rootViewController.presentedViewController;
88
84
  if (presentedViewController && !presentedViewController.isBeingDismissed) {
@@ -103,7 +99,7 @@ const NSInteger ResultCancel = 0;
103
99
 
104
100
  - (void)installWithBundleURL:(NSURL *)jsCodeLocation launchOptions:(NSDictionary *)launchOptions {
105
101
  _jsCodeLocation = jsCodeLocation;
106
-
102
+
107
103
  _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
108
104
  }
109
105
 
@@ -116,23 +112,23 @@ const NSInteger ResultCancel = 0;
116
112
  }
117
113
 
118
114
  - (BOOL)hasNativeModule:(NSString *)moduleName {
119
- return [_nativeModules objectForKey:moduleName] != nil;
115
+ return _nativeModules[moduleName] != nil;
120
116
  }
121
117
 
122
118
  - (Class)nativeModuleClassFromName:(NSString *)moduleName {
123
- return [_nativeModules objectForKey:moduleName];
119
+ return _nativeModules[moduleName];
124
120
  }
125
121
 
126
122
  - (void)registerReactModule:(NSString *)moduleName options:(NSDictionary *)options {
127
- [_reactModules setObject:options forKey:moduleName];
123
+ _reactModules[moduleName] = options;
128
124
  }
129
125
 
130
126
  - (NSDictionary *)reactModuleOptionsForKey:(NSString *)moduleName {
131
- return [_reactModules objectForKey:moduleName];
127
+ return _reactModules[moduleName];
132
128
  }
133
129
 
134
130
  - (BOOL)hasReactModuleForName:(NSString *)moduleName {
135
- return [_reactModules objectForKey:moduleName] != nil;
131
+ return _reactModules[moduleName] != nil;
136
132
  }
137
133
 
138
134
  - (void)startRegisterReactModule {
@@ -152,11 +148,11 @@ const NSInteger ResultCancel = 0;
152
148
  if (!self.isReactModuleRegisterCompleted) {
153
149
  return nil;
154
150
  }
155
-
151
+
156
152
  NSArray<NSString *> *layouts = [self.navigatorRegistry allLayouts];
157
153
  for (NSString *name in layouts) {
158
154
  if ([[layout allKeys] containsObject:name]) {
159
- id<HBDNavigator> navigator = [self.navigatorRegistry navigatorForLayout:name];
155
+ id <HBDNavigator> navigator = [self.navigatorRegistry navigatorForLayout:name];
160
156
  UIViewController *vc = [navigator createViewControllerWithLayout:layout];
161
157
  if (vc) {
162
158
  [self.navigatorRegistry setLayout:name forViewController:vc];
@@ -164,32 +160,32 @@ const NSInteger ResultCancel = 0;
164
160
  return vc;
165
161
  }
166
162
  }
167
-
163
+
168
164
  RCTLogError(@"[Navigator] Can't find a navigator that can handle layout '%@'. Did you forget to register?", layout);
169
165
  return nil;
170
166
  }
171
167
 
172
168
  - (HBDViewController *)controllerWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options {
173
169
  HBDViewController *vc = nil;
174
-
170
+
175
171
  if (!self.isReactModuleRegisterCompleted) {
176
172
  @throw [NSException exceptionWithName:@"IllegalStateException" reason:@"React module hasn't register completed." userInfo:@{}];
177
173
  }
178
-
174
+
179
175
  if (!props) {
180
176
  props = @{};
181
177
  }
182
-
178
+
183
179
  if (!options) {
184
180
  options = @{};
185
181
  }
186
-
182
+
187
183
  if ([self hasReactModuleForName:moduleName]) {
188
184
  NSDictionary *staticOptions = [[HBDReactBridgeManager get] reactModuleOptionsForKey:moduleName];
189
185
  options = [HBDUtils mergeItem:options withTarget:staticOptions];
190
186
  vc = [[HBDReactViewController alloc] initWithModuleName:moduleName props:props options:options];
191
187
  } else {
192
- Class clazz = [self nativeModuleClassFromName:moduleName];
188
+ Class clazz = [self nativeModuleClassFromName:moduleName];
193
189
  NSCAssert([self hasNativeModule:moduleName], @"Can't find module named with %@ , do you forget to register?", moduleName);
194
190
  vc = [[clazz alloc] initWithModuleName:moduleName props:props options:options];
195
191
  }
@@ -200,19 +196,19 @@ const NSInteger ResultCancel = 0;
200
196
  if (!self.viewHierarchyReady) {
201
197
  return nil;
202
198
  }
203
-
199
+
204
200
  UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
205
201
  UIViewController *vc = nil;
206
202
  for (UIWindow *window in application.windows) {
207
203
  if ([window isKindOfClass:[HBDModalWindow class]]) {
208
- HBDModalViewController *modal = (HBDModalViewController *)window.rootViewController;
204
+ HBDModalViewController *modal = (HBDModalViewController *) window.rootViewController;
209
205
  if (!modal || modal.isBeingHidden) {
210
206
  continue;
211
207
  }
212
208
  }
213
-
209
+
214
210
  vc = [self controllerForSceneId:sceneId withController:window.rootViewController];
215
-
211
+
216
212
  if (vc) {
217
213
  break;
218
214
  }
@@ -222,26 +218,26 @@ const NSInteger ResultCancel = 0;
222
218
 
223
219
  - (UIViewController *)controllerForSceneId:(NSString *)sceneId withController:(UIViewController *)controller {
224
220
  UIViewController *target;
225
-
221
+
226
222
  if ([controller.sceneId isEqualToString:sceneId]) {
227
223
  target = controller;
228
224
  }
229
-
225
+
230
226
  if (!target && [controller isKindOfClass:[HBDModalViewController class]]) {
231
- HBDModalViewController *modal = (HBDModalViewController *)controller;
227
+ HBDModalViewController *modal = (HBDModalViewController *) controller;
232
228
  target = [self controllerForSceneId:sceneId withController:modal.contentViewController];
233
229
  }
234
-
230
+
235
231
  if (!target) {
236
232
  UIViewController *presentedController = controller.presentedViewController;
237
233
  if (presentedController && ![presentedController isBeingDismissed]) {
238
234
  target = [self controllerForSceneId:sceneId withController:presentedController];
239
235
  }
240
236
  }
241
-
237
+
242
238
  if (!target && controller.childViewControllers.count > 0) {
243
239
  NSUInteger count = controller.childViewControllers.count;
244
- for (NSUInteger i = 0; i < count; i ++) {
240
+ for (NSUInteger i = 0; i < count; i++) {
245
241
  UIViewController *child = controller.childViewControllers[i];
246
242
  target = [self controllerForSceneId:sceneId withController:child];
247
243
  if (target) {
@@ -260,10 +256,10 @@ const NSInteger ResultCancel = 0;
260
256
  [HBDEventEmitter sendEvent:EVENT_WILL_SET_ROOT data:@{}];
261
257
  UIApplication *application = [[UIApplication class] performSelector:@selector(sharedApplication)];
262
258
  for (NSUInteger i = application.windows.count; i > 0; i--) {
263
- UIWindow *window = application.windows[i-1];
259
+ UIWindow *window = application.windows[i - 1];
264
260
  UIViewController *controller = window.rootViewController;
265
261
  if ([controller isKindOfClass:[HBDModalViewController class]]) {
266
- HBDModalViewController *modal = (HBDModalViewController *)controller;
262
+ HBDModalViewController *modal = (HBDModalViewController *) controller;
267
263
  [modal.contentViewController hbd_hideViewControllerAnimated:NO completion:nil];
268
264
  }
269
265
  }
@@ -292,8 +288,8 @@ const NSInteger ResultCancel = 0;
292
288
  }
293
289
  [UIView setAnimationsEnabled:oldState];
294
290
  self.viewHierarchyReady = YES;
295
- } completion:^(BOOL finished) {
296
- [HBDEventEmitter sendEvent:EVENT_DID_SET_ROOT data:@{ @"tag": tag }];
291
+ } completion:^(BOOL finished) {
292
+ [HBDEventEmitter sendEvent:EVENT_DID_SET_ROOT data:@{@"tag": tag}];
297
293
  }];
298
294
  } else {
299
295
  mainWindow.rootViewController = rootViewController;
@@ -302,7 +298,7 @@ const NSInteger ResultCancel = 0;
302
298
  [mainWindow makeKeyAndVisible];
303
299
  }
304
300
  self.viewHierarchyReady = YES;
305
- [HBDEventEmitter sendEvent:EVENT_DID_SET_ROOT data:@{ @"tag": tag }];
301
+ [HBDEventEmitter sendEvent:EVENT_DID_SET_ROOT data:@{@"tag": tag}];
306
302
  }
307
303
  }
308
304
 
@@ -317,18 +313,18 @@ const NSInteger ResultCancel = 0;
317
313
  if (modal && !modal.isBeingHidden) {
318
314
  return [self primaryViewControllerWithViewController:modal.contentViewController];
319
315
  }
320
-
316
+
321
317
  UIViewController *presented = vc.presentedViewController;
322
318
  if (presented && !presented.beingDismissed && ![presented isKindOfClass:[UIAlertController class]]) {
323
319
  return [self primaryViewControllerWithViewController:presented];
324
320
  }
325
-
326
- NSString *layout = [self.navigatorRegistry layoutForViewController:vc];
321
+
322
+ NSString *layout = [self.navigatorRegistry layoutForViewController:vc];
327
323
  if (layout) {
328
- id<HBDNavigator> navigator = [self.navigatorRegistry navigatorForLayout:layout];
324
+ id <HBDNavigator> navigator = [self.navigatorRegistry navigatorForLayout:layout];
329
325
  return [navigator primaryViewControllerWithViewController:vc];
330
326
  }
331
-
327
+
332
328
  return nil;
333
329
  }
334
330
 
@@ -336,25 +332,25 @@ const NSInteger ResultCancel = 0;
336
332
  UIWindow *mainWindow = [self mainWindow];
337
333
  UIViewController *vc = mainWindow.rootViewController;
338
334
  NSMutableDictionary *graph = [[self buildRouteGraphWithViewController:vc] mutableCopy];
339
-
335
+
340
336
  NSMutableArray *root = [[NSMutableArray alloc] init];
341
337
  NSMutableArray *modal = [[NSMutableArray alloc] init];
342
338
  NSMutableArray *present = [[NSMutableArray alloc] init];
343
-
339
+
344
340
  [self extractModal:modal present:present withGraph:graph];
345
-
341
+
346
342
  if (graph) {
347
343
  [root addObject:graph];
348
344
  }
349
-
345
+
350
346
  if ([present count] > 0) {
351
347
  [root addObjectsFromArray:present];
352
348
  }
353
-
349
+
354
350
  if ([modal count] > 0) {
355
351
  [root addObjectsFromArray:modal];
356
352
  }
357
-
353
+
358
354
  return root;
359
355
  }
360
356
 
@@ -366,17 +362,17 @@ const NSInteger ResultCancel = 0;
366
362
  [modal addObject:m];
367
363
  [self extractModal:modal present:present withGraph:m];
368
364
  }
369
-
365
+
370
366
  if (p) {
371
367
  [graph removeObjectForKey:@"ref_present"];
372
368
  [present addObject:p];
373
369
  [self extractModal:modal present:present withGraph:p];
374
370
  }
375
-
371
+
376
372
  NSArray *children = graph[@"children"];
377
373
  if (children) {
378
374
  for (int i = 0; i < children.count; i++) {
379
- NSMutableDictionary *child = [children objectAtIndex:i];
375
+ NSMutableDictionary *child = children[i];
380
376
  [self extractModal:modal present:present withGraph:child];
381
377
  }
382
378
  }
@@ -388,31 +384,31 @@ const NSInteger ResultCancel = 0;
388
384
  if (modal && !modal.isBeingHidden) {
389
385
  m = [[self buildRouteGraphWithViewController:modal.contentViewController] mutableCopy];
390
386
  }
391
-
387
+
392
388
  NSMutableDictionary *p = nil;
393
389
  UIViewController *presented = vc.presentedViewController;
394
390
  if (presented && presented.presentingViewController == vc && !presented.beingDismissed && ![presented isKindOfClass:[UIAlertController class]]) {
395
391
  p = [[self buildRouteGraphWithViewController:presented] mutableCopy];
396
392
  }
397
-
393
+
398
394
  NSString *layout = [self.navigatorRegistry layoutForViewController:vc];
399
395
  if (layout) {
400
- id<HBDNavigator> navigator = [self.navigatorRegistry navigatorForLayout:layout];
396
+ id <HBDNavigator> navigator = [self.navigatorRegistry navigatorForLayout:layout];
401
397
  NSMutableDictionary *graph = [[navigator buildRouteGraphWithViewController:vc] mutableCopy];
402
398
  if (m) {
403
- [graph setObject:m forKey:@"ref_modal"];
399
+ graph[@"ref_modal"] = m;
404
400
  }
405
401
  if (p) {
406
- [graph setObject:p forKey:@"ref_present"];
402
+ graph[@"ref_present"] = p;
407
403
  }
408
404
  return graph;
409
405
  }
410
-
406
+
411
407
  return nil;
412
408
  }
413
409
 
414
410
  - (void)handleNavigationWithViewController:(UIViewController *)target action:(NSString *)action extras:(NSDictionary *)extras resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
415
- id<HBDNavigator> navigator = [self.navigatorRegistry navigatorForAction:action];
411
+ id <HBDNavigator> navigator = [self.navigatorRegistry navigatorForAction:action];
416
412
  if (navigator) {
417
413
  [navigator handleNavigationWithViewController:target action:action extras:extras resolver:resolve rejecter:reject];
418
414
  } else {
@@ -420,7 +416,7 @@ const NSInteger ResultCancel = 0;
420
416
  }
421
417
  }
422
418
 
423
- - (void)registerNavigator:(id<HBDNavigator>)navigator {
419
+ - (void)registerNavigator:(id <HBDNavigator>)navigator {
424
420
  [self.navigatorRegistry registerNavigator:navigator];
425
421
  }
426
422
 
@@ -10,15 +10,15 @@
10
10
 
11
11
  @interface GlobalStyle : NSObject
12
12
 
13
- @property (nonatomic, strong, readonly) UIColor *screenBackgroundColor;
13
+ @property(nonatomic, strong, readonly) UIColor *screenBackgroundColor;
14
14
 
15
- @property (nonatomic, assign, readonly, getter=isBackTitleHidden) BOOL backTitleHidden;
15
+ @property(nonatomic, assign, readonly, getter=isBackTitleHidden) BOOL backTitleHidden;
16
16
 
17
- @property (nonatomic, copy) NSString *badgeColorHexString;
18
- @property (nonatomic, copy) NSString *tabBarItemColorHexString;
19
- @property (nonatomic, copy) NSString *tabBarUnselectedItemColorHexString;
20
- @property (nonatomic, strong, readonly) UIColor *tabBarBackgroundColor;
21
- @property (nonatomic, assign, readonly) BOOL awaysSplitNavigationBarTransition;
17
+ @property(nonatomic, copy) NSString *badgeColorHexString;
18
+ @property(nonatomic, copy) NSString *tabBarItemColorHexString;
19
+ @property(nonatomic, copy) NSString *tabBarUnselectedItemColorHexString;
20
+ @property(nonatomic, strong, readonly) UIColor *tabBarBackgroundColor;
21
+ @property(nonatomic, assign, readonly) BOOL alwaysSplitNavigationBarTransition;
22
22
 
23
23
  - (instancetype)initWithOptions:(NSDictionary *)options;
24
24