소스 검색

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

This reverts commit 326f4833f0.
Guy Carmeli 8 년 전
부모
커밋
bf1fabae7e

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/CollapsingTopBarParams.java 파일 보기

@@ -7,6 +7,7 @@ import com.reactnativenavigation.views.collapsingToolbar.behaviours.CollapseBeha
7 7
 public class CollapsingTopBarParams {
8 8
     public @Nullable String imageUri;
9 9
     public @Nullable String reactViewId;
10
+    public int reactViewHeight;
10 11
     public StyleParams.Color scrimColor;
11 12
     public CollapseBehaviour collapseBehaviour;
12 13
     public boolean expendOnTopTabChange;

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/CollapsingTopBarParamsParser.java 파일 보기

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

+ 2
- 1
android/app/src/main/java/com/reactnativenavigation/views/ContentView.java 파일 보기

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

+ 0
- 22
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/CollapsingReactHeaderMeasurer.java 파일 보기

@@ -1,22 +0,0 @@
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 파일 보기

@@ -78,7 +78,8 @@ public class CollapsingTopBar extends TopBar implements CollapsingView {
78 78
                     params,
79 79
                     new NavigationParams(Bundle.EMPTY),
80 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 83
             header.setOnHiddenListener(new CollapsingTopBarReactHeaderAnimator.OnHiddenListener() {
83 84
                 @Override
84 85
                 public void onHidden() {

+ 6
- 13
android/app/src/main/java/com/reactnativenavigation/views/collapsingToolbar/CollapsingTopBarReactHeader.java 파일 보기

@@ -38,21 +38,14 @@ public class CollapsingTopBarReactHeader extends ContentView implements Collapsi
38 38
         listener = scrollListener;
39 39
         ViewConfiguration vc = ViewConfiguration.get(context);
40 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 51
     public void collapse(float amount) {

+ 1
- 0
src/deprecated/platformSpecificDeprecated.android.js 파일 보기

@@ -128,6 +128,7 @@ function convertStyleParams(originalStyleObject) {
128 128
     topBarCollapseOnScroll: originalStyleObject.topBarCollapseOnScroll,
129 129
     collapsingToolBarImage: originalStyleObject.collapsingToolBarImage,
130 130
     collapsingToolBarComponent: originalStyleObject.collapsingToolBarComponent,
131
+    collapsingToolBarComponentHeight: originalStyleObject.collapsingToolBarComponentHeight,
131 132
     collapsingToolBarCollapsedColor: processColor(originalStyleObject.collapsingToolBarCollapsedColor),
132 133
     expendCollapsingToolBarOnTopTabChange: originalStyleObject.expendCollapsingToolBarOnTopTabChange,
133 134
     titleBarHidden: originalStyleObject.navBarHidden,