Просмотр исходного кода

Apply drawAboveBottomTabs on screen instead of ScreenStack

Guy Carmeli 8 лет назад
Родитель
Сommit
2edaa046db

+ 1
- 9
android/app/src/main/java/com/reactnativenavigation/layouts/BottomTabsLayout.java Просмотреть файл

@@ -54,15 +54,7 @@ public class BottomTabsLayout extends RelativeLayout implements Layout, AHBottom
54 54
     }
55 55
 
56 56
     private void addScreenStack(ScreenStack newStack) {
57
-        LayoutParams lp = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
58
-        if (shouldDrawScreenStackAboveBottomTabs(newStack)) {
59
-            lp.addRule(ABOVE, bottomTabs.getId());
60
-        }
61
-        addView(newStack, 0, lp);
62
-    }
63
-
64
-    private boolean shouldDrawScreenStackAboveBottomTabs(ScreenStack newStack) {
65
-        return newStack.getCurrentScreenStyleParams().drawScreenAboveBottomTabs;
57
+        addView(newStack, 0, new LayoutParams(MATCH_PARENT, MATCH_PARENT));
66 58
     }
67 59
 
68 60
     private void createBottomTabs() {

+ 8
- 1
android/app/src/main/java/com/reactnativenavigation/screens/ScreenStack.java Просмотреть файл

@@ -9,6 +9,7 @@ import com.reactnativenavigation.params.StyleParams;
9 9
 import com.reactnativenavigation.params.TitleBarButtonParams;
10 10
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
11 11
 import com.reactnativenavigation.utils.Task;
12
+import com.reactnativenavigation.utils.ViewUtils;
12 13
 import com.reactnativenavigation.views.TitleBarBackButtonListener;
13 14
 
14 15
 import java.util.List;
@@ -22,6 +23,7 @@ public class ScreenStack extends FrameLayout {
22 23
     private final AppCompatActivity activity;
23 24
     private TitleBarBackButtonListener titleBarBackButtonListener;
24 25
     private Stack<Screen> stack = new Stack<>();
26
+    private final int bottomTabsHeight;
25 27
 
26 28
     public ScreenStack(AppCompatActivity activity,
27 29
                        ScreenParams initialScreenParams,
@@ -29,6 +31,7 @@ public class ScreenStack extends FrameLayout {
29 31
         super(activity);
30 32
         this.activity = activity;
31 33
         this.titleBarBackButtonListener = titleBarBackButtonListener;
34
+        bottomTabsHeight = (int) ViewUtils.convertDpToPixel(56);
32 35
         pushInitialScreen(initialScreenParams);
33 36
     }
34 37
 
@@ -52,7 +55,11 @@ public class ScreenStack extends FrameLayout {
52 55
 
53 56
     private void addScreen(Screen screen) {
54 57
         screen.setVisibility(INVISIBLE);
55
-        addView(screen, new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
58
+        LayoutParams params = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
59
+        if (screen.screenParams.styleParams.drawScreenAboveBottomTabs) {
60
+            params.setMargins(0, 0, 0, bottomTabsHeight);
61
+        }
62
+        addView(screen, params);
56 63
         stack.push(screen);
57 64
     }
58 65
 

+ 9
- 5
android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java Просмотреть файл

@@ -32,10 +32,6 @@ public class BottomTabs extends AHBottomNavigation {
32 32
         }
33 33
     }
34 34
 
35
-    public void setVisibility(boolean hidden, boolean animated) {
36
-        visibilityAnimator.setVisible(hidden, animated);
37
-    }
38
-
39 35
     public void setStyleFromScreen(StyleParams params) {
40 36
         setBackgroundColor(params.bottomTabsColor);
41 37
 
@@ -49,7 +45,15 @@ public class BottomTabs extends AHBottomNavigation {
49 45
 
50 46
         setForceTitlesDisplay(params.forceTitlesDisplay);
51 47
 
52
-        setVisibility(params.bottomTabsHidden);
48
+        setVisibility(params.bottomTabsHidden, true);
49
+    }
50
+
51
+    public void setVisibility(boolean hidden, boolean animated) {
52
+        if (visibilityAnimator != null) {
53
+            visibilityAnimator.setVisible(!hidden, animated);
54
+        } else {
55
+            setVisibility(hidden);
56
+        }
53 57
     }
54 58
 
55 59
     private void setBackgroundColor(StyleParams.Color bottomTabsColor) {