Browse Source

Support tabBarHidden property

Guy Carmeli 8 years ago
parent
commit
0aaed3300d

+ 25
- 3
android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java View File

5
 import android.os.AsyncTask;
5
 import android.os.AsyncTask;
6
 import android.os.Bundle;
6
 import android.os.Bundle;
7
 import android.view.Menu;
7
 import android.view.Menu;
8
+import android.view.View;
8
 import android.widget.FrameLayout;
9
 import android.widget.FrameLayout;
9
 
10
 
10
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
11
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
118
             }
119
             }
119
         }
120
         }
120
         StyleHelper.updateStyles(mToolbar, getCurrentScreen());
121
         StyleHelper.updateStyles(mToolbar, getCurrentScreen());
122
+
123
+        if (shouldToggleTabs(screen)) {
124
+            toggleTabs(screen.bottomTabsHidden, false);
125
+        }
121
     }
126
     }
122
 
127
 
123
     @Override
128
     @Override
126
         for (ScreenStack stack : mScreenStacks) {
131
         for (ScreenStack stack : mScreenStacks) {
127
             if (stack.peek().navigatorId.equals(navigatorId)) {
132
             if (stack.peek().navigatorId.equals(navigatorId)) {
128
                 Screen popped = stack.pop();
133
                 Screen popped = stack.pop();
129
-                StyleHelper.updateStyles(mToolbar, getCurrentScreen());
134
+                Screen currentScreen = getCurrentScreen();
135
+                StyleHelper.updateStyles(mToolbar, currentScreen);
136
+
137
+                if (shouldToggleTabs(currentScreen)) {
138
+                    toggleTabs(currentScreen.bottomTabsHidden, false);
139
+                }
140
+
130
                 return popped;
141
                 return popped;
131
             }
142
             }
132
         }
143
         }
225
     public void toggleTabs(ReadableMap params) {
236
     public void toggleTabs(ReadableMap params) {
226
         boolean hide = params.getBoolean(KEY_HIDDEN);
237
         boolean hide = params.getBoolean(KEY_HIDDEN);
227
         boolean animated = params.getBoolean(KEY_ANIMATED);
238
         boolean animated = params.getBoolean(KEY_ANIMATED);
239
+        toggleTabs(hide, animated);
240
+    }
241
+
242
+    // TODO: support animated = false -guyca
243
+    private void toggleTabs(boolean hide, boolean animated) {
228
         if (hide) {
244
         if (hide) {
229
-            mBottomNavigation.hideBottomNavigation(animated);
245
+//            mBottomNavigation.hideBottomNavigation(animated);
246
+            mBottomNavigation.setVisibility(View.GONE);
230
         } else {
247
         } else {
231
-            mBottomNavigation.restoreBottomNavigation(animated);
248
+            mBottomNavigation.setVisibility(View.VISIBLE);
249
+//            mBottomNavigation.restoreBottomNavigation(animated);
232
         }
250
         }
233
     }
251
     }
234
 
252
 
253
+    private boolean shouldToggleTabs(Screen newScreen) {
254
+        return mBottomNavigation.isShown() == newScreen.bottomTabsHidden;
255
+    }
256
+
235
     private static class SetupTabsTask extends AsyncTask<Void, Void, Map<Screen, Drawable>> {
257
     private static class SetupTabsTask extends AsyncTask<Void, Void, Map<Screen, Drawable>> {
236
         private BottomTabActivity mActivity;
258
         private BottomTabActivity mActivity;
237
         private RnnToolBar mToolBar;
259
         private RnnToolBar mToolBar;

+ 3
- 0
android/app/src/main/java/com/reactnativenavigation/core/objects/Screen.java View File

43
     private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
43
     private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
44
     private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
44
     private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
45
     private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
45
     private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
46
+    private static final String KEY_BOTTOM_TABS_HIDDEN = "tabBarHidden";
46
     private static final String KEY_PROPS = "passProps";
47
     private static final String KEY_PROPS = "passProps";
47
 
48
 
48
     public String title;
49
     public String title;
66
     @Nullable @ColorInt public Integer tabNormalTextColor;
67
     @Nullable @ColorInt public Integer tabNormalTextColor;
67
     @Nullable @ColorInt public Integer tabSelectedTextColor;
68
     @Nullable @ColorInt public Integer tabSelectedTextColor;
68
     @Nullable @ColorInt public Integer tabIndicatorColor;
69
     @Nullable @ColorInt public Integer tabIndicatorColor;
70
+    public Boolean bottomTabsHidden;
69
 
71
 
70
     @NonNull
72
     @NonNull
71
     public List<Button> getButtons() {
73
     public List<Button> getButtons() {
132
             tabNormalTextColor = getColor(style, KEY_TAB_NORMAL_TEXT_COLOR);
134
             tabNormalTextColor = getColor(style, KEY_TAB_NORMAL_TEXT_COLOR);
133
             tabSelectedTextColor = getColor(style, KEY_TAB_SELECTED_TEXT_COLOR);
135
             tabSelectedTextColor = getColor(style, KEY_TAB_SELECTED_TEXT_COLOR);
134
             tabIndicatorColor = getColor(style, KEY_TAB_INDICATOR_COLOR);
136
             tabIndicatorColor = getColor(style, KEY_TAB_INDICATOR_COLOR);
137
+            bottomTabsHidden = getBoolean(style, KEY_BOTTOM_TABS_HIDDEN);
135
         }
138
         }
136
     }
139
     }
137
 }
140
 }