Daniel Zlotin 8 years ago
parent
commit
ee6cc6d967

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java View File

@@ -19,6 +19,7 @@ public class StyleParams {
19 19
             return color != null;
20 20
         }
21 21
 
22
+        @ColorInt
22 23
         public int getColor() {
23 24
             if (!hasColor()) {
24 25
                 throw new RuntimeException("Color undefined");
@@ -44,6 +45,7 @@ public class StyleParams {
44 45
     public boolean titleBarHidden;
45 46
     public Color titleBarTitleColor;
46 47
     public Color titleBarButtonColor;
48
+    public Color titleBarDisabledButtonColor;
47 49
     public boolean backButtonHidden;
48 50
 
49 51
     public Color topTabTextColor;

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/TitleBarButtonParams.java View File

@@ -21,6 +21,7 @@ public class TitleBarButtonParams {
21 21
     public String label;
22 22
     public Drawable icon;
23 23
     public StyleParams.Color color;
24
+    public StyleParams.Color disabledColor;
24 25
     public ShowAsAction showAsAction;
25 26
     public boolean enabled = true;
26 27
 

+ 8
- 1
android/app/src/main/java/com/reactnativenavigation/params/parsers/StyleParamsParser.java View File

@@ -1,5 +1,6 @@
1 1
 package com.reactnativenavigation.params.parsers;
2 2
 
3
+import android.graphics.Color;
3 4
 import android.os.Bundle;
4 5
 import android.support.annotation.NonNull;
5 6
 import android.support.annotation.Nullable;
@@ -26,6 +27,7 @@ public class StyleParamsParser {
26 27
         result.titleBarHidden = getBoolean("titleBarHidden", getDefaultTopBarHidden());
27 28
         result.titleBarTitleColor = getColor("titleBarTitleColor", getDefaultTitleBarColor());
28 29
         result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
30
+        result.titleBarDisabledButtonColor = getColor("titleBarDisabledButtonColor", getTitleBarDisabledButtonColor());
29 31
         result.backButtonHidden = getBoolean("backButtonHidden", getDefaultBackButtonHidden());
30 32
         result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());
31 33
 
@@ -40,7 +42,7 @@ public class StyleParamsParser {
40 42
 
41 43
         result.bottomTabsHidden = getBoolean("bottomTabsHidden", getDefaultBottomTabsHidden());
42 44
         result.drawScreenAboveBottomTabs = !result.bottomTabsHidden &&
43
-                params.getBoolean("drawScreenAboveBottomTabs", getDefaultDrawScreenAboveBottomTabs());
45
+                                           params.getBoolean("drawScreenAboveBottomTabs", getDefaultDrawScreenAboveBottomTabs());
44 46
         result.bottomTabsHiddenOnScroll =
45 47
                 getBoolean("bottomTabsHiddenOnScroll", getDefaultBottomTabsHiddenOnScroll());
46 48
         result.bottomTabsColor = getColor("bottomTabsColor", getDefaultBottomTabsColor());
@@ -128,6 +130,11 @@ public class StyleParamsParser {
128 130
         return AppStyle.appStyle == null ? new StyleParams.Color() : AppStyle.appStyle.titleBarButtonColor;
129 131
     }
130 132
 
133
+    @Nullable
134
+    private StyleParams.Color getTitleBarDisabledButtonColor() {
135
+        return AppStyle.appStyle == null ? new StyleParams.Color(Color.LTGRAY) : AppStyle.appStyle.titleBarDisabledButtonColor;
136
+    }
137
+
131 138
     private boolean getDefaultTopBarHidden() {
132 139
         return AppStyle.appStyle != null && AppStyle.appStyle.titleBarHidden;
133 140
     }

+ 4
- 3
android/app/src/main/java/com/reactnativenavigation/params/parsers/TitleBarButtonParamsParser.java View File

@@ -26,15 +26,16 @@ public class TitleBarButtonParamsParser extends Parser {
26 26
         if (hasKey(bundle,"icon")) {
27 27
             result.icon = ImageLoader.loadImage(bundle.getString("icon"));
28 28
         }
29
-        result.color = getColor(bundle, AppStyle.appStyle.titleBarButtonColor);
29
+        result.color = getColor(bundle, "color", AppStyle.appStyle.titleBarButtonColor);
30
+        result.disabledColor = getColor(bundle, "disabledColor", AppStyle.appStyle.titleBarDisabledButtonColor);
30 31
         result.showAsAction = parseShowAsAction(bundle.getString("showAsAction"));
31 32
         result.enabled = bundle.getBoolean("enabled", true);
32 33
         result.eventId = bundle.getString("id");
33 34
         return result;
34 35
     }
35 36
 
36
-    private StyleParams.Color getColor(Bundle bundle, StyleParams.Color defaultColor) {
37
-        StyleParams.Color color = StyleParams.Color.parse(bundle.getString("color"));
37
+    private StyleParams.Color getColor(Bundle bundle, String key, StyleParams.Color defaultColor) {
38
+        StyleParams.Color color = StyleParams.Color.parse(bundle.getString(key));
38 39
         return color.hasColor() || defaultColor == null ? color : defaultColor;
39 40
     }
40 41
 

+ 4
- 2
android/app/src/main/java/com/reactnativenavigation/utils/ViewUtils.java View File

@@ -1,7 +1,6 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3 3
 import android.content.Context;
4
-import android.graphics.Color;
5 4
 import android.graphics.PorterDuff;
6 5
 import android.graphics.PorterDuffColorFilter;
7 6
 import android.graphics.drawable.Drawable;
@@ -12,6 +11,7 @@ import android.view.ViewTreeObserver;
12 11
 import android.view.WindowManager;
13 12
 
14 13
 import com.reactnativenavigation.NavigationApplication;
14
+import com.reactnativenavigation.params.AppStyle;
15 15
 
16 16
 import java.util.concurrent.atomic.AtomicInteger;
17 17
 
@@ -33,7 +33,9 @@ public class ViewUtils {
33 33
     }
34 34
 
35 35
     public static void tintDrawable(Drawable drawable, int tint, boolean enabled) {
36
-        drawable.setColorFilter(new PorterDuffColorFilter(enabled ? tint : Color.LTGRAY, PorterDuff.Mode.SRC_IN));
36
+        drawable.setColorFilter(new PorterDuffColorFilter(enabled ? tint :
37
+                AppStyle.appStyle.titleBarDisabledButtonColor.getColor(),
38
+                PorterDuff.Mode.SRC_IN));
37 39
     }
38 40
 
39 41
     public static float convertDpToPixel(float dp) {

+ 1
- 1
package.json View File

@@ -7,7 +7,7 @@
7 7
     "type": "git",
8 8
     "url": "https://github.com/wix/react-native-navigation.git"
9 9
   },
10
-  "version": "2.0.0-experimental.49",
10
+  "version": "2.0.0-experimental.50",
11 11
   "description": "React Native Navigation - truly native navigation for iOS and Android",
12 12
   "nativePackage": true,
13 13
   "bugs": {