Browse Source

Apply drawAboveBottomTabs on screen instead of ScreenStack

Guy Carmeli 8 years ago
parent
commit
2edaa046db

+ 1
- 9
android/app/src/main/java/com/reactnativenavigation/layouts/BottomTabsLayout.java View File

54
     }
54
     }
55
 
55
 
56
     private void addScreenStack(ScreenStack newStack) {
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
     private void createBottomTabs() {
60
     private void createBottomTabs() {

+ 8
- 1
android/app/src/main/java/com/reactnativenavigation/screens/ScreenStack.java View File

9
 import com.reactnativenavigation.params.TitleBarButtonParams;
9
 import com.reactnativenavigation.params.TitleBarButtonParams;
10
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
10
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
11
 import com.reactnativenavigation.utils.Task;
11
 import com.reactnativenavigation.utils.Task;
12
+import com.reactnativenavigation.utils.ViewUtils;
12
 import com.reactnativenavigation.views.TitleBarBackButtonListener;
13
 import com.reactnativenavigation.views.TitleBarBackButtonListener;
13
 
14
 
14
 import java.util.List;
15
 import java.util.List;
22
     private final AppCompatActivity activity;
23
     private final AppCompatActivity activity;
23
     private TitleBarBackButtonListener titleBarBackButtonListener;
24
     private TitleBarBackButtonListener titleBarBackButtonListener;
24
     private Stack<Screen> stack = new Stack<>();
25
     private Stack<Screen> stack = new Stack<>();
26
+    private final int bottomTabsHeight;
25
 
27
 
26
     public ScreenStack(AppCompatActivity activity,
28
     public ScreenStack(AppCompatActivity activity,
27
                        ScreenParams initialScreenParams,
29
                        ScreenParams initialScreenParams,
29
         super(activity);
31
         super(activity);
30
         this.activity = activity;
32
         this.activity = activity;
31
         this.titleBarBackButtonListener = titleBarBackButtonListener;
33
         this.titleBarBackButtonListener = titleBarBackButtonListener;
34
+        bottomTabsHeight = (int) ViewUtils.convertDpToPixel(56);
32
         pushInitialScreen(initialScreenParams);
35
         pushInitialScreen(initialScreenParams);
33
     }
36
     }
34
 
37
 
52
 
55
 
53
     private void addScreen(Screen screen) {
56
     private void addScreen(Screen screen) {
54
         screen.setVisibility(INVISIBLE);
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
         stack.push(screen);
63
         stack.push(screen);
57
     }
64
     }
58
 
65
 

+ 9
- 5
android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java View File

32
         }
32
         }
33
     }
33
     }
34
 
34
 
35
-    public void setVisibility(boolean hidden, boolean animated) {
36
-        visibilityAnimator.setVisible(hidden, animated);
37
-    }
38
-
39
     public void setStyleFromScreen(StyleParams params) {
35
     public void setStyleFromScreen(StyleParams params) {
40
         setBackgroundColor(params.bottomTabsColor);
36
         setBackgroundColor(params.bottomTabsColor);
41
 
37
 
49
 
45
 
50
         setForceTitlesDisplay(params.forceTitlesDisplay);
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
     private void setBackgroundColor(StyleParams.Color bottomTabsColor) {
59
     private void setBackgroundColor(StyleParams.Color bottomTabsColor) {