|
@@ -2,7 +2,6 @@ package com.reactnativenavigation.views;
|
2
|
2
|
|
3
|
3
|
import android.content.Context;
|
4
|
4
|
import android.graphics.Color;
|
5
|
|
-import android.os.Bundle;
|
6
|
5
|
import android.text.TextUtils;
|
7
|
6
|
|
8
|
7
|
import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
|
|
@@ -11,7 +10,6 @@ import com.reactnativenavigation.animation.VisibilityAnimator;
|
11
|
10
|
import com.reactnativenavigation.params.AppStyle;
|
12
|
11
|
import com.reactnativenavigation.params.ScreenParams;
|
13
|
12
|
import com.reactnativenavigation.params.StyleParams;
|
14
|
|
-import com.reactnativenavigation.params.parsers.StyleParamsParser;
|
15
|
13
|
import com.reactnativenavigation.utils.ViewUtils;
|
16
|
14
|
import com.reactnativenavigation.views.utils.Constants;
|
17
|
15
|
|
|
@@ -23,17 +21,17 @@ public class BottomTabs extends AHBottomNavigation {
|
23
|
21
|
|
24
|
22
|
public BottomTabs(Context context) {
|
25
|
23
|
super(context);
|
26
|
|
-
|
27
|
24
|
setForceTint(true);
|
28
|
25
|
setId(ViewUtils.generateViewId());
|
29
|
26
|
createVisibilityAnimator();
|
30
|
|
- setStyle(AppStyle.appStyle);
|
|
27
|
+ setStyle();
|
31
|
28
|
setFontFamily();
|
32
|
29
|
}
|
33
|
30
|
|
34
|
31
|
public void addTabs(List<ScreenParams> params, OnTabSelectedListener onTabSelectedListener) {
|
35
|
32
|
for (ScreenParams screenParams : params) {
|
36
|
|
- AHBottomNavigationItem item = new AHBottomNavigationItem(screenParams.tabLabel, screenParams.tabIcon, Color.GRAY);
|
|
33
|
+ AHBottomNavigationItem item = new AHBottomNavigationItem(screenParams.tabLabel, screenParams.tabIcon,
|
|
34
|
+ Color.GRAY);
|
37
|
35
|
addItem(item);
|
38
|
36
|
setOnTabSelectedListener(onTabSelectedListener);
|
39
|
37
|
}
|
|
@@ -41,7 +39,19 @@ public class BottomTabs extends AHBottomNavigation {
|
41
|
39
|
}
|
42
|
40
|
|
43
|
41
|
public void setStyleFromScreen(StyleParams params) {
|
44
|
|
- this.setStyle(params);
|
|
42
|
+ if (params.bottomTabsColor.hasColor()) {
|
|
43
|
+ setBackgroundColor(params.bottomTabsColor);
|
|
44
|
+ }
|
|
45
|
+ if (params.bottomTabsButtonColor.hasColor()) {
|
|
46
|
+ if (getInactiveColor() != params.bottomTabsButtonColor.getColor()) {
|
|
47
|
+ setInactiveColor(params.bottomTabsButtonColor.getColor());
|
|
48
|
+ }
|
|
49
|
+ }
|
|
50
|
+ if (params.selectedBottomTabsButtonColor.hasColor()) {
|
|
51
|
+ if (getAccentColor() != params.selectedBottomTabsButtonColor.getColor()) {
|
|
52
|
+ setAccentColor(params.selectedBottomTabsButtonColor.getColor());
|
|
53
|
+ }
|
|
54
|
+ }
|
45
|
55
|
|
46
|
56
|
setVisibility(params.bottomTabsHidden, true);
|
47
|
57
|
}
|
|
@@ -122,27 +132,23 @@ public class BottomTabs extends AHBottomNavigation {
|
122
|
132
|
Constants.BOTTOM_TABS_HEIGHT);
|
123
|
133
|
}
|
124
|
134
|
|
125
|
|
- private void setStyle(StyleParams params) {
|
126
|
|
- if (params.bottomTabBadgeBackgroundColor.hasColor()) {
|
|
135
|
+ private void setStyle() {
|
|
136
|
+ if (hasBadgeBackgroundColor()) {
|
127
|
137
|
setNotificationBackgroundColor(AppStyle.appStyle.bottomTabBadgeBackgroundColor.getColor());
|
128
|
138
|
}
|
129
|
|
- if (params.bottomTabBadgeTextColor.hasColor()) {
|
|
139
|
+ if (hasBadgeTextColor()) {
|
130
|
140
|
setNotificationTextColor(AppStyle.appStyle.bottomTabBadgeTextColor.getColor());
|
131
|
141
|
}
|
|
142
|
+ }
|
132
|
143
|
|
133
|
|
- if (params.bottomTabsColor.hasColor()) {
|
134
|
|
- setBackgroundColor(params.bottomTabsColor);
|
135
|
|
- }
|
136
|
|
- if (params.bottomTabsButtonColor.hasColor()) {
|
137
|
|
- if (getInactiveColor() != params.bottomTabsButtonColor.getColor()) {
|
138
|
|
- setInactiveColor(params.bottomTabsButtonColor.getColor());
|
139
|
|
- }
|
140
|
|
- }
|
141
|
|
- if (params.selectedBottomTabsButtonColor.hasColor()) {
|
142
|
|
- if (getAccentColor() != params.selectedBottomTabsButtonColor.getColor()) {
|
143
|
|
- setAccentColor(params.selectedBottomTabsButtonColor.getColor());
|
144
|
|
- }
|
145
|
|
- }
|
|
144
|
+ private boolean hasBadgeTextColor() {
|
|
145
|
+ return AppStyle.appStyle.bottomTabBadgeTextColor != null &&
|
|
146
|
+ AppStyle.appStyle.bottomTabBadgeTextColor.hasColor();
|
|
147
|
+ }
|
|
148
|
+
|
|
149
|
+ private boolean hasBadgeBackgroundColor() {
|
|
150
|
+ return AppStyle.appStyle.bottomTabBadgeBackgroundColor != null &&
|
|
151
|
+ AppStyle.appStyle.bottomTabBadgeBackgroundColor.hasColor();
|
146
|
152
|
}
|
147
|
153
|
|
148
|
154
|
private void setFontFamily() {
|