|
@@ -212,7 +212,13 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
|
212
|
212
|
}
|
213
|
213
|
|
214
|
214
|
public void switchToTab(ReadableMap params) {
|
215
|
|
- int tabIndex = params.getInt(KEY_TAB_INDEX);
|
|
215
|
+ Integer tabIndex;
|
|
216
|
+ if (params.hasKey(KEY_TAB_INDEX)) {
|
|
217
|
+ tabIndex = params.getInt(KEY_TAB_INDEX);
|
|
218
|
+ } else {
|
|
219
|
+ final String navigatorId = params.getString(KEY_NAVIGATOR_ID);
|
|
220
|
+ tabIndex = findNavigatorTabIndex(navigatorId);
|
|
221
|
+ }
|
216
|
222
|
mBottomNavigation.setCurrentItem(tabIndex);
|
217
|
223
|
}
|
218
|
224
|
|
|
@@ -255,6 +261,17 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
|
255
|
261
|
}
|
256
|
262
|
}
|
257
|
263
|
|
|
264
|
+ protected Integer findNavigatorTabIndex(String navigatorId) {
|
|
265
|
+ for (int i = 0; i < mScreenStacks.size(); i++) {
|
|
266
|
+ ScreenStack stack = mScreenStacks.get(i);
|
|
267
|
+ if (!stack.isEmpty() && stack.peek().navigatorId.equals(navigatorId)) {
|
|
268
|
+ return i;
|
|
269
|
+ }
|
|
270
|
+ }
|
|
271
|
+
|
|
272
|
+ return null;
|
|
273
|
+ }
|
|
274
|
+
|
258
|
275
|
private void setTabsWithIcons(ArrayList<Screen> screens, Map<Screen, Drawable> icons) {
|
259
|
276
|
mScreenStacks = new ArrayList<>();
|
260
|
277
|
for (Screen screen : screens) {
|
|
@@ -268,6 +285,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
|
268
|
285
|
this.onTabSelected(0, false);
|
269
|
286
|
}
|
270
|
287
|
|
|
288
|
+
|
271
|
289
|
@Override
|
272
|
290
|
protected void removeAllReactViews() {
|
273
|
291
|
for (ScreenStack screenStack : mScreenStacks) {
|