Ver código fonte

Add badge styling options

Guy Carmeli 8 anos atrás
pai
commit
098f0e509f

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java Ver arquivo

@@ -61,6 +61,8 @@ public class StyleParams {
61 61
     public Color selectedBottomTabsButtonColor;
62 62
     public Color bottomTabsButtonColor;
63 63
     public boolean forceTitlesDisplay;
64
+    public Color bottomTabBadgeTextColor;
65
+    public Color bottomTabBadgeBackgroundColor;
64 66
 
65 67
     public Color navigationBarColor;
66 68
 }

+ 10
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/StyleParamsParser.java Ver arquivo

@@ -47,6 +47,8 @@ public class StyleParamsParser {
47 47
         result.bottomTabsButtonColor = getColor("bottomTabsButtonColor", getDefaultBottomTabsButtonColor());
48 48
         result.selectedBottomTabsButtonColor =
49 49
                 getColor("bottomTabsSelectedButtonColor", getDefaultSelectedBottomTabsButtonColor());
50
+        result.bottomTabBadgeTextColor = getColor("bottomTabBadgeTextColor", getBottomTabBadgeTextColor());
51
+        result.bottomTabBadgeBackgroundColor = getColor("bottomTabBadgeBackgroundColor", getBottomTabBadgeBackgroundColor());
50 52
 
51 53
         result.navigationBarColor = getColor("navigationBarColor", getDefaultNavigationColor());
52 54
         result.forceTitlesDisplay = getBoolean("forceTitlesDisplay", getDefaultForceTitlesDisplay());
@@ -82,6 +84,14 @@ public class StyleParamsParser {
82 84
         return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.selectedBottomTabsButtonColor;
83 85
     }
84 86
 
87
+    private StyleParams.Color getBottomTabBadgeTextColor() {
88
+        return new StyleParams.Color();
89
+    }
90
+
91
+    private StyleParams.Color getBottomTabBadgeBackgroundColor() {
92
+        return new StyleParams.Color();
93
+    }
94
+
85 95
     private StyleParams.Color getDefaultBottomTabsButtonColor() {
86 96
         return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.bottomTabsButtonColor;
87 97
     }

+ 11
- 0
android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java Ver arquivo

@@ -6,6 +6,7 @@ import android.graphics.Color;
6 6
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
7 7
 import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
8 8
 import com.reactnativenavigation.animation.VisibilityAnimator;
9
+import com.reactnativenavigation.params.AppStyle;
9 10
 import com.reactnativenavigation.params.ScreenParams;
10 11
 import com.reactnativenavigation.params.StyleParams;
11 12
 import com.reactnativenavigation.utils.ViewUtils;
@@ -21,6 +22,7 @@ public class BottomTabs extends AHBottomNavigation {
21 22
         setForceTint(true);
22 23
         setId(ViewUtils.generateViewId());
23 24
         createVisibilityAnimator();
25
+        setStyle();
24 26
     }
25 27
 
26 28
     public void addTabs(List<ScreenParams> params, OnTabSelectedListener onTabSelectedListener) {
@@ -78,4 +80,13 @@ public class BottomTabs extends AHBottomNavigation {
78 80
             }
79 81
         });
80 82
     }
83
+
84
+    private void setStyle() {
85
+        if (AppStyle.appStyle.bottomTabBadgeBackgroundColor.hasColor()) {
86
+            setNotificationBackgroundColor(AppStyle.appStyle.bottomTabBadgeBackgroundColor.getColor());
87
+        }
88
+        if (AppStyle.appStyle.bottomTabBadgeTextColor.hasColor()) {
89
+            setNotificationTextColor(AppStyle.appStyle.bottomTabBadgeTextColor.getColor());
90
+        }
91
+    }
81 92
 }

+ 2
- 0
src/deprecated/platformSpecificDeprecated.android.js Ver arquivo

@@ -134,6 +134,8 @@ function convertStyleParams(originalStyleObject) {
134 134
     bottomTabsHidden: originalStyleObject.tabBarHidden,
135 135
     bottomTabsHiddenOnScroll: originalStyleObject.bottomTabsHiddenOnScroll,
136 136
     forceTitlesDisplay: originalStyleObject.forceTitlesDisplay,
137
+    bottomTabBadgeTextColor: originalStyleObject.bottomTabBadgeTextColor,
138
+    bottomTabBadgeBackgroundColor: originalStyleObject.bottomTabBadgeBackgroundColor,
137 139
 
138 140
     navigationBarColor: originalStyleObject.navigationBarColor
139 141
   }