瀏覽代碼

Set BottomTab colours only if needed (#1414)

Fixes #1411
Each time a color attribute is set in AHBottomNavigation, all items in
the BottomTabs are recreated. If a badge is set, it is animated each
time items are recreated. This behaviour can even be seen in the gifs
in the repo https://github.com/aurelhubert/ahbottomnavigation
Guy Carmeli 8 年之前
父節點
當前提交
0d6b895b1b
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10
    4
      android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java

+ 10
- 4
android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java 查看文件

43
             setBackgroundColor(params.bottomTabsColor);
43
             setBackgroundColor(params.bottomTabsColor);
44
         }
44
         }
45
         if (params.bottomTabsButtonColor.hasColor()) {
45
         if (params.bottomTabsButtonColor.hasColor()) {
46
-            setInactiveColor(params.bottomTabsButtonColor.getColor());
46
+            if (getInactiveColor() != params.bottomTabsButtonColor.getColor()) {
47
+                setInactiveColor(params.bottomTabsButtonColor.getColor());
48
+            }
47
         }
49
         }
48
         if (params.selectedBottomTabsButtonColor.hasColor()) {
50
         if (params.selectedBottomTabsButtonColor.hasColor()) {
49
-            setAccentColor(params.selectedBottomTabsButtonColor.getColor());
51
+            if (getAccentColor() != params.selectedBottomTabsButtonColor.getColor()) {
52
+                setAccentColor(params.selectedBottomTabsButtonColor.getColor());
53
+            }
50
         }
54
         }
51
 
55
 
52
         setVisibility(params.bottomTabsHidden, true);
56
         setVisibility(params.bottomTabsHidden, true);
90
 
94
 
91
     private void setBackgroundColor(StyleParams.Color bottomTabsColor) {
95
     private void setBackgroundColor(StyleParams.Color bottomTabsColor) {
92
         if (bottomTabsColor.hasColor()) {
96
         if (bottomTabsColor.hasColor()) {
93
-            setDefaultBackgroundColor(bottomTabsColor.getColor());
94
-        } else {
97
+            if (bottomTabsColor.getColor() != getDefaultBackgroundColor()) {
98
+                setDefaultBackgroundColor(bottomTabsColor.getColor());
99
+            }
100
+        } else if (Color.WHITE != getDefaultBackgroundColor()){
95
             setDefaultBackgroundColor(Color.WHITE);
101
             setDefaultBackgroundColor(Color.WHITE);
96
         }
102
         }
97
     }
103
     }