hybrid-navigation 2.17.0 → 2.17.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.
@@ -33,5 +33,5 @@ dependencies {
33
33
  implementation fileTree(dir: 'libs', include: ['*.jar'])
34
34
  implementation 'com.facebook.react:react-native:+'
35
35
  // api project(':navigation')
36
- api 'io.github.listenzz:AndroidNavigation:13.6.5'
36
+ api 'io.github.listenzz:AndroidNavigation:13.6.6'
37
37
  }
@@ -120,7 +120,7 @@ public class ScreenNavigator implements Navigator {
120
120
  callback.invoke(null, false);
121
121
  return;
122
122
  }
123
-
123
+
124
124
  ReadableMap layout = extras.getMap("layout");
125
125
  presented = getReactBridgeManager().createFragment(layout);
126
126
  if (presented == null) {
@@ -138,7 +138,7 @@ public class ScreenNavigator implements Navigator {
138
138
  callback.invoke(null, false);
139
139
  return;
140
140
  }
141
-
141
+
142
142
  ReadableMap layout = extras.getMap("layout");
143
143
  presented = getReactBridgeManager().createFragment(layout);
144
144
  if (presented == null) {
@@ -155,7 +155,7 @@ public class ScreenNavigator implements Navigator {
155
155
  callback.invoke(null, false);
156
156
  return;
157
157
  }
158
-
158
+
159
159
  presented = createFragmentWithExtras(extras);
160
160
  if (presented == null) {
161
161
  callback.invoke(null, false);
@@ -163,15 +163,16 @@ public class ScreenNavigator implements Navigator {
163
163
  }
164
164
  presented.setPresentationStyle(PresentationStyle.OverFullScreen);
165
165
  int requestCode = extras.getInt("requestCode");
166
+
166
167
  presenting.presentFragment(presented, requestCode, () -> callback.invoke(null, true), TransitionAnimation.Fade);
167
168
  }
168
169
 
169
- private void handleHideModal(@NonNull AwesomeFragment target, @NonNull Callback callback) {
170
- target.dismissFragment(() -> callback.invoke(null, true), TransitionAnimation.Fade);
170
+ private void handleHideModal(@NonNull AwesomeFragment presented, @NonNull Callback callback) {
171
+ presented.dismissFragment(() -> callback.invoke(null, true), TransitionAnimation.Fade);
171
172
  }
172
173
 
173
- private void handleDismiss(@NonNull AwesomeFragment target, @NonNull Callback callback) {
174
- target.dismissFragment(() -> callback.invoke(null, true));
174
+ private void handleDismiss(@NonNull AwesomeFragment presented, @NonNull Callback callback) {
175
+ presented.dismissFragment(() -> callback.invoke(null, true));
175
176
  }
176
177
 
177
178
  private void handlePresent(@NonNull AwesomeFragment presenting, @NonNull ReadableMap extras, @NonNull Callback callback) {
@@ -94,16 +94,6 @@
94
94
  return;
95
95
  }
96
96
 
97
- if (!drawer.hbd_viewAppeared) {
98
- [self performSelector:@selector(handleNavigation:) withObject:@{
99
- @"viewController": vc,
100
- @"action": action,
101
- @"extras": extras,
102
- @"callback": callback,
103
- } afterDelay:0.05];
104
- return;
105
- }
106
-
107
97
  callback(@[NSNull.null, @YES]);
108
98
 
109
99
  if ([action isEqualToString:@"toggleMenu"]) {
@@ -122,12 +112,8 @@
122
112
  }
123
113
  }
124
114
 
125
- -(void)handleNavigation:(NSDictionary *)params {
126
- [self handleNavigationWithViewController:params[@"viewController"] action:params[@"action"] extras:params[@"extras"] callback:params[@"callback"]];
127
- }
128
-
129
115
  - (void)invalidate {
130
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
116
+ //
131
117
  }
132
118
 
133
119
  @end
@@ -55,16 +55,6 @@
55
55
  return;
56
56
  }
57
57
 
58
- if (!vc.hbd_viewAppeared) {
59
- [self performSelector:@selector(handleNavigation:) withObject:@{
60
- @"viewController": vc,
61
- @"action": action,
62
- @"extras": extras,
63
- @"callback": callback,
64
- } afterDelay:0.05];
65
- return;
66
- }
67
-
68
58
  if ([action isEqualToString:@"present"]) {
69
59
  [self handlePresentWithViewController:vc extras:extras callback:callback];
70
60
  return;
@@ -161,12 +151,8 @@
161
151
  return [[HBDReactBridgeManager get] viewControllerWithModuleName:moduleName props:props options:options];
162
152
  }
163
153
 
164
- -(void)handleNavigation:(NSDictionary *)params {
165
- [self handleNavigationWithViewController:params[@"viewController"] action:params[@"action"] extras:params[@"extras"] callback:params[@"callback"]];
166
- }
167
-
168
154
  - (void)invalidate {
169
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
155
+ //
170
156
  }
171
157
 
172
158
  @end
@@ -82,16 +82,6 @@
82
82
  return;
83
83
  }
84
84
 
85
- if (!nav.hbd_viewAppeared) {
86
- [self performSelector:@selector(handleNavigation:) withObject:@{
87
- @"viewController": vc,
88
- @"action": action,
89
- @"extras": extras,
90
- @"callback": callback,
91
- } afterDelay:0.05];
92
- return;
93
- }
94
-
95
85
  if ([action isEqualToString:@"push"]) {
96
86
  [self handlePushWithNavigationController:nav extras:extras callback:callback];
97
87
  return;
@@ -257,12 +247,8 @@
257
247
  return drawer.contentController.navigationController;
258
248
  }
259
249
 
260
- -(void)handleNavigation:(NSDictionary *)params {
261
- [self handleNavigationWithViewController:params[@"viewController"] action:params[@"action"] extras:params[@"extras"] callback:params[@"callback"]];
262
- }
263
-
264
250
  - (void)invalidate {
265
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
251
+ //
266
252
  }
267
253
 
268
254
  @end
@@ -187,28 +187,14 @@
187
187
  return;
188
188
  }
189
189
 
190
- if (!tabBarController.hbd_viewAppeared) {
191
- [self performSelector:@selector(handleNavigation:) withObject:@{
192
- @"viewController": vc,
193
- @"action": action,
194
- @"extras": extras,
195
- @"callback": callback,
196
- } afterDelay:0.05];
197
- return;
198
- }
199
-
200
190
  if ([action isEqualToString:@"switchTab"]) {
201
191
  [self handleSwitchTabWithTabBarController:tabBarController extras:extras callback:callback];
202
192
  return;
203
193
  }
204
194
  }
205
195
 
206
- -(void)handleNavigation:(NSDictionary *)params {
207
- [self handleNavigationWithViewController:params[@"viewController"] action:params[@"action"] extras:params[@"extras"] callback:params[@"callback"]];
208
- }
209
-
210
196
  - (void)invalidate {
211
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
197
+ //
212
198
  }
213
199
 
214
200
  @end
@@ -587,21 +587,7 @@
587
587
  }
588
588
 
589
589
  - (CGRect)fakeBarFrameForViewController:(UIViewController *)vc {
590
- UIView *back = [self.navigationBar.subviews firstObject];
591
- CGRect frame = [self.navigationBar convertRect:back.frame toView:vc.view];
592
- frame.origin.x = 0;
593
- if ((vc.edgesForExtendedLayout & UIRectEdgeTop) == 0) {
594
- frame.origin.y = -frame.size.height;
595
- }
596
-
597
- // fix issue for pushed to UIViewController whose root view is UIScrollView.
598
- if ([vc.view isKindOfClass:[UIScrollView class]]) {
599
- UIScrollView *scrollView = (UIScrollView *) vc.view;
600
- scrollView.clipsToBounds = NO;
601
- if (scrollView.contentOffset.y == 0) {
602
- frame.origin.y = -frame.size.height;
603
- }
604
- }
590
+ CGRect frame = CGRectMake(0, 0, self.navigationBar.frame.size.width, UIApplication.sharedApplication.statusBarFrame.size.height + self.navigationBar.frame.size.height);
605
591
  return frame;
606
592
  }
607
593
 
@@ -22,6 +22,7 @@
22
22
  - (void)hbd_setNeedsUpdateNavigationBar;
23
23
 
24
24
  @property(nonatomic, copy, readonly) NSString *sceneId;
25
+ @property(nonatomic, copy) NSString *presentingSceneId;
25
26
  @property(nonatomic, assign) NSInteger resultCode;
26
27
  @property(nonatomic, assign) NSInteger requestCode;
27
28
  @property(nonatomic, copy) NSDictionary *resultData;
@@ -36,7 +36,7 @@
36
36
  self.hbd_viewAppeared = NO;
37
37
  }
38
38
 
39
- - (void)hbd_presentViewController:(UIViewController *)viewController animated:(BOOL)flag completion:(void (^)(void))completion {
39
+ - (void)hbd_presentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^)(void))completion {
40
40
  if (![self canPresentViewController]) {
41
41
  [self didReceiveResultCode:0 resultData:nil requestCode:viewController.requestCode];
42
42
  if (completion) {
@@ -44,7 +44,8 @@
44
44
  }
45
45
  return;
46
46
  }
47
- [self hbd_presentViewController:viewController animated:flag completion:completion];
47
+ viewController.presentingSceneId = self.sceneId;
48
+ [self hbd_presentViewController:viewController animated:animated completion:completion];
48
49
  }
49
50
 
50
51
  - (BOOL)canPresentViewController {
@@ -66,7 +67,10 @@
66
67
 
67
68
  [self hbd_dismissViewControllerAnimated:animated completion:^{
68
69
  if (![presented isKindOfClass:[UIAlertController class]]) {
69
- [presenting didReceiveResultCode:presented.resultCode resultData:presented.resultData requestCode:presented.requestCode];
70
+ BOOL consumed = presented.presentingSceneId && [UIViewController dispatchResult:presenting presented:presented sceneId:presented.presentingSceneId];
71
+ if (!consumed) {
72
+ [presenting didReceiveResultCode:presented.resultCode resultData:presented.resultData requestCode:presented.requestCode];
73
+ }
70
74
  }
71
75
 
72
76
  if (completion) {
@@ -75,6 +79,24 @@
75
79
  }];
76
80
  }
77
81
 
82
+ + (BOOL)dispatchResult:(UIViewController *)presenting presented:(UIViewController *)presented sceneId:(NSString *)sceneId {
83
+ if ([sceneId isEqualToString:presenting.sceneId]) {
84
+ [presenting didReceiveResultCode:presented.resultCode resultData:presented.resultData requestCode:presented.requestCode];
85
+ return YES;
86
+ }
87
+
88
+ NSArray<UIViewController *> *children = presenting.childViewControllers;
89
+ for (UIViewController *vc in children) {
90
+ BOOL consumed = [self dispatchResult:vc presented:presented sceneId:sceneId];
91
+ if (consumed) {
92
+ return YES;
93
+ }
94
+ }
95
+
96
+ return NO;
97
+ }
98
+
99
+
78
100
  - (NSString *)sceneId {
79
101
  id obj = objc_getAssociatedObject(self, _cmd);
80
102
  if (!obj) {
@@ -302,6 +324,14 @@
302
324
  self.resultData = data;
303
325
  }
304
326
 
327
+ - (NSString *)presentingSceneId {
328
+ return objc_getAssociatedObject(self, _cmd);
329
+ }
330
+
331
+ - (void)setPresentingSceneId:(NSString *)presentingSceneId {
332
+ objc_setAssociatedObject(self, @selector(presentingSceneId), presentingSceneId, OBJC_ASSOCIATION_COPY_NONATOMIC);
333
+ }
334
+
305
335
  - (void)didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
306
336
  if ([self isKindOfClass:[UITabBarController class]]) {
307
337
  UIViewController *child = ((UITabBarController *) self).selectedViewController;
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.17.0",
4
+ "version": "2.17.1",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
7
7
  "react-native": "src/index",