Преглед изворни кода

Add support for white colors :)

Guy Carmeli пре 8 година
родитељ
комит
c9147439f1

+ 14
- 3
android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java Прегледај датотеку

@@ -5,14 +5,18 @@ import android.support.annotation.ColorInt;
5 5
 public class StyleParams {
6 6
     public static class Color {
7 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 15
             this.color = color;
12 16
         }
13 17
 
14 18
         public boolean hasColor() {
15
-            return color != -1;
19
+            return color != null;
16 20
         }
17 21
 
18 22
         public int getColor() {
@@ -21,6 +25,13 @@ public class StyleParams {
21 25
             }
22 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 37
     public Color statusBarColor;

+ 0
- 1
android/app/src/main/java/com/reactnativenavigation/params/parsers/ActivityParamsParser.java Прегледај датотеку

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

+ 0
- 15
android/app/src/main/java/com/reactnativenavigation/params/parsers/ColorParser.java Прегледај датотеку

@@ -1,15 +0,0 @@
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 Прегледај датотеку

@@ -29,7 +29,7 @@ public class StyleParamsParser {
29 29
         result.topBarColor = getColor("topBarColor", getDefaultTopBarColor());
30 30
         result.titleBarHidden = getBoolean("titleBarHidden", isDefaultTopBarHidden());
31 31
         result.titleBarTitleColor = getColor("titleBarTitleColor", getDefaultTitleBarColor());
32
-        result.titleBarButtonColor = getColor("titleBarButtonColor", getDefaultTitleBarColor());
32
+        result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
33 33
         result.backButtonHidden = getBoolean("backButtonHidden", isDefaultBackButtonHidden());
34 34
         result.topTabsHidden = getBoolean("topTabsHidden", isDefaultTopTabsHidden());
35 35
 
@@ -50,22 +50,22 @@ public class StyleParamsParser {
50 50
 
51 51
     @Nullable
52 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 56
     @Nullable
57 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 61
     @Nullable
62 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 66
     @Nullable
67 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 71
     private boolean isDefaultBottomTabsHiddenOnScroll() {
@@ -90,12 +90,12 @@ public class StyleParamsParser {
90 90
 
91 91
     @Nullable
92 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 96
     @Nullable
97 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 101
     private boolean isDefaultTopBarHidden() {
@@ -104,12 +104,12 @@ public class StyleParamsParser {
104 104
 
105 105
     @Nullable
106 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 110
     @Nullable
111 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 115
     private boolean getBoolean(String titleBarHidden, boolean defaultValue) {
@@ -118,7 +118,7 @@ public class StyleParamsParser {
118 118
 
119 119
     @NonNull
120 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 122
         if (color.hasColor()) {
123 123
             return color;
124 124
         } else {

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/params/parsers/TitleBarButtonParamsParser.java Прегледај датотеку

@@ -25,7 +25,7 @@ public class TitleBarButtonParamsParser extends Parser {
25 25
         if (hasKey(bundle,"icon")) {
26 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 29
         result.showAsAction = parseShowAsAction(bundle.getString("showAsAction"));
30 30
         result.enabled = bundle.getBoolean("enabled", true);
31 31
         result.eventId = bundle.getString("id");

+ 0
- 5
src/deprecated/platformSpecificDeprecated.android.js Прегледај датотеку

@@ -140,11 +140,6 @@ function startTabBasedApp(params) {
140 140
   });
141 141
 
142 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 143
   // TODO: add drawer params
149 144
   newPlatformSpecific.startApp(params);
150 145
 }