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