|
@@ -9,6 +9,7 @@ import android.widget.ScrollView;
|
9
|
9
|
|
10
|
10
|
import com.reactnativenavigation.params.CollapsingTopBarParams;
|
11
|
11
|
import com.reactnativenavigation.params.NavigationParams;
|
|
12
|
+import com.reactnativenavigation.params.StyleParams;
|
12
|
13
|
import com.reactnativenavigation.utils.ViewUtils;
|
13
|
14
|
import com.reactnativenavigation.views.TitleBar;
|
14
|
15
|
import com.reactnativenavigation.views.TopBar;
|
|
@@ -21,26 +22,31 @@ public class CollapsingTopBar extends TopBar implements CollapsingView {
|
21
|
22
|
private CollapsingTopBarReactHeader header;
|
22
|
23
|
private ScrollListener scrollListener;
|
23
|
24
|
private float finalCollapsedTranslation;
|
24
|
|
- private CollapsingTopBarParams params;
|
|
25
|
+ private final StyleParams styleParams;
|
|
26
|
+ private final CollapsingTopBarParams params;
|
25
|
27
|
private final ViewCollapser viewCollapser;
|
26
|
28
|
private final int topBarHeight;
|
27
|
29
|
private String title;
|
28
|
30
|
|
29
|
|
- public CollapsingTopBar(Context context, final CollapsingTopBarParams params) {
|
|
31
|
+ public CollapsingTopBar(Context context, final StyleParams params) {
|
30
|
32
|
super(context);
|
31
|
|
- this.params = params;
|
|
33
|
+ styleParams = params;
|
|
34
|
+ this.params = params.collapsingTopBarParams;
|
32
|
35
|
topBarHeight = calculateTopBarHeight();
|
33
|
|
- createBackgroundImage(params);
|
34
|
|
- calculateFinalCollapsedTranslation(params);
|
|
36
|
+ createBackgroundImage();
|
|
37
|
+ calculateFinalCollapsedTranslation();
|
35
|
38
|
viewCollapser = new ViewCollapser(this);
|
36
|
39
|
}
|
37
|
40
|
|
38
|
|
- private void calculateFinalCollapsedTranslation(final CollapsingTopBarParams params) {
|
|
41
|
+ private void calculateFinalCollapsedTranslation() {
|
39
|
42
|
ViewUtils.runOnPreDraw(this, new Runnable() {
|
40
|
43
|
@Override
|
41
|
44
|
public void run() {
|
42
|
45
|
if (params.hasBackgroundImage() || params.hasReactView()) {
|
43
|
46
|
finalCollapsedTranslation = getCollapsedHeight() - getHeight();
|
|
47
|
+ if (styleParams.topBarCollapseOnScroll) {
|
|
48
|
+ finalCollapsedTranslation += titleBar.getHeight();
|
|
49
|
+ }
|
44
|
50
|
} else {
|
45
|
51
|
finalCollapsedTranslation = -titleBar.getHeight();
|
46
|
52
|
}
|
|
@@ -61,7 +67,7 @@ public class CollapsingTopBar extends TopBar implements CollapsingView {
|
61
|
67
|
}
|
62
|
68
|
}
|
63
|
69
|
|
64
|
|
- private void createBackgroundImage(CollapsingTopBarParams params) {
|
|
70
|
+ private void createBackgroundImage() {
|
65
|
71
|
if (params.hasBackgroundImage()) {
|
66
|
72
|
collapsingTopBarBackground = new CollapsingTopBarBackground(getContext(), params);
|
67
|
73
|
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, (int) CollapsingTopBarBackground.MAX_HEIGHT);
|