Browse Source

Save titleBarHidden in screenParams when toggling TitleBar (#840)

* Save titleBarHidden in screenParams when toggling TitleBar

* empty commit
Guy Carmeli 7 years ago
parent
commit
3f7f42367d

+ 0
- 36
android/app/src/main/java/com/reactnativenavigation/animation/VisibilityAnimator.java View File

@@ -6,8 +6,6 @@ import android.animation.ObjectAnimator;
6 6
 import android.support.v4.view.animation.LinearOutSlowInInterpolator;
7 7
 import android.view.View;
8 8
 
9
-import com.reactnativenavigation.views.ScrollDirectionListener;
10
-
11 9
 public class VisibilityAnimator {
12 10
 
13 11
     public enum HideDirection {
@@ -22,24 +20,14 @@ public class VisibilityAnimator {
22 20
     private static final int DURATION = 300;
23 21
 
24 22
     private final View view;
25
-    private final HideDirection hideDirection;
26 23
     private final int hiddenEndValue;
27 24
     private VisibilityState visibilityState = VisibilityState.Shown;
28 25
 
29 26
     public VisibilityAnimator(View view, HideDirection hideDirection, int height) {
30 27
         this.view = view;
31
-        this.hideDirection = hideDirection;
32 28
         this.hiddenEndValue = hideDirection == HideDirection.Up ? -height : height;
33 29
     }
34 30
 
35
-    public void onScrollChanged(ScrollDirectionListener.Direction scrollDirection) {
36
-        if (hideDirection == HideDirection.Down) {
37
-            handleDownHidingViews(scrollDirection);
38
-        } else {
39
-            handleUpHidingViews(scrollDirection);
40
-        }
41
-    }
42
-
43 31
     public void setVisible(boolean visible, boolean animate) {
44 32
         if (visible && isHiding()) {
45 33
             show(animate);
@@ -48,22 +36,6 @@ public class VisibilityAnimator {
48 36
         }
49 37
     }
50 38
 
51
-    private void handleUpHidingViews(ScrollDirectionListener.Direction scrollDirection) {
52
-        if (scrollUp(scrollDirection) && !isShowing()) {
53
-            show(true);
54
-        } else if (scrollDown(scrollDirection) && !isHiding()) {
55
-            hide(true);
56
-        }
57
-    }
58
-
59
-    private void handleDownHidingViews(ScrollDirectionListener.Direction scrollDirection) {
60
-        if (scrollDown(scrollDirection) && !isHiding()) {
61
-            hide(true);
62
-        } else if (scrollUp(scrollDirection) && !isShowing()) {
63
-            show(true);
64
-        }
65
-    }
66
-
67 39
     private void show(boolean animate) {
68 40
         if (animate) {
69 41
             ObjectAnimator animator = createAnimator(true);
@@ -84,14 +56,6 @@ public class VisibilityAnimator {
84 56
         }
85 57
     }
86 58
 
87
-    private boolean scrollUp(ScrollDirectionListener.Direction scrollDirection) {
88
-        return scrollDirection == ScrollDirectionListener.Direction.Up;
89
-    }
90
-
91
-    private boolean scrollDown(ScrollDirectionListener.Direction scrollDirection) {
92
-        return scrollDirection == ScrollDirectionListener.Direction.Down;
93
-    }
94
-
95 59
     private boolean isShowing() {
96 60
         return visibilityState == VisibilityState.Shown || visibilityState == VisibilityState.AnimateShow;
97 61
     }

+ 0
- 1
android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java View File

@@ -50,7 +50,6 @@ public class StyleParams {
50 50
     public Color topBarColor;
51 51
     public CollapsingTopBarParams collapsingTopBarParams;
52 52
     public boolean topBarCollapseOnScroll;
53
-    public boolean topBarHidden;
54 53
     public boolean topBarElevationShadowEnabled;
55 54
     public boolean topTabsHidden;
56 55
     public boolean drawScreenBelowTopBar;

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/screens/Screen.java View File

@@ -171,6 +171,7 @@ public abstract class Screen extends RelativeLayout implements Subscriber {
171 171
     }
172 172
 
173 173
     public void setTopBarVisible(boolean visible, boolean animate) {
174
+        screenParams.styleParams.titleBarHidden = !visible;
174 175
         topBarVisibilityAnimator.setVisible(visible, animate);
175 176
     }
176 177
 

+ 0
- 1
android/app/src/main/java/com/reactnativenavigation/views/TopBar.java View File

@@ -73,7 +73,6 @@ public class TopBar extends AppBarLayout {
73 73
         if (styleParams.topBarTransparent) {
74 74
             setTransparent();
75 75
         }
76
-        setVisibility(styleParams.topBarHidden ? GONE : VISIBLE);
77 76
         titleBar.setStyle(styleParams);
78 77
         setTopTabsStyle(styleParams);
79 78
         if (!styleParams.topBarElevationShadowEnabled) {

+ 1
- 1
src/deprecated/platformSpecificDeprecated.android.js View File

@@ -358,7 +358,7 @@ function navigatorToggleDrawer(navigator, params) {
358 358
 
359 359
 function navigatorToggleNavBar(navigator, params) {
360 360
   const screenInstanceID = navigator.screenInstanceID;
361
-  const visible = params.to === 'shown';
361
+  const visible = params.to === 'shown' || params.to === 'show';
362 362
   const animated = !(params.animated === false);
363 363
 
364 364
   newPlatformSpecific.toggleTopBarVisible(