|
@@ -3,6 +3,7 @@ package com.reactnativenavigation.viewcontrollers;
|
3
|
3
|
import android.app.Activity;
|
4
|
4
|
import android.graphics.Color;
|
5
|
5
|
import android.graphics.drawable.Drawable;
|
|
6
|
+import android.support.annotation.IntRange;
|
6
|
7
|
import android.support.annotation.NonNull;
|
7
|
8
|
import android.view.ViewGroup;
|
8
|
9
|
import android.widget.RelativeLayout;
|
|
@@ -13,10 +14,12 @@ import com.reactnativenavigation.parse.BottomTabOptions;
|
13
|
14
|
import com.reactnativenavigation.parse.BottomTabsOptions;
|
14
|
15
|
import com.reactnativenavigation.parse.Options;
|
15
|
16
|
import com.reactnativenavigation.parse.Text;
|
|
17
|
+import com.reactnativenavigation.presentation.BottomTabOptionsPresenter;
|
16
|
18
|
import com.reactnativenavigation.presentation.NavigationOptionsListener;
|
17
|
19
|
import com.reactnativenavigation.utils.ImageLoader;
|
18
|
20
|
import com.reactnativenavigation.utils.UiUtils;
|
19
|
21
|
import com.reactnativenavigation.views.BottomTabs;
|
|
22
|
+import com.reactnativenavigation.views.ReactComponent;
|
20
|
23
|
|
21
|
24
|
import java.util.ArrayList;
|
22
|
25
|
import java.util.Collection;
|
|
@@ -50,7 +53,13 @@ public class BottomTabsController extends ParentController implements AHBottomNa
|
50
|
53
|
return root;
|
51
|
54
|
}
|
52
|
55
|
|
53
|
|
- @Override
|
|
56
|
+ @Override
|
|
57
|
+ public void applyOptions(Options options, ReactComponent childComponent) {
|
|
58
|
+ int tabIndex = findTabContainingComponent(childComponent);
|
|
59
|
+ if (tabIndex >= 0) new BottomTabOptionsPresenter(bottomTabs).present(options, tabIndex);
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ @Override
|
54
|
63
|
public boolean handleBack() {
|
55
|
64
|
return !tabs.isEmpty() && tabs.get(bottomTabs.getCurrentItem()).handleBack();
|
56
|
65
|
}
|
|
@@ -69,6 +78,7 @@ public class BottomTabsController extends ParentController implements AHBottomNa
|
69
|
78
|
this.tabs = tabs;
|
70
|
79
|
getView();
|
71
|
80
|
for (int i = 0; i < tabs.size(); i++) {
|
|
81
|
+ tabs.get(i).setParentController(this);
|
72
|
82
|
createTab(i, tabs.get(i).options.bottomTabOptions, tabs.get(i).options.bottomTabsOptions);
|
73
|
83
|
}
|
74
|
84
|
selectTabAtIndex(0);
|
|
@@ -113,6 +123,7 @@ public class BottomTabsController extends ParentController implements AHBottomNa
|
113
|
123
|
|
114
|
124
|
@Override
|
115
|
125
|
public void mergeOptions(Options options) {
|
|
126
|
+ this.options.mergeWith(options);
|
116
|
127
|
if (options.bottomTabsOptions.currentTabIndex != NO_INT_VALUE) {
|
117
|
128
|
selectTabAtIndex(options.bottomTabsOptions.currentTabIndex);
|
118
|
129
|
}
|
|
@@ -153,4 +164,14 @@ public class BottomTabsController extends ParentController implements AHBottomNa
|
153
|
164
|
}
|
154
|
165
|
return false;
|
155
|
166
|
}
|
|
167
|
+
|
|
168
|
+ @IntRange(from = -1)
|
|
169
|
+ private int findTabContainingComponent(ReactComponent component) {
|
|
170
|
+ for (int i = 0; i < tabs.size(); i++) {
|
|
171
|
+ if (tabs.get(i).containsComponent(component)) {
|
|
172
|
+ return i;
|
|
173
|
+ }
|
|
174
|
+ }
|
|
175
|
+ return -1;
|
|
176
|
+ }
|
156
|
177
|
}
|