|
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
4
|
4
|
import android.content.Context;
|
5
|
5
|
import android.graphics.Typeface;
|
6
|
6
|
import android.support.annotation.ColorInt;
|
|
7
|
+import android.support.annotation.NonNull;
|
7
|
8
|
import android.support.annotation.RestrictTo;
|
8
|
9
|
import android.support.annotation.VisibleForTesting;
|
9
|
10
|
import android.support.design.widget.AppBarLayout;
|
|
@@ -13,6 +14,7 @@ import android.view.Gravity;
|
13
|
14
|
import android.view.View;
|
14
|
15
|
import android.view.ViewGroup;
|
15
|
16
|
import android.widget.FrameLayout;
|
|
17
|
+import android.widget.LinearLayout;
|
16
|
18
|
import android.widget.RelativeLayout;
|
17
|
19
|
import android.widget.TextView;
|
18
|
20
|
|
|
@@ -49,6 +51,7 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
49
|
51
|
private TopBarAnimator animator;
|
50
|
52
|
private TopTabs topTabs;
|
51
|
53
|
private FrameLayout root;
|
|
54
|
+ private LinearLayout content;
|
52
|
55
|
private StackLayout parentView;
|
53
|
56
|
private TopBarBackgroundViewController topBarBackgroundViewController;
|
54
|
57
|
private View border;
|
|
@@ -65,18 +68,37 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
65
|
68
|
|
66
|
69
|
private void createLayout(ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
|
67
|
70
|
setId(CompatUtils.generateViewId());
|
68
|
|
- topTabs = new TopTabs(getContext());
|
69
|
71
|
titleBar = createTitleBar(getContext(), buttonCreator, titleBarReactViewCreator, onClickListener);
|
70
|
|
- titleBar.setId(CompatUtils.generateViewId());
|
|
72
|
+ topTabs = createTopTabs();
|
|
73
|
+ border = createBorder();
|
|
74
|
+ content = createContentLayout();
|
|
75
|
+
|
71
|
76
|
root = new FrameLayout(getContext());
|
72
|
77
|
root.setId(CompatUtils.generateViewId());
|
73
|
|
- root.addView(titleBar, MATCH_PARENT, WRAP_CONTENT);
|
74
|
|
- border = createBorder();
|
|
78
|
+ content.addView(titleBar);
|
|
79
|
+ content.addView(topTabs);
|
|
80
|
+ root.addView(content);
|
75
|
81
|
root.addView(border);
|
76
|
82
|
addView(root, MATCH_PARENT, WRAP_CONTENT);
|
77
|
83
|
if (BuildConfig.DEBUG) setContentDescription("TopBar");
|
78
|
84
|
}
|
79
|
85
|
|
|
86
|
+ private LinearLayout createContentLayout() {
|
|
87
|
+ LinearLayout content = new LinearLayout(getContext());
|
|
88
|
+ content.setOrientation(VERTICAL);
|
|
89
|
+ return content;
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+ @NonNull
|
|
93
|
+ private TopTabs createTopTabs() {
|
|
94
|
+ RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
|
|
95
|
+ lp.addRule(RelativeLayout.BELOW, titleBar.getId());
|
|
96
|
+ TopTabs topTabs = new TopTabs(getContext());
|
|
97
|
+ topTabs.setLayoutParams(lp);
|
|
98
|
+ topTabs.setVisibility(GONE);
|
|
99
|
+ return topTabs;
|
|
100
|
+ }
|
|
101
|
+
|
80
|
102
|
private View createBorder() {
|
81
|
103
|
View border = new View(getContext());
|
82
|
104
|
border.setBackgroundColor(android.graphics.Color.TRANSPARENT);
|
|
@@ -87,7 +109,9 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
87
|
109
|
}
|
88
|
110
|
|
89
|
111
|
protected TitleBar createTitleBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator reactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
|
90
|
|
- return new TitleBar(context, buttonCreator, reactViewCreator, onClickListener);
|
|
112
|
+ TitleBar titleBar = new TitleBar(context, buttonCreator, reactViewCreator, onClickListener);
|
|
113
|
+ titleBar.setId(CompatUtils.generateViewId());
|
|
114
|
+ return titleBar;
|
91
|
115
|
}
|
92
|
116
|
|
93
|
117
|
public void setHeight(int height) {
|
|
@@ -177,6 +201,12 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
177
|
201
|
topTabs.setVisibility(this, visible);
|
178
|
202
|
}
|
179
|
203
|
|
|
204
|
+ public void setTopTabsHeight(int height) {
|
|
205
|
+ if (topTabs.getLayoutParams().height == height) return;
|
|
206
|
+ topTabs.getLayoutParams().height = height > 0 ? (int) UiUtils.dpToPx(getContext(), height) : height;
|
|
207
|
+ topTabs.setLayoutParams(topTabs.getLayoutParams());
|
|
208
|
+ }
|
|
209
|
+
|
180
|
210
|
public void setLeftButtons(List<Button> leftButtons) {
|
181
|
211
|
titleBar.setLeftButtons(leftButtons);
|
182
|
212
|
}
|
|
@@ -194,11 +224,8 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
194
|
224
|
}
|
195
|
225
|
|
196
|
226
|
public void initTopTabs(ViewPager viewPager) {
|
197
|
|
- topTabs = new TopTabs(getContext());
|
|
227
|
+ topTabs.setVisibility(VISIBLE);
|
198
|
228
|
topTabs.init(viewPager);
|
199
|
|
- RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT);
|
200
|
|
- lp.addRule(RelativeLayout.BELOW, titleBar.getId());
|
201
|
|
- root.addView(topTabs, lp);
|
202
|
229
|
}
|
203
|
230
|
|
204
|
231
|
public void enableCollapse(ScrollEventListener scrollEventListener) {
|