|
@@ -1,13 +1,17 @@
|
1
|
1
|
package com.reactnativenavigation.views;
|
2
|
2
|
|
3
|
3
|
import android.content.Context;
|
|
4
|
+import android.graphics.drawable.Drawable;
|
|
5
|
+import android.support.v7.widget.ActionMenuView;
|
4
|
6
|
import android.support.v7.widget.Toolbar;
|
5
|
7
|
import android.view.Menu;
|
|
8
|
+import android.view.View;
|
6
|
9
|
|
7
|
10
|
import com.reactnativenavigation.animation.VisibilityAnimator;
|
8
|
11
|
import com.reactnativenavigation.params.StyleParams;
|
9
|
12
|
import com.reactnativenavigation.params.TitleBarButtonParams;
|
10
|
13
|
import com.reactnativenavigation.params.TitleBarLeftButtonParams;
|
|
14
|
+import com.reactnativenavigation.utils.ViewUtils;
|
11
|
15
|
|
12
|
16
|
import java.util.List;
|
13
|
17
|
|
|
@@ -16,11 +20,20 @@ public class TitleBar extends Toolbar {
|
16
|
20
|
private boolean hideOnScroll = false;
|
17
|
21
|
private VisibilityAnimator visibilityAnimator;
|
18
|
22
|
private LeftButton leftButton;
|
|
23
|
+ private ActionMenuView actionMenuView;
|
19
|
24
|
|
20
|
25
|
public TitleBar(Context context) {
|
21
|
26
|
super(context);
|
22
|
27
|
}
|
23
|
28
|
|
|
29
|
+ @Override
|
|
30
|
+ public void onViewAdded(View child) {
|
|
31
|
+ super.onViewAdded(child);
|
|
32
|
+ if (child instanceof ActionMenuView) {
|
|
33
|
+ actionMenuView = (ActionMenuView) child;
|
|
34
|
+ }
|
|
35
|
+ }
|
|
36
|
+
|
24
|
37
|
public void setRightButtons(List<TitleBarButtonParams> rightButtons, String navigatorEventId) {
|
25
|
38
|
Menu menu = getMenu();
|
26
|
39
|
menu.clear();
|
|
@@ -44,6 +57,18 @@ public class TitleBar extends Toolbar {
|
44
|
57
|
public void setStyle(StyleParams params) {
|
45
|
58
|
setVisibility(params.titleBarHidden ? GONE : VISIBLE);
|
46
|
59
|
setTitleTextColor(params);
|
|
60
|
+ colorOverflowButton(params);
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ private void colorOverflowButton(StyleParams params) {
|
|
64
|
+ Drawable overflowIcon = actionMenuView.getOverflowIcon();
|
|
65
|
+ if (shouldColorOverflowButton(params, overflowIcon)) {
|
|
66
|
+ ViewUtils.tintDrawable(overflowIcon, params.titleBarButtonColor.getColor(), true);
|
|
67
|
+ }
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ private boolean shouldColorOverflowButton(StyleParams params, Drawable overflowIcon) {
|
|
71
|
+ return overflowIcon != null && params.titleBarButtonColor.hasColor();
|
47
|
72
|
}
|
48
|
73
|
|
49
|
74
|
private void setTitleTextColor(StyleParams params) {
|