Kaynağa Gözat

Merge branch 'moutAllTabs' into v2

Guy Carmeli 6 yıl önce
ebeveyn
işleme
fed8f1b0c5

+ 12
- 3
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java Dosyayı Görüntüle

@@ -4,6 +4,7 @@ import android.app.Activity;
4 4
 import android.graphics.drawable.Drawable;
5 5
 import android.support.annotation.NonNull;
6 6
 import android.support.annotation.RestrictTo;
7
+import android.view.View;
7 8
 import android.view.ViewGroup;
8 9
 import android.widget.RelativeLayout;
9 10
 
@@ -140,7 +141,7 @@ public class BottomTabsController extends ParentController implements AHBottomNa
140 141
                         bottomTabs.setTabTestId(i, bottomTabOptionsList.get(i).testId);
141 142
                     }
142 143
                 });
143
-                selectTab(0);
144
+                attachTabs();
144 145
             }
145 146
 
146 147
             @Override
@@ -151,6 +152,14 @@ public class BottomTabsController extends ParentController implements AHBottomNa
151 152
 
152 153
 	}
153 154
 
155
+    private void attachTabs() {
156
+        for (int i = (tabs.size() - 1); i >= 0; i--) {
157
+            ViewGroup tab = tabs.get(i).getView();
158
+            if (i != 0) tab.setVisibility(View.GONE);
159
+            getView().addView(tab);
160
+        }
161
+    }
162
+
154 163
     public int getSelectedIndex() {
155 164
 		return bottomTabs.getCurrentItem();
156 165
 	}
@@ -163,9 +172,9 @@ public class BottomTabsController extends ParentController implements AHBottomNa
163 172
 
164 173
     @Override
165 174
     public void selectTab(final int newIndex) {
166
-        getView().removeView(getCurrentView());
175
+        getCurrentView().setVisibility(View.GONE);
167 176
         bottomTabs.setCurrentItem(newIndex, false);
168
-        getView().addView(getCurrentView());
177
+        getCurrentView().setVisibility(View.VISIBLE);
169 178
     }
170 179
 
171 180
     @NonNull