Browse Source

Merge branch 'moutAllTabs' into v2

Guy Carmeli 6 years ago
parent
commit
fed8f1b0c5

+ 12
- 3
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java View File

4
 import android.graphics.drawable.Drawable;
4
 import android.graphics.drawable.Drawable;
5
 import android.support.annotation.NonNull;
5
 import android.support.annotation.NonNull;
6
 import android.support.annotation.RestrictTo;
6
 import android.support.annotation.RestrictTo;
7
+import android.view.View;
7
 import android.view.ViewGroup;
8
 import android.view.ViewGroup;
8
 import android.widget.RelativeLayout;
9
 import android.widget.RelativeLayout;
9
 
10
 
140
                         bottomTabs.setTabTestId(i, bottomTabOptionsList.get(i).testId);
141
                         bottomTabs.setTabTestId(i, bottomTabOptionsList.get(i).testId);
141
                     }
142
                     }
142
                 });
143
                 });
143
-                selectTab(0);
144
+                attachTabs();
144
             }
145
             }
145
 
146
 
146
             @Override
147
             @Override
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
     public int getSelectedIndex() {
163
     public int getSelectedIndex() {
155
 		return bottomTabs.getCurrentItem();
164
 		return bottomTabs.getCurrentItem();
156
 	}
165
 	}
163
 
172
 
164
     @Override
173
     @Override
165
     public void selectTab(final int newIndex) {
174
     public void selectTab(final int newIndex) {
166
-        getView().removeView(getCurrentView());
175
+        getCurrentView().setVisibility(View.GONE);
167
         bottomTabs.setCurrentItem(newIndex, false);
176
         bottomTabs.setCurrentItem(newIndex, false);
168
-        getView().addView(getCurrentView());
177
+        getCurrentView().setVisibility(View.VISIBLE);
169
     }
178
     }
170
 
179
 
171
     @NonNull
180
     @NonNull