Browse Source

Add support for white colors :)

Guy Carmeli 8 years ago
parent
commit
c9147439f1

+ 14
- 3
android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java View File

5
 public class StyleParams {
5
 public class StyleParams {
6
     public static class Color {
6
     public static class Color {
7
         @ColorInt
7
         @ColorInt
8
-        private int color = -1;
8
+        private Integer color = null;
9
 
9
 
10
-        public Color(int color) {
10
+        public Color() {
11
+            color = null;
12
+        }
13
+
14
+        public Color(Integer color) {
11
             this.color = color;
15
             this.color = color;
12
         }
16
         }
13
 
17
 
14
         public boolean hasColor() {
18
         public boolean hasColor() {
15
-            return color != -1;
19
+            return color != null;
16
         }
20
         }
17
 
21
 
18
         public int getColor() {
22
         public int getColor() {
21
             }
25
             }
22
             return color;
26
             return color;
23
         }
27
         }
28
+
29
+        public static Color parse(String str) {
30
+            if (str == null) {
31
+                return new Color();
32
+            }
33
+            return new Color(android.graphics.Color.parseColor(str));
34
+        }
24
     }
35
     }
25
 
36
 
26
     public Color statusBarColor;
37
     public Color statusBarColor;

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

3
 import android.os.Bundle;
3
 import android.os.Bundle;
4
 
4
 
5
 import com.reactnativenavigation.params.ActivityParams;
5
 import com.reactnativenavigation.params.ActivityParams;
6
-import com.reactnativenavigation.params.StyleParams;
7
 
6
 
8
 public class ActivityParamsParser extends Parser {
7
 public class ActivityParamsParser extends Parser {
9
     public static ActivityParams parse(Bundle params) {
8
     public static ActivityParams parse(Bundle params) {

+ 0
- 15
android/app/src/main/java/com/reactnativenavigation/params/parsers/ColorParser.java View File

1
-package com.reactnativenavigation.params.parsers;
2
-
3
-import android.graphics.Color;
4
-import android.support.annotation.ColorInt;
5
-
6
-//TODO move to JS
7
-public class ColorParser {
8
-    @ColorInt
9
-    public static int parse(String str) {
10
-        if (str == null) {
11
-            return -1;
12
-        }
13
-        return Color.parseColor(str);
14
-    }
15
-}

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

29
         result.topBarColor = getColor("topBarColor", getDefaultTopBarColor());
29
         result.topBarColor = getColor("topBarColor", getDefaultTopBarColor());
30
         result.titleBarHidden = getBoolean("titleBarHidden", isDefaultTopBarHidden());
30
         result.titleBarHidden = getBoolean("titleBarHidden", isDefaultTopBarHidden());
31
         result.titleBarTitleColor = getColor("titleBarTitleColor", getDefaultTitleBarColor());
31
         result.titleBarTitleColor = getColor("titleBarTitleColor", getDefaultTitleBarColor());
32
-        result.titleBarButtonColor = getColor("titleBarButtonColor", getDefaultTitleBarColor());
32
+        result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
33
         result.backButtonHidden = getBoolean("backButtonHidden", isDefaultBackButtonHidden());
33
         result.backButtonHidden = getBoolean("backButtonHidden", isDefaultBackButtonHidden());
34
         result.topTabsHidden = getBoolean("topTabsHidden", isDefaultTopTabsHidden());
34
         result.topTabsHidden = getBoolean("topTabsHidden", isDefaultTopTabsHidden());
35
 
35
 
50
 
50
 
51
     @Nullable
51
     @Nullable
52
     private StyleParams.Color getDefaultNavigationColor() {
52
     private StyleParams.Color getDefaultNavigationColor() {
53
-        return appStyle == null ? new StyleParams.Color(-1) : appStyle.navigationBarColor;
53
+        return appStyle == null ? new StyleParams.Color() : appStyle.navigationBarColor;
54
     }
54
     }
55
 
55
 
56
     @Nullable
56
     @Nullable
57
     private StyleParams.Color getDefaultSelectedBottomTabsButtonColor() {
57
     private StyleParams.Color getDefaultSelectedBottomTabsButtonColor() {
58
-        return appStyle == null ? new StyleParams.Color(-1) : appStyle.selectedBottomTabsButtonColor;
58
+        return appStyle == null ? new StyleParams.Color() : appStyle.selectedBottomTabsButtonColor;
59
     }
59
     }
60
 
60
 
61
     @Nullable
61
     @Nullable
62
     private StyleParams.Color getDefaultBottomTabsButtonColor() {
62
     private StyleParams.Color getDefaultBottomTabsButtonColor() {
63
-        return appStyle == null ? new StyleParams.Color(-1) : appStyle.bottomTabsButtonColor;
63
+        return appStyle == null ? new StyleParams.Color() : appStyle.bottomTabsButtonColor;
64
     }
64
     }
65
 
65
 
66
     @Nullable
66
     @Nullable
67
     private StyleParams.Color getDefaultBottomTabsColor() {
67
     private StyleParams.Color getDefaultBottomTabsColor() {
68
-        return appStyle == null ? new StyleParams.Color(-1) : appStyle.bottomTabsColor;
68
+        return appStyle == null ? new StyleParams.Color() : appStyle.bottomTabsColor;
69
     }
69
     }
70
 
70
 
71
     private boolean isDefaultBottomTabsHiddenOnScroll() {
71
     private boolean isDefaultBottomTabsHiddenOnScroll() {
90
 
90
 
91
     @Nullable
91
     @Nullable
92
     private StyleParams.Color getDefaultTitleBarColor() {
92
     private StyleParams.Color getDefaultTitleBarColor() {
93
-        return appStyle == null ? new StyleParams.Color(-1) : appStyle.titleBarTitleColor;
93
+        return appStyle == null ? new StyleParams.Color() : appStyle.titleBarTitleColor;
94
     }
94
     }
95
 
95
 
96
     @Nullable
96
     @Nullable
97
     private StyleParams.Color getTitleBarButtonColor() {
97
     private StyleParams.Color getTitleBarButtonColor() {
98
-        return appStyle == null ? new StyleParams.Color(-1) : appStyle.titleBarButtonColor;
98
+        return appStyle == null ? new StyleParams.Color() : appStyle.titleBarButtonColor;
99
     }
99
     }
100
 
100
 
101
     private boolean isDefaultTopBarHidden() {
101
     private boolean isDefaultTopBarHidden() {
104
 
104
 
105
     @Nullable
105
     @Nullable
106
     private StyleParams.Color getDefaultTopBarColor() {
106
     private StyleParams.Color getDefaultTopBarColor() {
107
-        return appStyle == null ? new StyleParams.Color(-1) : appStyle.topBarColor;
107
+        return appStyle == null ? new StyleParams.Color() : appStyle.topBarColor;
108
     }
108
     }
109
 
109
 
110
     @Nullable
110
     @Nullable
111
     private StyleParams.Color getDefaultStatusBarColor() {
111
     private StyleParams.Color getDefaultStatusBarColor() {
112
-        return appStyle == null ? new StyleParams.Color(-1) : appStyle.statusBarColor;
112
+        return appStyle == null ? new StyleParams.Color() : appStyle.statusBarColor;
113
     }
113
     }
114
 
114
 
115
     private boolean getBoolean(String titleBarHidden, boolean defaultValue) {
115
     private boolean getBoolean(String titleBarHidden, boolean defaultValue) {
118
 
118
 
119
     @NonNull
119
     @NonNull
120
     private StyleParams.Color getColor(String key, StyleParams.Color defaultColor) {
120
     private StyleParams.Color getColor(String key, StyleParams.Color defaultColor) {
121
-        StyleParams.Color color = new StyleParams.Color(ColorParser.parse(params.getString(key)));
121
+        StyleParams.Color color = StyleParams.Color.parse(params.getString(key));
122
         if (color.hasColor()) {
122
         if (color.hasColor()) {
123
             return color;
123
             return color;
124
         } else {
124
         } else {

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

25
         if (hasKey(bundle,"icon")) {
25
         if (hasKey(bundle,"icon")) {
26
             result.icon = ImageLoader.loadImage(bundle.getString("icon"));
26
             result.icon = ImageLoader.loadImage(bundle.getString("icon"));
27
         }
27
         }
28
-        result.color = new StyleParams.Color(ColorParser.parse(bundle.getString("color")));
28
+        result.color = StyleParams.Color.parse(bundle.getString("color"));
29
         result.showAsAction = parseShowAsAction(bundle.getString("showAsAction"));
29
         result.showAsAction = parseShowAsAction(bundle.getString("showAsAction"));
30
         result.enabled = bundle.getBoolean("enabled", true);
30
         result.enabled = bundle.getBoolean("enabled", true);
31
         result.eventId = bundle.getString("id");
31
         result.eventId = bundle.getString("id");

+ 0
- 5
src/deprecated/platformSpecificDeprecated.android.js View File

140
   });
140
   });
141
 
141
 
142
   params.appStyle = convertStyleParams(params.appStyle);
142
   params.appStyle = convertStyleParams(params.appStyle);
143
-
144
-  console.log('appStyle.bottomTabsButtonColor', params.appStyle.bottomTabsButtonColor);
145
-  console.log('appStyle.bottomTabsColor', params.appStyle.bottomTabsColor);
146
-  console.log('appStyle.selectedBottomTabsButtonColor', params.appStyle.selectedBottomTabsButtonColor);
147
-
148
   // TODO: add drawer params
143
   // TODO: add drawer params
149
   newPlatformSpecific.startApp(params);
144
   newPlatformSpecific.startApp(params);
150
 }
145
 }