Browse Source

default to statusBarTextColorScheme from AppStyle

Guy Carmeli 7 years ago
parent
commit
2ce161d09e

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

@@ -6,15 +6,15 @@ import android.support.annotation.Nullable;
6 6
 public enum StatusBarTextColorScheme {
7 7
     Light, Dark, Undefined;
8 8
 
9
-    public static StatusBarTextColorScheme fromString(@Nullable String colorScheme) {
10
-        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || colorScheme == null) return Undefined;
9
+    public static StatusBarTextColorScheme fromString(@Nullable String colorScheme, StatusBarTextColorScheme defaultScheme) {
10
+        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || colorScheme == null) return defaultScheme;
11 11
         switch (colorScheme) {
12 12
             case "light":
13 13
                 return Light;
14 14
             case "dark":
15 15
                 return Dark;
16 16
             default:
17
-                return Undefined;
17
+                return defaultScheme;
18 18
         }
19 19
     }
20 20
 }

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

@@ -30,7 +30,7 @@ public class StyleParamsParser {
30 30
         result.orientation = Orientation.fromString(params.getString("orientation", getDefaultOrientation()));
31 31
         result.statusBarColor = getColor("statusBarColor", getDefaultStatusBarColor());
32 32
         result.statusBarHidden = getBoolean("statusBarHidden", getDefaultStatusHidden());
33
-        result.statusBarTextColorScheme = StatusBarTextColorScheme.fromString(params.getString("statusBarTextColorScheme"));
33
+        result.statusBarTextColorScheme = StatusBarTextColorScheme.fromString(params.getString("statusBarTextColorScheme"), getDefaultStatusBarTextColorScheme());
34 34
         result.contextualMenuStatusBarColor = getColor("contextualMenuStatusBarColor", getDefaultContextualMenuStatusBarColor());
35 35
         result.contextualMenuButtonsColor = getColor("contextualMenuButtonsColor", getDefaultContextualMenuButtonsColor());
36 36
         result.contextualMenuBackgroundColor = getColor("contextualMenuBackgroundColor", getDefaultContextualMenuBackgroundColor());
@@ -99,6 +99,10 @@ public class StyleParamsParser {
99 99
         return result;
100 100
     }
101 101
 
102
+    private StatusBarTextColorScheme getDefaultStatusBarTextColorScheme() {
103
+        return AppStyle.appStyle == null ? StatusBarTextColorScheme.Undefined : AppStyle.appStyle.statusBarTextColorScheme;
104
+    }
105
+
102 106
     private String getDefaultOrientation() {
103 107
         return AppStyle.appStyle == null ? null : AppStyle.appStyle.orientation.name;
104 108
     }