react-native-navigation 7.25.1 → 7.25.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/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java +7 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/BottomTabOptions.java +4 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/OverlayOptions.java +3 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/OverlayOptions.kt +31 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/parsers/JSONParser.java +0 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenter.java +2 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +31 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java +6 -13
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +35 -11
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalStack.java +4 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/navigator/Navigator.java +20 -6
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManager.kt +104 -33
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/parent/ParentController.java +86 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuController.java +12 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java +18 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenter.java +51 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/TopBarController.kt +4 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonController.kt +7 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt +1 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/RootPresenter.java +0 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewController.java +12 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabs.java +29 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainer.kt +1 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabsLayout.java +10 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java +10 -2
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/overlay/AttachedOverlayContainer.kt +69 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/overlay/ViewTooltip.java +921 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/sidemenu/SideMenuRoot.java +9 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/StackLayout.java +14 -4
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/TopBar.java +0 -1
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/toptabs/TopTabsStyleHelper.java +0 -1
- package/lib/dist/src/interfaces/Options.d.ts +25 -1
- package/lib/src/interfaces/Options.ts +27 -1
- package/package.json +1 -1
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
package com.reactnativenavigation.viewcontrollers.parent;
|
|
2
2
|
|
|
3
|
+
import static com.reactnativenavigation.utils.CollectionUtils.forEach;
|
|
4
|
+
import static com.reactnativenavigation.utils.ObjectUtils.perform;
|
|
5
|
+
|
|
3
6
|
import android.app.Activity;
|
|
4
7
|
import android.content.res.Configuration;
|
|
5
8
|
import android.view.View;
|
|
6
9
|
import android.view.ViewGroup;
|
|
7
10
|
|
|
11
|
+
import androidx.annotation.CallSuper;
|
|
12
|
+
import androidx.annotation.CheckResult;
|
|
13
|
+
import androidx.annotation.NonNull;
|
|
14
|
+
import androidx.annotation.Nullable;
|
|
15
|
+
import androidx.viewpager.widget.ViewPager;
|
|
16
|
+
|
|
8
17
|
import com.reactnativenavigation.options.Options;
|
|
18
|
+
import com.reactnativenavigation.options.OverlayAttachOptions;
|
|
9
19
|
import com.reactnativenavigation.options.params.Bool;
|
|
10
20
|
import com.reactnativenavigation.utils.CollectionUtils;
|
|
11
21
|
import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabsController;
|
|
12
22
|
import com.reactnativenavigation.viewcontrollers.child.ChildController;
|
|
13
23
|
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
24
|
+
import com.reactnativenavigation.viewcontrollers.stack.StackController;
|
|
14
25
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
15
26
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
16
27
|
import com.reactnativenavigation.views.component.Component;
|
|
17
28
|
|
|
18
29
|
import java.util.Collection;
|
|
19
|
-
|
|
20
|
-
import
|
|
21
|
-
import androidx.annotation.CheckResult;
|
|
22
|
-
import androidx.annotation.NonNull;
|
|
23
|
-
import androidx.annotation.Nullable;
|
|
24
|
-
import androidx.viewpager.widget.ViewPager;
|
|
25
|
-
|
|
26
|
-
import static com.reactnativenavigation.utils.CollectionUtils.*;
|
|
27
|
-
import static com.reactnativenavigation.utils.ObjectUtils.perform;
|
|
30
|
+
import java.util.Collections;
|
|
31
|
+
import java.util.List;
|
|
28
32
|
|
|
29
33
|
public abstract class ParentController<T extends ViewGroup> extends ChildController<T> {
|
|
30
34
|
|
|
@@ -88,6 +92,10 @@ public abstract class ParentController<T extends ViewGroup> extends ChildControl
|
|
|
88
92
|
|
|
89
93
|
public abstract ViewController<?> getCurrentChild();
|
|
90
94
|
|
|
95
|
+
public List<ViewController<?>> getChildren(){
|
|
96
|
+
return Collections.emptyList();
|
|
97
|
+
}
|
|
98
|
+
|
|
91
99
|
@NonNull
|
|
92
100
|
@Override
|
|
93
101
|
public abstract T createView();
|
|
@@ -103,6 +111,51 @@ public abstract class ParentController<T extends ViewGroup> extends ChildControl
|
|
|
103
111
|
return perform(getParentController(), null, ParentController::getBottomTabsController);
|
|
104
112
|
}
|
|
105
113
|
|
|
114
|
+
@Override
|
|
115
|
+
protected View findTooltipAnchorView(OverlayAttachOptions options) {
|
|
116
|
+
final String id = options.anchorId.get();
|
|
117
|
+
View found = null;
|
|
118
|
+
final View topBarView = findTopBarViewById(id);
|
|
119
|
+
if (topBarView != null) {
|
|
120
|
+
found = topBarView;
|
|
121
|
+
} else {
|
|
122
|
+
final View bottomTabViewById = findBottomTabViewById(id);
|
|
123
|
+
if (bottomTabViewById != null) {
|
|
124
|
+
found = bottomTabViewById;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return found;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Nullable
|
|
131
|
+
protected View findTopBarViewById(String id) {
|
|
132
|
+
final View[] found = {null};
|
|
133
|
+
lookup((controller) -> {
|
|
134
|
+
if (controller instanceof StackController) {
|
|
135
|
+
final StackController stackController = (StackController) controller;
|
|
136
|
+
final View topBarViewById = stackController.presenter.findTopBarViewById(id);
|
|
137
|
+
found[0] = topBarViewById;
|
|
138
|
+
return topBarViewById != null;
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
});
|
|
142
|
+
return found[0];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@Nullable
|
|
146
|
+
protected View findBottomTabViewById(@NonNull String id) {
|
|
147
|
+
final View[] found = {null};
|
|
148
|
+
lookup((controller) -> {
|
|
149
|
+
if (controller instanceof BottomTabsController) {
|
|
150
|
+
BottomTabsController bottomTabsController = (BottomTabsController) controller;
|
|
151
|
+
found[0] = bottomTabsController.getTabViewByTag(id);
|
|
152
|
+
return found[0] != null;
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
});
|
|
156
|
+
return found[0];
|
|
157
|
+
}
|
|
158
|
+
|
|
106
159
|
@Nullable
|
|
107
160
|
@Override
|
|
108
161
|
public ViewController<?> findController(final String id) {
|
|
@@ -204,6 +257,30 @@ public abstract class ParentController<T extends ViewGroup> extends ChildControl
|
|
|
204
257
|
return getCurrentChild().getCurrentComponentName();
|
|
205
258
|
}
|
|
206
259
|
|
|
260
|
+
protected interface LookupPredicate<T> {
|
|
261
|
+
boolean test(T t);
|
|
262
|
+
}
|
|
263
|
+
public ViewController<?> lookup(LookupPredicate<ViewController<?>> predicate){
|
|
264
|
+
if(predicate.test(this)){
|
|
265
|
+
return this;
|
|
266
|
+
}else{
|
|
267
|
+
final List<ViewController<?>> children = getChildren();
|
|
268
|
+
for(ViewController<?> child : children){
|
|
269
|
+
if(child instanceof ParentController){
|
|
270
|
+
ViewController<?> result= ((ParentController<?>) child).lookup(predicate);
|
|
271
|
+
if(result!=null){
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
}else{
|
|
275
|
+
if(predicate.test(child)){
|
|
276
|
+
return child;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
207
284
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
208
285
|
super.onConfigurationChanged(newConfig);
|
|
209
286
|
Collection<? extends ViewController<?>> childControllers = getChildControllers();
|
|
@@ -3,8 +3,10 @@ package com.reactnativenavigation.viewcontrollers.sidemenu;
|
|
|
3
3
|
import android.app.Activity;
|
|
4
4
|
import android.view.Gravity;
|
|
5
5
|
import android.view.View;
|
|
6
|
+
import android.view.ViewGroup;
|
|
6
7
|
|
|
7
8
|
import com.reactnativenavigation.options.Options;
|
|
9
|
+
import com.reactnativenavigation.options.OverlayAttachOptions;
|
|
8
10
|
import com.reactnativenavigation.options.SideMenuRootOptions;
|
|
9
11
|
import com.reactnativenavigation.options.params.Bool;
|
|
10
12
|
import com.reactnativenavigation.react.CommandListener;
|
|
@@ -12,6 +14,7 @@ import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
|
|
|
12
14
|
import com.reactnativenavigation.viewcontrollers.parent.ParentController;
|
|
13
15
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
14
16
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
17
|
+
import com.reactnativenavigation.views.overlay.ViewTooltip;
|
|
15
18
|
import com.reactnativenavigation.views.sidemenu.SideMenu;
|
|
16
19
|
import com.reactnativenavigation.views.sidemenu.SideMenuRoot;
|
|
17
20
|
|
|
@@ -65,6 +68,15 @@ public class SideMenuController extends ParentController<SideMenuRoot> implement
|
|
|
65
68
|
return root;
|
|
66
69
|
}
|
|
67
70
|
|
|
71
|
+
@Override
|
|
72
|
+
public ViewTooltip.TooltipView showAnchoredOverlay(@NonNull View anchorView, @NonNull OverlayAttachOptions overlayAttachOptions, @NonNull ViewController<?> overlayViewController) {
|
|
73
|
+
if (view != null) {
|
|
74
|
+
return view.getAttachedOverlayContainer().addAnchoredView(anchorView, overlayViewController.getView(),
|
|
75
|
+
overlayAttachOptions.gravity.get());
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
68
80
|
@Override
|
|
69
81
|
public void sendOnNavigationButtonPressed(String buttonId) {
|
|
70
82
|
center.sendOnNavigationButtonPressed(buttonId);
|
|
@@ -8,6 +8,7 @@ import android.view.ViewGroup;
|
|
|
8
8
|
import com.facebook.react.ReactRootView;
|
|
9
9
|
import com.reactnativenavigation.options.ButtonOptions;
|
|
10
10
|
import com.reactnativenavigation.options.Options;
|
|
11
|
+
import com.reactnativenavigation.options.OverlayAttachOptions;
|
|
11
12
|
import com.reactnativenavigation.options.StackAnimationOptions;
|
|
12
13
|
import com.reactnativenavigation.react.CommandListener;
|
|
13
14
|
import com.reactnativenavigation.react.CommandListenerAdapter;
|
|
@@ -19,6 +20,7 @@ import com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController;
|
|
|
19
20
|
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.BackButtonHelper;
|
|
20
21
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
|
|
21
22
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
23
|
+
import com.reactnativenavigation.views.overlay.ViewTooltip;
|
|
22
24
|
import com.reactnativenavigation.views.component.Component;
|
|
23
25
|
import com.reactnativenavigation.views.stack.StackBehaviour;
|
|
24
26
|
import com.reactnativenavigation.views.stack.StackLayout;
|
|
@@ -32,6 +34,7 @@ import java.util.Iterator;
|
|
|
32
34
|
import java.util.List;
|
|
33
35
|
|
|
34
36
|
import androidx.annotation.NonNull;
|
|
37
|
+
import androidx.annotation.Nullable;
|
|
35
38
|
import androidx.annotation.RestrictTo;
|
|
36
39
|
import androidx.annotation.Size;
|
|
37
40
|
import androidx.annotation.VisibleForTesting;
|
|
@@ -51,7 +54,7 @@ public class StackController extends ParentController<StackLayout> {
|
|
|
51
54
|
private final EventEmitter eventEmitter;
|
|
52
55
|
private final TopBarController topBarController;
|
|
53
56
|
private final BackButtonHelper backButtonHelper;
|
|
54
|
-
|
|
57
|
+
public final StackPresenter presenter;
|
|
55
58
|
private final FabPresenter fabPresenter;
|
|
56
59
|
|
|
57
60
|
public StackController(Activity activity, List<ViewController<?>> children, ChildControllersRegistry childRegistry, EventEmitter eventEmitter, TopBarController topBarController, StackAnimator animator, String id, Options initialOptions, BackButtonHelper backButtonHelper, StackPresenter stackPresenter, Presenter presenter, FabPresenter fabPresenter) {
|
|
@@ -478,6 +481,20 @@ public class StackController extends ParentController<StackLayout> {
|
|
|
478
481
|
return false;
|
|
479
482
|
}
|
|
480
483
|
|
|
484
|
+
@Override
|
|
485
|
+
public ViewTooltip.TooltipView showAnchoredOverlay(@NonNull View anchorView, @NonNull OverlayAttachOptions overlayAttachOptions, @NonNull ViewController<?> overlayViewController) {
|
|
486
|
+
if(view!=null){
|
|
487
|
+
return( (StackLayout)view).getAttachedOverlayContainer().addAnchoredView(anchorView, overlayViewController.getView(),
|
|
488
|
+
overlayAttachOptions.gravity.get());
|
|
489
|
+
}
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
@Override
|
|
494
|
+
public List<ViewController<?>> getChildren() {
|
|
495
|
+
return stack.values();
|
|
496
|
+
}
|
|
497
|
+
|
|
481
498
|
@Override
|
|
482
499
|
public int getTopInset(ViewController<?> child) {
|
|
483
500
|
return presenter.getTopInset(resolveChildOptions(child));
|
|
@@ -10,6 +10,8 @@ import static com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarContr
|
|
|
10
10
|
import android.animation.Animator;
|
|
11
11
|
import android.app.Activity;
|
|
12
12
|
import android.graphics.Color;
|
|
13
|
+
import android.util.Pair;
|
|
14
|
+
import android.view.MenuItem;
|
|
13
15
|
import android.view.View;
|
|
14
16
|
import android.view.ViewGroup;
|
|
15
17
|
import android.view.ViewGroup.LayoutParams;
|
|
@@ -49,10 +51,12 @@ import com.reactnativenavigation.viewcontrollers.viewcontroller.IReactView;
|
|
|
49
51
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
|
|
50
52
|
import com.reactnativenavigation.views.stack.topbar.TopBar;
|
|
51
53
|
import com.reactnativenavigation.views.stack.topbar.TopBarBackgroundViewCreator;
|
|
54
|
+
import com.reactnativenavigation.views.stack.topbar.titlebar.ButtonBar;
|
|
52
55
|
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleBarButtonCreator;
|
|
53
56
|
import com.reactnativenavigation.views.stack.topbar.titlebar.TitleBarReactViewCreator;
|
|
54
57
|
|
|
55
58
|
import java.util.ArrayList;
|
|
59
|
+
import java.util.Collection;
|
|
56
60
|
import java.util.Collections;
|
|
57
61
|
import java.util.HashMap;
|
|
58
62
|
import java.util.List;
|
|
@@ -674,4 +678,51 @@ public class StackPresenter {
|
|
|
674
678
|
public int getTopInset(Options resolvedOptions) {
|
|
675
679
|
return resolvedOptions.withDefaultOptions(defaultOptions).topBar.isHiddenOrDrawBehind() ? 0 : topBarController.getHeight();
|
|
676
680
|
}
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
private TitleBarReactViewController findTitleById(String id){
|
|
684
|
+
final Collection<TitleBarReactViewController> values = titleControllers.values();
|
|
685
|
+
for(TitleBarReactViewController child: values){
|
|
686
|
+
if(child.getId().equals(id)){
|
|
687
|
+
return child;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
692
|
+
private Pair<ButtonController, ButtonBar> findButtonById(String id){
|
|
693
|
+
final Collection<Map<String, ButtonController>> leftControllers = leftButtonControllers.values();
|
|
694
|
+
final Collection<Map<String, ButtonController>> rightControllers = rightButtonControllers.values();
|
|
695
|
+
for(Map<String, ButtonController> map : leftControllers){
|
|
696
|
+
if(map.containsKey(id)){
|
|
697
|
+
return Pair.create(map.get(id),topBar.getLeftButtonBar());
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
for(Map<String, ButtonController> map : rightControllers){
|
|
701
|
+
if(map.containsKey(id)){
|
|
702
|
+
return Pair.create(map.get(id),topBar.getRightButtonBar());
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
@Nullable
|
|
708
|
+
public View findTopBarViewById(String id) {
|
|
709
|
+
final Pair<ButtonController, ButtonBar> buttonById = findButtonById(id);
|
|
710
|
+
if(buttonById!=null){
|
|
711
|
+
final View view = buttonById.first.getNullableView();
|
|
712
|
+
if(view==null){
|
|
713
|
+
final MenuItem menuItem = buttonById.first.getMenuItem();
|
|
714
|
+
if(menuItem!=null){
|
|
715
|
+
final int order = menuItem.getOrder();
|
|
716
|
+
return buttonById.second.getChildAt(order/10);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return view;
|
|
720
|
+
}else {
|
|
721
|
+
final TitleBarReactViewController titleById = findTitleById(id);
|
|
722
|
+
if(titleById!=null){
|
|
723
|
+
return titleById.getView();
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
677
728
|
}
|
|
@@ -177,14 +177,16 @@ open class TopBarController(private val animator: TopBarAnimator = TopBarAnimato
|
|
|
177
177
|
controllerCreator: (ButtonOptions) -> ButtonController,
|
|
178
178
|
buttonBar: ButtonBar
|
|
179
179
|
) {
|
|
180
|
+
buttonBar.clearButtons()
|
|
180
181
|
if (buttonBar.shouldAnimate)
|
|
181
182
|
TransitionManager.beginDelayedTransition(buttonBar, buttonsTransition)
|
|
182
183
|
|
|
183
|
-
buttonBar.clearButtons()
|
|
184
184
|
buttons.forEachIndexed { index, it ->
|
|
185
185
|
val order = index * 10
|
|
186
186
|
val newController = if (btnControllers.containsKey(it.id)) {
|
|
187
|
-
btnControllers.remove(it.id)
|
|
187
|
+
btnControllers.remove(it.id)?.apply {
|
|
188
|
+
this.mergeButtonOptions(it,buttonBar)
|
|
189
|
+
}
|
|
188
190
|
} else {
|
|
189
191
|
controllerCreator(it)
|
|
190
192
|
}!!
|
|
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|
|
4
4
|
import android.app.Activity
|
|
5
5
|
import android.view.Menu
|
|
6
6
|
import android.view.MenuItem
|
|
7
|
+
import android.view.View
|
|
7
8
|
import androidx.appcompat.widget.Toolbar
|
|
8
9
|
import com.reactnativenavigation.options.ButtonOptions
|
|
9
10
|
import com.reactnativenavigation.options.Options
|
|
@@ -22,7 +23,8 @@ open class ButtonController(activity: Activity,
|
|
|
22
23
|
private val viewCreator: TitleBarButtonCreator,
|
|
23
24
|
private val onPressListener: OnClickListener) : ViewController<TitleBarReactButtonView>(activity, button.id, YellowBoxDelegate(activity), Options(), ViewControllerOverlay(activity)), MenuItem.OnMenuItemClickListener {
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
var menuItem: MenuItem? = null
|
|
27
|
+
private set
|
|
26
28
|
|
|
27
29
|
interface OnClickListener {
|
|
28
30
|
fun onPress(button: ButtonOptions)
|
|
@@ -113,4 +115,8 @@ open class ButtonController(activity: Activity,
|
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
|
|
118
|
+
fun getNullableView(): View?{
|
|
119
|
+
return view
|
|
120
|
+
}
|
|
121
|
+
|
|
116
122
|
}
|
|
@@ -11,7 +11,6 @@ import androidx.annotation.VisibleForTesting;
|
|
|
11
11
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
12
12
|
|
|
13
13
|
import kotlin.Unit;
|
|
14
|
-
import kotlin.jvm.functions.Function0;
|
|
15
14
|
|
|
16
15
|
import static com.reactnativenavigation.utils.CoordinatorLayoutUtils.matchParentWithBehaviour;
|
|
17
16
|
|
|
@@ -12,11 +12,13 @@ import android.view.ViewTreeObserver;
|
|
|
12
12
|
|
|
13
13
|
import androidx.annotation.CallSuper;
|
|
14
14
|
import androidx.annotation.CheckResult;
|
|
15
|
+
import androidx.annotation.NonNull;
|
|
15
16
|
import androidx.annotation.Nullable;
|
|
16
17
|
import androidx.annotation.VisibleForTesting;
|
|
17
18
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
18
19
|
|
|
19
20
|
import com.reactnativenavigation.options.Options;
|
|
21
|
+
import com.reactnativenavigation.options.OverlayAttachOptions;
|
|
20
22
|
import com.reactnativenavigation.options.params.Bool;
|
|
21
23
|
import com.reactnativenavigation.options.params.NullBool;
|
|
22
24
|
import com.reactnativenavigation.react.CommandListener;
|
|
@@ -28,6 +30,7 @@ import com.reactnativenavigation.viewcontrollers.parent.ParentController;
|
|
|
28
30
|
import com.reactnativenavigation.viewcontrollers.stack.StackController;
|
|
29
31
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.overlay.ViewControllerOverlay;
|
|
30
32
|
import com.reactnativenavigation.views.BehaviourAdapter;
|
|
33
|
+
import com.reactnativenavigation.views.overlay.ViewTooltip;
|
|
31
34
|
import com.reactnativenavigation.views.component.Component;
|
|
32
35
|
import com.reactnativenavigation.views.component.Renderable;
|
|
33
36
|
|
|
@@ -392,6 +395,15 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
|
|
|
392
395
|
|
|
393
396
|
}
|
|
394
397
|
|
|
398
|
+
protected View findTooltipAnchorView(OverlayAttachOptions options) {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
public ViewTooltip.TooltipView showAnchoredOverlay(@NonNull View anchorView,
|
|
403
|
+
@NonNull OverlayAttachOptions overlayAttachOptions,
|
|
404
|
+
@NonNull ViewController<?> overlayViewController) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
395
407
|
public int getBottomInset() {
|
|
396
408
|
return perform(parentController, 0, p -> p.getBottomInset(this));
|
|
397
409
|
}
|
package/lib/android/app/src/main/java/com/reactnativenavigation/views/bottomtabs/BottomTabs.java
CHANGED
|
@@ -12,7 +12,9 @@ import com.reactnativenavigation.R;
|
|
|
12
12
|
import com.reactnativenavigation.options.LayoutDirection;
|
|
13
13
|
|
|
14
14
|
import java.util.ArrayList;
|
|
15
|
+
import java.util.HashMap;
|
|
15
16
|
import java.util.List;
|
|
17
|
+
import java.util.Map;
|
|
16
18
|
|
|
17
19
|
import androidx.annotation.IntRange;
|
|
18
20
|
|
|
@@ -21,10 +23,11 @@ import static com.reactnativenavigation.utils.ViewUtils.findChildByClass;
|
|
|
21
23
|
|
|
22
24
|
@SuppressLint("ViewConstructor")
|
|
23
25
|
public class BottomTabs extends AHBottomNavigation {
|
|
26
|
+
public final static int TAB_NOT_FOUND = -1;
|
|
24
27
|
private boolean itemsCreationEnabled = true;
|
|
25
28
|
private boolean shouldCreateItems = true;
|
|
26
29
|
private List<Runnable> onItemCreationEnabled = new ArrayList<>();
|
|
27
|
-
|
|
30
|
+
private final Map<String,Integer> idPositionMapping = new HashMap<>();
|
|
28
31
|
public BottomTabs(Context context) {
|
|
29
32
|
super(context);
|
|
30
33
|
setId(R.id.bottomTabs);
|
|
@@ -132,4 +135,29 @@ public class BottomTabs extends AHBottomNavigation {
|
|
|
132
135
|
private boolean hasItemsAndIsMeasured(int w, int h, int oldw, int oldh) {
|
|
133
136
|
return w != 0 && h != 0 && (w != oldw || h != oldh) && getItemsCount() > 0;
|
|
134
137
|
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
public void setTagForTabIndex(int index, String tag) {
|
|
141
|
+
if(tag==null){
|
|
142
|
+
String oldTag = null;
|
|
143
|
+
for(Map.Entry<String,Integer> e: idPositionMapping.entrySet()){
|
|
144
|
+
if(e.getValue() == index){
|
|
145
|
+
oldTag = e.getKey();
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if(oldTag!=null){
|
|
150
|
+
idPositionMapping.remove(oldTag);
|
|
151
|
+
}
|
|
152
|
+
}else{
|
|
153
|
+
idPositionMapping.put(tag,index);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public int getTabIndexByTag(String tag) {
|
|
158
|
+
if(tag!=null && idPositionMapping.containsKey(tag)){
|
|
159
|
+
return idPositionMapping.get(tag);
|
|
160
|
+
}
|
|
161
|
+
return TAB_NOT_FOUND;
|
|
162
|
+
}
|
|
135
163
|
}
|
|
@@ -10,12 +10,21 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
|
10
10
|
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
11
11
|
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
12
12
|
|
|
13
|
+
import com.reactnativenavigation.views.overlay.AttachedOverlayContainer;
|
|
14
|
+
|
|
13
15
|
public class BottomTabsLayout extends CoordinatorLayout {
|
|
14
16
|
|
|
15
17
|
private BottomTabsContainer bottomTabsContainer;
|
|
18
|
+
final private AttachedOverlayContainer attachedOverlayContainer ;
|
|
16
19
|
|
|
17
20
|
public BottomTabsLayout(Context context) {
|
|
18
21
|
super(context);
|
|
22
|
+
attachedOverlayContainer=new AttachedOverlayContainer(context);
|
|
23
|
+
this.addView(attachedOverlayContainer, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public AttachedOverlayContainer getAttachedOverlayContainer() {
|
|
27
|
+
return attachedOverlayContainer;
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
@Override
|
|
@@ -33,4 +42,4 @@ public class BottomTabsLayout extends CoordinatorLayout {
|
|
|
33
42
|
addView(bottomTabsContainer, lp);
|
|
34
43
|
this.bottomTabsContainer = bottomTabsContainer;
|
|
35
44
|
}
|
|
36
|
-
}
|
|
45
|
+
}
|
package/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java
CHANGED
|
@@ -4,15 +4,16 @@ import android.annotation.SuppressLint;
|
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.view.MotionEvent;
|
|
6
6
|
import android.view.ViewGroup;
|
|
7
|
-
import android.view.WindowInsets;
|
|
8
7
|
|
|
9
8
|
import com.reactnativenavigation.options.ButtonOptions;
|
|
9
|
+
import com.reactnativenavigation.utils.CoordinatorLayoutUtils;
|
|
10
10
|
import com.reactnativenavigation.viewcontrollers.viewcontroller.ScrollEventListener;
|
|
11
11
|
import com.reactnativenavigation.options.Options;
|
|
12
12
|
import com.reactnativenavigation.options.params.Bool;
|
|
13
13
|
import com.reactnativenavigation.react.ReactView;
|
|
14
14
|
import com.reactnativenavigation.react.events.ComponentType;
|
|
15
15
|
import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController;
|
|
16
|
+
import com.reactnativenavigation.views.overlay.AttachedOverlayContainer;
|
|
16
17
|
import com.reactnativenavigation.views.touch.OverlayTouchDelegate;
|
|
17
18
|
|
|
18
19
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
@@ -25,14 +26,21 @@ public class ComponentLayout extends CoordinatorLayout implements ReactComponent
|
|
|
25
26
|
private boolean willAppearSent = false;
|
|
26
27
|
private ReactView reactView;
|
|
27
28
|
private final OverlayTouchDelegate touchDelegate;
|
|
29
|
+
final private AttachedOverlayContainer attachedOverlayContainer ;
|
|
28
30
|
|
|
29
31
|
public ComponentLayout(Context context, ReactView reactView) {
|
|
30
32
|
super(context);
|
|
31
33
|
this.reactView = reactView;
|
|
34
|
+
attachedOverlayContainer = new AttachedOverlayContainer(context);
|
|
32
35
|
addView(reactView.asView(), matchParentLP());
|
|
36
|
+
addView(attachedOverlayContainer, CoordinatorLayoutUtils.matchParentLP());
|
|
33
37
|
touchDelegate = new OverlayTouchDelegate(this, reactView);
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
public AttachedOverlayContainer getAttachedOverlayContainer() {
|
|
41
|
+
return attachedOverlayContainer;
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
@Override
|
|
37
45
|
public boolean isReady() {
|
|
38
46
|
return reactView.isReady();
|
|
@@ -109,4 +117,4 @@ public class ComponentLayout extends CoordinatorLayout implements ReactComponent
|
|
|
109
117
|
public boolean superOnInterceptTouchEvent(MotionEvent event) {
|
|
110
118
|
return super.onInterceptTouchEvent(event);
|
|
111
119
|
}
|
|
112
|
-
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
package com.reactnativenavigation.views.overlay
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.graphics.Color
|
|
6
|
+
import android.view.View
|
|
7
|
+
import android.widget.FrameLayout
|
|
8
|
+
|
|
9
|
+
class AttachedOverlayContainer(context: Context) : FrameLayout(context) {
|
|
10
|
+
|
|
11
|
+
init {
|
|
12
|
+
z = Float.MAX_VALUE
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
fun addOverlay(overlayView: View) {
|
|
16
|
+
addView(overlayView)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fun addAnchoredView(anchorView: View, overlayView: View, gravity: String): ViewTooltip.TooltipView? {
|
|
20
|
+
return when (gravity) {
|
|
21
|
+
"top" -> {
|
|
22
|
+
showTooltip(overlayView, anchorView, ViewTooltip.Position.TOP)
|
|
23
|
+
}
|
|
24
|
+
"bottom" -> {
|
|
25
|
+
showTooltip(overlayView, anchorView, ViewTooltip.Position.BOTTOM)
|
|
26
|
+
}
|
|
27
|
+
"left" -> {
|
|
28
|
+
showTooltip(overlayView, anchorView, ViewTooltip.Position.LEFT)
|
|
29
|
+
}
|
|
30
|
+
"right" -> {
|
|
31
|
+
showTooltip(overlayView, anchorView, ViewTooltip.Position.RIGHT)
|
|
32
|
+
}
|
|
33
|
+
else -> {
|
|
34
|
+
showTooltip(overlayView, anchorView, ViewTooltip.Position.TOP)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
private fun showTooltip(
|
|
42
|
+
tooltipView: View,
|
|
43
|
+
tooltipAnchorView: View,
|
|
44
|
+
pos: ViewTooltip.Position
|
|
45
|
+
): ViewTooltip.TooltipView {
|
|
46
|
+
val tooltipViewContainer = ViewTooltip
|
|
47
|
+
.on(context as Activity, this, tooltipAnchorView)
|
|
48
|
+
.autoHide(false, 5000)
|
|
49
|
+
.clickToHide(false)
|
|
50
|
+
.align(ViewTooltip.ALIGN.CENTER)
|
|
51
|
+
.padding(0, 0, 0, 0)
|
|
52
|
+
.customView(tooltipView)
|
|
53
|
+
.distanceWithView(0)
|
|
54
|
+
.color(Color.WHITE)
|
|
55
|
+
.bubble(false)
|
|
56
|
+
.arrowHeight(0)
|
|
57
|
+
.arrowWidth(0)
|
|
58
|
+
.position(pos)
|
|
59
|
+
|
|
60
|
+
.onDisplay {
|
|
61
|
+
}
|
|
62
|
+
.onHide {
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
.show()
|
|
66
|
+
return tooltipViewContainer
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|