|
@@ -14,6 +14,7 @@ import com.reactnativenavigation.params.ScreenParams;
|
14
|
14
|
import com.reactnativenavigation.views.CollapsingContentView;
|
15
|
15
|
import com.reactnativenavigation.views.ContentView;
|
16
|
16
|
import com.reactnativenavigation.views.LeftButtonOnClickListener;
|
|
17
|
+import com.reactnativenavigation.views.TopBar;
|
17
|
18
|
import com.reactnativenavigation.views.collapsingToolbar.CollapseAmount;
|
18
|
19
|
import com.reactnativenavigation.views.collapsingToolbar.CollapseCalculator;
|
19
|
20
|
import com.reactnativenavigation.views.collapsingToolbar.CollapsingTopBar;
|
|
@@ -33,10 +34,10 @@ public class CollapsingViewPagerScreen extends ViewPagerScreen {
|
33
|
34
|
}
|
34
|
35
|
|
35
|
36
|
@Override
|
36
|
|
- protected void createTopBar() {
|
|
37
|
+ protected TopBar createTopBar() {
|
37
|
38
|
final CollapsingTopBar topBar = new CollapsingTopBar(getContext(), styleParams.collapsingTopBarParams);
|
38
|
|
- topBar.setScrollListener(getScrollListener());
|
39
|
|
- this.topBar = topBar;
|
|
39
|
+ topBar.setScrollListener(getScrollListener(topBar));
|
|
40
|
+ return topBar;
|
40
|
41
|
}
|
41
|
42
|
|
42
|
43
|
@Override
|
|
@@ -49,18 +50,15 @@ public class CollapsingViewPagerScreen extends ViewPagerScreen {
|
49
|
50
|
}
|
50
|
51
|
|
51
|
52
|
protected ContentView createContentView(PageParams tab) {
|
52
|
|
- if (tab.hasCollapsingTopBar()) {
|
53
|
|
- CollapsingContentView contentView = new CollapsingContentView(getContext(), tab.screenId, tab.navigationParams);
|
54
|
|
- contentView.setViewMeasurer(new CollapsingViewPagerContentViewMeasurer((CollapsingTopBar) topBar, this, screenParams.styleParams));
|
55
|
|
- setupCollapseDetection(contentView);
|
56
|
|
- return contentView;
|
57
|
|
- } else {
|
58
|
|
- return new ContentView(getContext(), tab.screenId, tab.navigationParams);
|
59
|
|
- }
|
|
53
|
+ CollapsingContentView contentView = new CollapsingContentView(getContext(), tab.screenId, tab.navigationParams);
|
|
54
|
+ contentView.setViewMeasurer(new CollapsingViewPagerContentViewMeasurer((CollapsingTopBar) topBar, this, screenParams.styleParams));
|
|
55
|
+ setupCollapseDetection(contentView);
|
|
56
|
+ return contentView;
|
60
|
57
|
}
|
61
|
58
|
|
62
|
59
|
private void setupCollapseDetection(CollapsingContentView contentView) {
|
63
|
|
- contentView.setupCollapseDetection(getScrollListener(), new OnScrollViewAddedListener() {
|
|
60
|
+ ScrollListener scrollListener = getScrollListener((CollapsingView) topBar);
|
|
61
|
+ contentView.setupCollapseDetection(scrollListener, new OnScrollViewAddedListener() {
|
64
|
62
|
@Override
|
65
|
63
|
public void onScrollViewAdded(ScrollView scrollView) {
|
66
|
64
|
((CollapsingTopBar) topBar).onScrollViewAdded(scrollView);
|
|
@@ -68,18 +66,18 @@ public class CollapsingViewPagerScreen extends ViewPagerScreen {
|
68
|
66
|
});
|
69
|
67
|
}
|
70
|
68
|
|
71
|
|
- private ScrollListener getScrollListener() {
|
72
|
|
- return new ScrollListener(new CollapseCalculator((CollapsingView) topBar, getCollapseBehaviour()),
|
|
69
|
+ private ScrollListener getScrollListener(final CollapsingView topBar) {
|
|
70
|
+ return new ScrollListener(new CollapseCalculator(topBar, getCollapseBehaviour()),
|
73
|
71
|
new OnScrollListener() {
|
74
|
72
|
@Override
|
75
|
73
|
public void onScroll(CollapseAmount amount) {
|
76
|
|
- ((CollapsingView) topBar).collapse(amount);
|
|
74
|
+ topBar.collapse(amount);
|
77
|
75
|
((CollapsingView) viewPager).collapse(amount);
|
78
|
76
|
}
|
79
|
77
|
|
80
|
78
|
@Override
|
81
|
79
|
public void onFling(CollapseAmount amount) {
|
82
|
|
- ((CollapsingView) topBar).collapse(amount);
|
|
80
|
+ topBar.collapse(amount);
|
83
|
81
|
((CollapsingView) viewPager).collapse(amount);
|
84
|
82
|
}
|
85
|
83
|
},
|
|
@@ -111,4 +109,8 @@ public class CollapsingViewPagerScreen extends ViewPagerScreen {
|
111
|
109
|
}
|
112
|
110
|
}
|
113
|
111
|
}
|
|
112
|
+
|
|
113
|
+ protected ContentView getCurrentPage() {
|
|
114
|
+ return (ContentView) viewPager.getChildAt(viewPager.getCurrentItem());
|
|
115
|
+ }
|
114
|
116
|
}
|