hybrid-navigation 4.0.1 → 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.
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +224 -12
- package/android/src/main/java/com/navigation/androidx/HybridDrawerLayout.java +636 -0
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +4 -0
- package/android/src/main/java/com/navigation/androidx/TabBar.java +36 -5
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +4 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +9 -0
- package/android/src/main/res/layout/nav_fragment_drawer.xml +2 -2
- package/ios/Navigator/HBDScreenNavigator.mm +6 -11
- package/ios/Navigator/HBDStackNavigator.mm +1 -23
- package/ios/React/HBDNativeNavigation.mm +21 -5
- package/ios/ViewController/HBDDrawerController.mm +615 -87
- package/ios/ViewController/HBDNavigationController.mm +28 -1
- package/ios/ViewController/HBDViewController.mm +3 -3
- package/package.json +1 -1
|
@@ -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 =
|
|
297
|
+
int availableWidth = getWidth();
|
|
297
298
|
if (availableWidth <= 0) {
|
|
298
|
-
availableWidth =
|
|
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 =
|
|
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.
|
|
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
|
|
@@ -284,6 +284,10 @@ public class TabBarFragment extends AwesomeFragment {
|
|
|
284
284
|
if (completion != null) {
|
|
285
285
|
completion.run();
|
|
286
286
|
}
|
|
287
|
+
DrawerFragment drawerFragment = getDrawerFragment();
|
|
288
|
+
if (drawerFragment != null) {
|
|
289
|
+
drawerFragment.updateMenuGestureState();
|
|
290
|
+
}
|
|
287
291
|
return current;
|
|
288
292
|
}
|
|
289
293
|
|
|
@@ -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.
|
|
83
|
+
style.setScreenBackgroundColor(Color.TRANSPARENT);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -99,6 +99,15 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
99
99
|
onCreateMainComponent();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
protected void setNeedsSystemBarsAppearanceUpdate() {
|
|
103
|
+
Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
|
|
104
|
+
if (fragment instanceof AwesomeFragment awesomeFragment) {
|
|
105
|
+
awesomeFragment.setNeedsLayoutInDisplayCutoutModeUpdate();
|
|
106
|
+
awesomeFragment.setNeedsStatusBarAppearanceUpdate();
|
|
107
|
+
awesomeFragment.setNeedsNavigationBarAppearanceUpdate();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
102
111
|
protected void onCreateMainComponent() {
|
|
103
112
|
ReactManager reactManager = getReactManager();
|
|
104
113
|
if (getMainComponentName() != null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<
|
|
2
|
+
<com.navigation.androidx.HybridDrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
3
|
android:id="@+id/drawer"
|
|
4
4
|
android:fitsSystemWindows="false"
|
|
5
5
|
android:layout_width="match_parent"
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
android:layout_gravity="start" />
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
</
|
|
23
|
+
</com.navigation.androidx.HybridDrawerLayout>
|
|
@@ -110,13 +110,14 @@
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
- (void)handleDismissWithViewController:(UIViewController *) vc callback:(RCTResponseSenderBlock)callback {
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
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:
|
|
173
|
+
[presenting presentViewController:vc animated:NO completion:^{
|
|
179
174
|
callback(@[NSNull.null, @YES]);
|
|
180
175
|
}];
|
|
181
176
|
}
|
|
@@ -294,29 +294,7 @@
|
|
|
294
294
|
return (UINavigationController *)vc;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
|
|
298
|
-
if (nav) {
|
|
299
|
-
return nav;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
HBDDrawerController *drawer = vc.drawerController;
|
|
303
|
-
if (!drawer) {
|
|
304
|
-
return nil;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if ([drawer.contentController isKindOfClass:[UITabBarController class]]) {
|
|
308
|
-
UITabBarController *tabs = (UITabBarController *)drawer.contentController;
|
|
309
|
-
if ([tabs.selectedViewController isKindOfClass:[UINavigationController class]]) {
|
|
310
|
-
return (UINavigationController *)tabs.selectedViewController;
|
|
311
|
-
}
|
|
312
|
-
return nil;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
if ([drawer.contentController isKindOfClass:[UINavigationController class]]) {
|
|
316
|
-
return (UINavigationController *)drawer.contentController;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return drawer.contentController.navigationController;
|
|
297
|
+
return vc.navigationController;
|
|
320
298
|
}
|
|
321
299
|
|
|
322
300
|
- (void)invalidate {
|
|
@@ -107,6 +107,11 @@
|
|
|
107
107
|
|
|
108
108
|
- (void)isStackRoot:(nonnull NSString *)sceneId callback:(nonnull RCTResponseSenderBlock)callback {
|
|
109
109
|
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
110
|
+
if (!vc) {
|
|
111
|
+
callback(@[NSNull.null, @NO]);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
UINavigationController *nav = vc.navigationController;
|
|
111
116
|
if (!nav) {
|
|
112
117
|
callback(@[NSNull.null, @NO]);
|
|
@@ -120,17 +125,28 @@
|
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
UIViewController *root = children[0];
|
|
123
|
-
if ([
|
|
128
|
+
if ([self viewController:vc hasAncestorOrSelf:root]) {
|
|
124
129
|
callback(@[NSNull.null, @YES]);
|
|
125
130
|
return;
|
|
126
131
|
}
|
|
127
132
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
callback(@[NSNull.null, @NO]);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
- (BOOL)viewController:(UIViewController *)viewController hasAncestorOrSelf:(UIViewController *)ancestor {
|
|
137
|
+
if (!viewController || !ancestor) {
|
|
138
|
+
return NO;
|
|
131
139
|
}
|
|
132
140
|
|
|
133
|
-
|
|
141
|
+
NSMutableSet<UIViewController *> *visited = [NSMutableSet set];
|
|
142
|
+
for (UIViewController *current = viewController; current != nil && ![visited containsObject:current]; current = current.parentViewController) {
|
|
143
|
+
if (current == ancestor) {
|
|
144
|
+
return YES;
|
|
145
|
+
}
|
|
146
|
+
[visited addObject:current];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return NO;
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
- (void)dispatch:(nonnull NSString *)sceneId action:(nonnull NSString *)action params:(nonnull NSDictionary *)params callback:(nonnull RCTResponseSenderBlock)callback {
|