|
@@ -1,5 +1,7 @@
|
1
|
1
|
package com.reactnativenavigation.parse;
|
2
|
2
|
|
|
3
|
+import android.support.annotation.Nullable;
|
|
4
|
+
|
3
|
5
|
import com.reactnativenavigation.parse.params.Color;
|
4
|
6
|
import com.reactnativenavigation.parse.params.NullColor;
|
5
|
7
|
import com.reactnativenavigation.parse.parsers.ColorParser;
|
|
@@ -7,22 +9,52 @@ import com.reactnativenavigation.parse.parsers.ColorParser;
|
7
|
9
|
import org.json.JSONObject;
|
8
|
10
|
|
9
|
11
|
public class StatusBarOptions {
|
|
12
|
+ public enum TextColorScheme {
|
|
13
|
+ Light("light"), Dark("dark"), None("none");
|
|
14
|
+
|
|
15
|
+ private String scheme;
|
|
16
|
+
|
|
17
|
+ TextColorScheme(String scheme) {
|
|
18
|
+ this.scheme = scheme;
|
|
19
|
+ }
|
|
20
|
+
|
|
21
|
+ public static TextColorScheme fromString(@Nullable String scheme) {
|
|
22
|
+ if (scheme == null) return None;
|
|
23
|
+ switch (scheme) {
|
|
24
|
+ case "light":
|
|
25
|
+ return Light;
|
|
26
|
+ case "dark":
|
|
27
|
+ return Dark;
|
|
28
|
+ default:
|
|
29
|
+ return None;
|
|
30
|
+ }
|
|
31
|
+ }
|
|
32
|
+
|
|
33
|
+ public boolean hasValue() {
|
|
34
|
+ return !scheme.equals(None.scheme);
|
|
35
|
+ }
|
|
36
|
+ }
|
|
37
|
+
|
10
|
38
|
public static StatusBarOptions parse(JSONObject json) {
|
11
|
39
|
StatusBarOptions result = new StatusBarOptions();
|
12
|
40
|
if (json == null) return result;
|
13
|
41
|
|
14
|
42
|
result.backgroundColor = ColorParser.parse(json, "statusBarBackgroundColor");
|
|
43
|
+ result.textColorScheme = TextColorScheme.fromString(json.optString("statusBarStyle"));
|
15
|
44
|
|
16
|
45
|
return result;
|
17
|
46
|
}
|
18
|
47
|
|
19
|
48
|
public Color backgroundColor = new NullColor();
|
|
49
|
+ public TextColorScheme textColorScheme = TextColorScheme.None;
|
20
|
50
|
|
21
|
51
|
public void mergeWith(StatusBarOptions other) {
|
22
|
52
|
if (other.backgroundColor.hasValue()) backgroundColor = other.backgroundColor;
|
|
53
|
+ if (other.textColorScheme.hasValue()) textColorScheme = other.textColorScheme;
|
23
|
54
|
}
|
24
|
55
|
|
25
|
56
|
public void mergeWithDefault(StatusBarOptions defaultOptions) {
|
26
|
57
|
if (!backgroundColor.hasValue()) backgroundColor = defaultOptions.backgroundColor;
|
|
58
|
+ if (!textColorScheme.hasValue()) textColorScheme = defaultOptions.textColorScheme;
|
27
|
59
|
}
|
28
|
60
|
}
|