|
@@ -2,6 +2,7 @@ package com.reactnativenavigation.views;
|
2
|
2
|
|
3
|
3
|
import android.support.annotation.NonNull;
|
4
|
4
|
import android.support.annotation.Nullable;
|
|
5
|
+import android.text.SpannableStringBuilder;
|
5
|
6
|
import android.view.Menu;
|
6
|
7
|
import android.view.MenuItem;
|
7
|
8
|
import android.view.View;
|
|
@@ -9,6 +10,7 @@ import android.widget.TextView;
|
9
|
10
|
|
10
|
11
|
import com.reactnativenavigation.NavigationApplication;
|
11
|
12
|
import com.reactnativenavigation.params.TitleBarButtonParams;
|
|
13
|
+import com.reactnativenavigation.utils.TypefaceSpan;
|
12
|
14
|
import com.reactnativenavigation.utils.ViewUtils;
|
13
|
15
|
|
14
|
16
|
import java.util.ArrayList;
|
|
@@ -28,7 +30,7 @@ class TitleBarButton implements MenuItem.OnMenuItemClickListener {
|
28
|
30
|
}
|
29
|
31
|
|
30
|
32
|
MenuItem addToMenu(int index) {
|
31
|
|
- MenuItem item = menu.add(Menu.NONE, Menu.NONE, index, buttonParams.label);
|
|
33
|
+ MenuItem item = createMenuItem(index);
|
32
|
34
|
item.setShowAsAction(buttonParams.showAsAction.action);
|
33
|
35
|
item.setEnabled(buttonParams.enabled);
|
34
|
36
|
setIcon(item);
|
|
@@ -38,6 +40,16 @@ class TitleBarButton implements MenuItem.OnMenuItemClickListener {
|
38
|
40
|
return item;
|
39
|
41
|
}
|
40
|
42
|
|
|
43
|
+ private MenuItem createMenuItem(int index) {
|
|
44
|
+ if (!buttonParams.font.hasFont()) {
|
|
45
|
+ return menu.add(Menu.NONE, Menu.NONE, index, buttonParams.label);
|
|
46
|
+ }
|
|
47
|
+ TypefaceSpan span = new TypefaceSpan(buttonParams.font.get());
|
|
48
|
+ SpannableStringBuilder title = new SpannableStringBuilder(buttonParams.label);
|
|
49
|
+ title.setSpan(span, 0, title.length(), 0);
|
|
50
|
+ return menu.add(Menu.NONE, Menu.NONE, index, title);
|
|
51
|
+ }
|
|
52
|
+
|
41
|
53
|
private void setIcon(MenuItem item) {
|
42
|
54
|
if (hasIcon()) {
|
43
|
55
|
item.setIcon(buttonParams.icon);
|
|
@@ -71,7 +83,7 @@ class TitleBarButton implements MenuItem.OnMenuItemClickListener {
|
71
|
83
|
}
|
72
|
84
|
|
73
|
85
|
private void setFont() {
|
74
|
|
- if (buttonParams.font == null) {
|
|
86
|
+ if (!buttonParams.font.hasFont()) {
|
75
|
87
|
return;
|
76
|
88
|
}
|
77
|
89
|
ArrayList<View> buttons = findActualTextViewInMenuByLabel();
|