|
@@ -1,7 +1,9 @@
|
1
|
1
|
package com.reactnativenavigation.views;
|
2
|
2
|
|
3
|
3
|
import android.content.Context;
|
|
4
|
+import android.content.res.AssetManager;
|
4
|
5
|
import android.graphics.Color;
|
|
6
|
+import android.graphics.Typeface;
|
5
|
7
|
|
6
|
8
|
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
|
7
|
9
|
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
|
|
@@ -11,6 +13,8 @@ import com.reactnativenavigation.params.ScreenParams;
|
11
|
13
|
import com.reactnativenavigation.params.StyleParams;
|
12
|
14
|
import com.reactnativenavigation.utils.ViewUtils;
|
13
|
15
|
|
|
16
|
+import java.io.IOException;
|
|
17
|
+import java.util.Arrays;
|
14
|
18
|
import java.util.List;
|
15
|
19
|
|
16
|
20
|
public class BottomTabs extends AHBottomNavigation {
|
|
@@ -23,6 +27,7 @@ public class BottomTabs extends AHBottomNavigation {
|
23
|
27
|
setId(ViewUtils.generateViewId());
|
24
|
28
|
createVisibilityAnimator();
|
25
|
29
|
setStyle();
|
|
30
|
+ setFontFamily(context);
|
26
|
31
|
}
|
27
|
32
|
|
28
|
33
|
public void addTabs(List<ScreenParams> params, OnTabSelectedListener onTabSelectedListener) {
|
|
@@ -97,4 +102,31 @@ public class BottomTabs extends AHBottomNavigation {
|
97
|
102
|
private boolean hasBadgeBackgroundColor() {
|
98
|
103
|
return AppStyle.appStyle.bottomTabBadgeBackgroundColor != null && AppStyle.appStyle.bottomTabBadgeBackgroundColor.hasColor();
|
99
|
104
|
}
|
|
105
|
+
|
|
106
|
+ private boolean hasBottomTabFontFamily() {
|
|
107
|
+ return AppStyle.appStyle.bottomTabFontFamily != null;
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ private void setFontFamily(Context context) {
|
|
111
|
+ if(hasBottomTabFontFamily()) {
|
|
112
|
+
|
|
113
|
+ AssetManager assetManager = context.getAssets();
|
|
114
|
+ String fontFamilyName = AppStyle.appStyle.bottomTabFontFamily;
|
|
115
|
+
|
|
116
|
+ Typeface typeFace = null;
|
|
117
|
+ try {
|
|
118
|
+ boolean hasAsset = Arrays.asList(assetManager.list("fonts")).contains(fontFamilyName);
|
|
119
|
+ typeFace = hasAsset ?
|
|
120
|
+ Typeface.createFromAsset(assetManager, "fonts/".concat(fontFamilyName))
|
|
121
|
+ :
|
|
122
|
+ Typeface.create(fontFamilyName, Typeface.NORMAL);
|
|
123
|
+ } catch (IOException e) {
|
|
124
|
+ e.printStackTrace();
|
|
125
|
+ }
|
|
126
|
+
|
|
127
|
+ if(typeFace != null) {
|
|
128
|
+ setTitleTypeface(typeFace);
|
|
129
|
+ }
|
|
130
|
+ }
|
|
131
|
+ }
|
100
|
132
|
}
|