|
@@ -9,11 +9,14 @@ import android.support.annotation.VisibleForTesting;
|
9
|
9
|
import android.support.design.widget.AppBarLayout;
|
10
|
10
|
import android.support.v4.view.ViewPager;
|
11
|
11
|
import android.support.v7.widget.Toolbar;
|
|
12
|
+import android.view.Gravity;
|
12
|
13
|
import android.view.View;
|
13
|
14
|
import android.view.ViewGroup;
|
|
15
|
+import android.widget.FrameLayout;
|
14
|
16
|
import android.widget.RelativeLayout;
|
15
|
17
|
import android.widget.TextView;
|
16
|
18
|
|
|
19
|
+import com.reactnativenavigation.BuildConfig;
|
17
|
20
|
import com.reactnativenavigation.anim.TopBarAnimator;
|
18
|
21
|
import com.reactnativenavigation.anim.TopBarCollapseBehavior;
|
19
|
22
|
import com.reactnativenavigation.interfaces.ScrollEventListener;
|
|
@@ -45,9 +48,10 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
45
|
48
|
private final TopBarCollapseBehavior collapsingBehavior;
|
46
|
49
|
private TopBarAnimator animator;
|
47
|
50
|
private TopTabs topTabs;
|
48
|
|
- private RelativeLayout root;
|
|
51
|
+ private FrameLayout root;
|
49
|
52
|
private StackLayout parentView;
|
50
|
53
|
private TopBarBackgroundViewController topBarBackgroundViewController;
|
|
54
|
+ private View border;
|
51
|
55
|
|
52
|
56
|
public TopBar(final Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarBackgroundViewController topBarBackgroundViewController, TopBarButtonController.OnClickListener onClickListener, StackLayout parentView) {
|
53
|
57
|
super(context);
|
|
@@ -60,13 +64,26 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
60
|
64
|
}
|
61
|
65
|
|
62
|
66
|
private void createLayout(ReactViewCreator buttonCreator, TitleBarReactViewCreator titleBarReactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
|
|
67
|
+ setId(CompatUtils.generateViewId());
|
63
|
68
|
topTabs = new TopTabs(getContext());
|
64
|
69
|
titleBar = createTitleBar(getContext(), buttonCreator, titleBarReactViewCreator, onClickListener);
|
65
|
70
|
titleBar.setId(CompatUtils.generateViewId());
|
66
|
|
- root = new RelativeLayout(getContext());
|
|
71
|
+ root = new FrameLayout(getContext());
|
|
72
|
+ root.setId(CompatUtils.generateViewId());
|
67
|
73
|
root.addView(titleBar, MATCH_PARENT, WRAP_CONTENT);
|
|
74
|
+ border = createBorder();
|
|
75
|
+ root.addView(border);
|
68
|
76
|
addView(root, MATCH_PARENT, WRAP_CONTENT);
|
69
|
|
- setContentDescription("TopBar");
|
|
77
|
+ if (BuildConfig.DEBUG) setContentDescription("TopBar");
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ private View createBorder() {
|
|
81
|
+ View border = new View(getContext());
|
|
82
|
+ border.setBackgroundColor(android.graphics.Color.TRANSPARENT);
|
|
83
|
+ FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT, 0);
|
|
84
|
+ lp.gravity = Gravity.BOTTOM;
|
|
85
|
+ border.setLayoutParams(lp);
|
|
86
|
+ return border;
|
70
|
87
|
}
|
71
|
88
|
|
72
|
89
|
protected TitleBar createTitleBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator reactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
|
|
@@ -104,7 +121,7 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
104
|
121
|
titleBar.setSubtitleTypeface(fontFamily);
|
105
|
122
|
}
|
106
|
123
|
|
107
|
|
- public void setSubtitleFontSize(float size) {
|
|
124
|
+ public void setSubtitleFontSize(double size) {
|
108
|
125
|
titleBar.setSubtitleFontSize(size);
|
109
|
126
|
}
|
110
|
127
|
|
|
@@ -120,7 +137,7 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
120
|
137
|
titleBar.setTitleTextColor(color);
|
121
|
138
|
}
|
122
|
139
|
|
123
|
|
- public void setTitleFontSize(float size) {
|
|
140
|
+ public void setTitleFontSize(double size) {
|
124
|
141
|
titleBar.setTitleFontSize(size);
|
125
|
142
|
}
|
126
|
143
|
|
|
@@ -266,4 +283,12 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
266
|
283
|
setRotationY(0);
|
267
|
284
|
setRotation(0);
|
268
|
285
|
}
|
|
286
|
+
|
|
287
|
+ public void setBorderHeight(double height) {
|
|
288
|
+ border.getLayoutParams().height = (int) UiUtils.dpToPx(getContext(), (float) height);
|
|
289
|
+ }
|
|
290
|
+
|
|
291
|
+ public void setBorderColor(int color) {
|
|
292
|
+ border.setBackgroundColor(color);
|
|
293
|
+ }
|
269
|
294
|
}
|