Browse Source

Revert "Dynamic height for CollapsingReactHeader (#726)" (#728)

This reverts commit 326f4833f0.
Guy Carmeli 8 years ago
parent
commit
bf1fabae7e

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

7
 public class CollapsingTopBarParams {
7
 public class CollapsingTopBarParams {
8
     public @Nullable String imageUri;
8
     public @Nullable String imageUri;
9
     public @Nullable String reactViewId;
9
     public @Nullable String reactViewId;
10
+    public int reactViewHeight;
10
     public StyleParams.Color scrimColor;
11
     public StyleParams.Color scrimColor;
11
     public CollapseBehaviour collapseBehaviour;
12
     public CollapseBehaviour collapseBehaviour;
12
     public boolean expendOnTopTabChange;
13
     public boolean expendOnTopTabChange;

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

32
         CollapsingTopBarParams result = new CollapsingTopBarParams();
32
         CollapsingTopBarParams result = new CollapsingTopBarParams();
33
         result.imageUri = params.getString("collapsingToolBarImage", null);
33
         result.imageUri = params.getString("collapsingToolBarImage", null);
34
         result.reactViewId = params.getString("collapsingToolBarComponent", null);
34
         result.reactViewId = params.getString("collapsingToolBarComponent", null);
35
+        result.reactViewHeight = params.getInt("collapsingToolBarComponentHeight");
35
         result.expendOnTopTabChange = params.getBoolean("expendCollapsingToolBarOnTopTabChange");
36
         result.expendOnTopTabChange = params.getBoolean("expendCollapsingToolBarOnTopTabChange");
36
         result.scrimColor = getColor(params, "collapsingToolBarCollapsedColor", new StyleParams.Color(Color.WHITE));
37
         result.scrimColor = getColor(params, "collapsingToolBarCollapsedColor", new StyleParams.Color(Color.WHITE));
37
         result.showTitleWhenCollapsed = hasReactView;
38
         result.showTitleWhenCollapsed = hasReactView;

+ 2
- 1
android/app/src/main/java/com/reactnativenavigation/views/ContentView.java View File

50
     @Override
50
     @Override
51
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
51
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
52
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
52
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
53
+        int measuredHeight = viewMeasurer.getMeasuredHeight(heightMeasureSpec);
53
         setMeasuredDimension(viewMeasurer.getMeasuredWidth(widthMeasureSpec),
54
         setMeasuredDimension(viewMeasurer.getMeasuredWidth(widthMeasureSpec),
54
-                viewMeasurer.getMeasuredHeight(heightMeasureSpec));
55
+                measuredHeight);
55
     }
56
     }
56
 
57
 
57
     @Override
58
     @Override

+ 0
- 22
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/CollapsingReactHeaderMeasurer.java View File

1
-package com.reactnativenavigation.views.collapsingToolbar;
2
-
3
-import android.view.ViewGroup;
4
-
5
-import com.reactnativenavigation.views.utils.ViewMeasurer;
6
-
7
-class CollapsingReactHeaderMeasurer extends ViewMeasurer {
8
-    private ViewGroup header;
9
-
10
-    CollapsingReactHeaderMeasurer(ViewGroup header) {
11
-        this.header = header;
12
-    }
13
-
14
-    @Override
15
-    public int getMeasuredHeight(int heightMeasureSpec) {
16
-        return hasChildren() ? header.getChildAt(0).getMeasuredHeight() : super.getMeasuredHeight(heightMeasureSpec);
17
-    }
18
-
19
-    private boolean hasChildren() {
20
-        return header.getChildCount() > 0;
21
-    }
22
-}

+ 2
- 1
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/CollapsingTopBar.java View File

78
                     params,
78
                     params,
79
                     new NavigationParams(Bundle.EMPTY),
79
                     new NavigationParams(Bundle.EMPTY),
80
                     scrollListener);
80
                     scrollListener);
81
-            titleBarAndContextualMenuContainer.addView(header, new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
81
+            LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, (int) ViewUtils.convertDpToPixel(params.reactViewHeight));
82
+            titleBarAndContextualMenuContainer.addView(header, lp);
82
             header.setOnHiddenListener(new CollapsingTopBarReactHeaderAnimator.OnHiddenListener() {
83
             header.setOnHiddenListener(new CollapsingTopBarReactHeaderAnimator.OnHiddenListener() {
83
                 @Override
84
                 @Override
84
                 public void onHidden() {
85
                 public void onHidden() {

+ 6
- 13
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/CollapsingTopBarReactHeader.java View File

38
         listener = scrollListener;
38
         listener = scrollListener;
39
         ViewConfiguration vc = ViewConfiguration.get(context);
39
         ViewConfiguration vc = ViewConfiguration.get(context);
40
         mTouchSlop = vc.getScaledTouchSlop();
40
         mTouchSlop = vc.getScaledTouchSlop();
41
-        setViewMeasurer(new CollapsingReactHeaderMeasurer(this));
42
-        createVisibilityAnimator(getHeight());
41
+        createVisibilityAnimator(params.reactViewHeight);
43
     }
42
     }
44
 
43
 
45
-    private void createVisibilityAnimator(final int reactViewHeight) {
46
-        ViewUtils.runOnPreDraw(this, new Runnable() {
47
-            @Override
48
-            public void run() {
49
-                final CollapsingTopBarReactHeader header = CollapsingTopBarReactHeader.this;
50
-                float height = ViewUtils.convertDpToPixel(reactViewHeight);
51
-                visibilityAnimator = new CollapsingTopBarReactHeaderAnimator(header, height * 0.6f, height * 0.60f);
52
-                visibilityAnimator.setOnHiddenListener(header);
53
-                visibilityAnimator.setOnVisibleListener(header);
54
-            }
55
-        });
44
+    private void createVisibilityAnimator(int reactViewHeight) {
45
+        float height = ViewUtils.convertDpToPixel(reactViewHeight);
46
+        visibilityAnimator = new CollapsingTopBarReactHeaderAnimator(this, height * 0.6f, height * 0.60f);
47
+        visibilityAnimator.setOnHiddenListener(this);
48
+        visibilityAnimator.setOnVisibleListener(this);
56
     }
49
     }
57
 
50
 
58
     public void collapse(float amount) {
51
     public void collapse(float amount) {

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

128
     topBarCollapseOnScroll: originalStyleObject.topBarCollapseOnScroll,
128
     topBarCollapseOnScroll: originalStyleObject.topBarCollapseOnScroll,
129
     collapsingToolBarImage: originalStyleObject.collapsingToolBarImage,
129
     collapsingToolBarImage: originalStyleObject.collapsingToolBarImage,
130
     collapsingToolBarComponent: originalStyleObject.collapsingToolBarComponent,
130
     collapsingToolBarComponent: originalStyleObject.collapsingToolBarComponent,
131
+    collapsingToolBarComponentHeight: originalStyleObject.collapsingToolBarComponentHeight,
131
     collapsingToolBarCollapsedColor: processColor(originalStyleObject.collapsingToolBarCollapsedColor),
132
     collapsingToolBarCollapsedColor: processColor(originalStyleObject.collapsingToolBarCollapsedColor),
132
     expendCollapsingToolBarOnTopTabChange: originalStyleObject.expendCollapsingToolBarOnTopTabChange,
133
     expendCollapsingToolBarOnTopTabChange: originalStyleObject.expendCollapsingToolBarOnTopTabChange,
133
     titleBarHidden: originalStyleObject.navBarHidden,
134
     titleBarHidden: originalStyleObject.navBarHidden,