Browse Source

Change BottomTabs visibility to Invisible instead of Gone

This change is introduced so BottomTabs are actually rendered when created
This commit also fixes back button issue where it wasn't properly added when pushing screens.
Guy Carmeli 6 years ago
parent
commit
990fb5705a

+ 5
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BackButton.java View File

@@ -58,4 +58,9 @@ public class BackButton extends Button {
58 58
         if (!enabled.hasValue()) enabled = defaultOptions.enabled;
59 59
         if (!testId.hasValue()) testId = defaultOptions.testId;
60 60
     }
61
+
62
+    public void setVisible() {
63
+        visible = new Bool(true);
64
+        hasValue = true;
65
+    }
61 66
 }

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

@@ -155,7 +155,7 @@ public class BottomTabsController extends ParentController implements AHBottomNa
155 155
     private void attachTabs() {
156 156
         for (int i = (tabs.size() - 1); i >= 0; i--) {
157 157
             ViewGroup tab = tabs.get(i).getView();
158
-            if (i != 0) tab.setVisibility(View.GONE);
158
+            if (i != 0) tab.setVisibility(View.INVISIBLE);
159 159
             getView().addView(tab);
160 160
         }
161 161
     }
@@ -172,7 +172,7 @@ public class BottomTabsController extends ParentController implements AHBottomNa
172 172
 
173 173
     @Override
174 174
     public void selectTab(final int newIndex) {
175
-        getCurrentView().setVisibility(View.GONE);
175
+        getCurrentView().setVisibility(View.INVISIBLE);
176 176
         bottomTabs.setCurrentItem(newIndex, false);
177 177
         getCurrentView().setVisibility(View.VISIBLE);
178 178
     }

+ 1
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/BackButtonHelper.java View File

@@ -1,14 +1,13 @@
1 1
 package com.reactnativenavigation.viewcontrollers.stack;
2 2
 
3 3
 import com.reactnativenavigation.parse.Options;
4
-import com.reactnativenavigation.parse.params.Bool;
5 4
 import com.reactnativenavigation.viewcontrollers.ViewController;
6 5
 
7 6
 public class BackButtonHelper {
8 7
     public void addToChild(StackController stack, ViewController child) {
9 8
         if (stack.size() <= 1 || child.options.topBar.buttons.left != null || child.options.topBar.buttons.back.visible.isFalse()) return;
10 9
         Options options = new Options();
11
-        options.topBar.buttons.back.visible = new Bool(true);
10
+        options.topBar.buttons.back.setVisible();
12 11
         child.mergeOptions(options);
13 12
     }
14 13
 }

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/BottomTabsControllerTest.java View File

@@ -116,7 +116,7 @@ public class BottomTabsControllerTest extends BaseTest {
116 116
     public void setTabs_firstChildIsVisibleOtherAreGone() {
117 117
         uut.onViewAppeared();
118 118
         for (int i = 0; i < uut.getChildControllers().size(); i++) {
119
-            assertThat(uut.getView().getChildAt(i).getVisibility()).isEqualTo(i == 0 ? View.VISIBLE : View.GONE);
119
+            assertThat(uut.getView().getChildAt(i).getVisibility()).isEqualTo(i == 0 ? View.VISIBLE : View.INVISIBLE);
120 120
         }
121 121
     }
122 122
 
@@ -128,7 +128,7 @@ public class BottomTabsControllerTest extends BaseTest {
128 128
         uut.onTabSelected(3, false);
129 129
 
130 130
         assertThat(uut.getSelectedIndex()).isEqualTo(3);
131
-        assertThat(((ViewController) ((List) uut.getChildControllers()).get(0)).getView().getVisibility()).isEqualTo(View.GONE);
131
+        assertThat(((ViewController) ((List) uut.getChildControllers()).get(0)).getView().getVisibility()).isEqualTo(View.INVISIBLE);
132 132
         assertThat(((ViewController) ((List) uut.getChildControllers()).get(3)).getView().getVisibility()).isEqualTo(View.VISIBLE);
133 133
         verify(eventEmitter, times(1)).emitBottomTabSelected(0, 3);
134 134
     }