hybrid-navigation 4.0.2 → 4.0.3

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.
@@ -123,6 +123,7 @@ public class TabBar extends FrameLayout {
123
123
  if (tabBarItem != null && tabView != null) {
124
124
  bindTabWithData(tabBarItem, tabView, this);
125
125
  tabView.initialise();
126
+ post(() -> relayoutTabs(resolveAvailableWidth()));
126
127
  }
127
128
  }
128
129
 
@@ -293,12 +294,15 @@ public class TabBar extends FrameLayout {
293
294
  }
294
295
 
295
296
  private int resolveAvailableWidth() {
296
- int availableWidth = tabContainer.getWidth();
297
+ int availableWidth = getWidth();
297
298
  if (availableWidth <= 0) {
298
- availableWidth = getWidth();
299
+ availableWidth = getMeasuredWidth();
300
+ }
301
+ if (availableWidth <= 0 && getParent() instanceof View) {
302
+ availableWidth = ((View) getParent()).getWidth();
299
303
  }
300
304
  if (availableWidth <= 0) {
301
- availableWidth = getMeasuredWidth();
305
+ availableWidth = tabContainer.getWidth();
302
306
  }
303
307
  if (availableWidth <= 0) {
304
308
  availableWidth = AppUtils.getScreenWidth(getContext());
@@ -306,16 +310,43 @@ public class TabBar extends FrameLayout {
306
310
  return availableWidth;
307
311
  }
308
312
 
313
+ private int resolveMeasuredWidth(int widthMeasureSpec) {
314
+ if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.UNSPECIFIED) {
315
+ return 0;
316
+ }
317
+ return MeasureSpec.getSize(widthMeasureSpec);
318
+ }
319
+
309
320
  private void relayoutTabs(int availableWidth) {
310
321
  if (availableWidth <= 0 || tabs.isEmpty() || tabBarItems.isEmpty()) {
311
322
  return;
312
323
  }
313
324
 
314
325
  int itemWidth = getTabWidth(getContext(), availableWidth, tabBarItems.size());
326
+ boolean changed = false;
315
327
  for (TabView tab : tabs) {
316
- tab.setTabWidth(itemWidth);
328
+ ViewGroup.LayoutParams params = tab.getLayoutParams();
329
+ if (params == null || params.width != itemWidth) {
330
+ tab.setTabWidth(itemWidth);
331
+ changed = true;
332
+ }
333
+ }
334
+ if (changed) {
335
+ tabContainer.requestLayout();
336
+ }
337
+ }
338
+
339
+ @Override
340
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
341
+ int measuredWidth = resolveMeasuredWidth(widthMeasureSpec);
342
+ if (measuredWidth > 0) {
343
+ relayoutTabs(measuredWidth);
344
+ }
345
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
346
+ int actualWidth = getMeasuredWidth();
347
+ if (actualWidth > 0 && actualWidth != measuredWidth) {
348
+ relayoutTabs(actualWidth);
317
349
  }
318
- tabContainer.requestLayout();
319
350
  }
320
351
 
321
352
  @Override
@@ -80,7 +80,7 @@ public class HybridFragment extends AwesomeFragment {
80
80
  private void setBackgroundForModal(@NonNull Style style) {
81
81
  int color = mStyle.getScreenBackgroundColor();
82
82
  if (Color.alpha(color) == 255) {
83
- style.setScreenBackgroundColor(Color.parseColor("#77000000"));
83
+ style.setScreenBackgroundColor(Color.TRANSPARENT);
84
84
  }
85
85
  }
86
86
 
@@ -110,13 +110,14 @@
110
110
  }
111
111
 
112
112
  - (void)handleDismissWithViewController:(UIViewController *) vc callback:(RCTResponseSenderBlock)callback {
113
- BOOL animated = YES;
114
- if ([vc isKindOfClass:[HBDViewController class]]) {
113
+ UIViewController *modalHost = [self modalHostViewControllerForViewController:vc];
114
+ BOOL isModal = modalHost.modalPresentationStyle == UIModalPresentationOverFullScreen;
115
+ BOOL animated = !isModal;
116
+ if (!isModal && [vc isKindOfClass:[HBDViewController class]]) {
115
117
  HBDViewController *hbdvc = (HBDViewController *)vc;
116
118
  animated = hbdvc.animatedTransition;
117
119
  }
118
120
 
119
- UIViewController *modalHost = [self modalHostViewControllerForViewController:vc];
120
121
  UIViewController *presenting = modalHost.presentingViewController;
121
122
 
122
123
  [modalHost dismissViewControllerAnimated:animated completion:^{
@@ -142,13 +143,7 @@
142
143
  vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
143
144
  [vc setRequestCode:requestCode];
144
145
 
145
- BOOL animated = YES;
146
- if ([vc isKindOfClass:[HBDViewController class]]) {
147
- HBDViewController *hbdvc = (HBDViewController *)vc;
148
- animated = hbdvc.animatedTransition;
149
- }
150
-
151
- [presenting presentViewController:vc animated:animated completion:^{
146
+ [presenting presentViewController:vc animated:NO completion:^{
152
147
  callback(@[NSNull.null, @YES]);
153
148
  }];
154
149
  }
@@ -175,7 +170,7 @@
175
170
  [vc setRequestCode:requestCode];
176
171
  [vc setPresentingSceneId:presenting.sceneId];
177
172
 
178
- [presenting presentViewController:vc animated:YES completion:^{
173
+ [presenting presentViewController:vc animated:NO completion:^{
179
174
  callback(@[NSNull.null, @YES]);
180
175
  }];
181
176
  }
@@ -172,7 +172,7 @@
172
172
  }
173
173
 
174
174
  - (void)setModalBackgroundColor {
175
- self.view.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.5];
175
+ self.view.backgroundColor = UIColor.clearColor;
176
176
 
177
177
  NSString *screenColor = self.options[@"screenBackgroundColor"];
178
178
 
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": "4.0.2",
4
+ "version": "4.0.3",
5
5
  "main": "./dist/index",
6
6
  "module": "./dist/index",
7
7
  "types": "./dist/index.d.ts",