Browse Source

Allow navigationBarColor change within mergeOptions, addition to PR #5547 (#5624)

Daniel Lang 5 years ago
parent
commit
87206286bf

+ 17
- 8
lib/android/app/src/main/java/com/reactnativenavigation/presentation/Presenter.java View File

@@ -40,6 +40,7 @@ public class Presenter {
40 40
 
41 41
     public void mergeOptions(View view, Options options) {
42 42
         mergeStatusBarOptions(view, options.statusBar);
43
+        mergeNavigationBarOptions(options.navigationBar);
43 44
     }
44 45
 
45 46
     public void applyOptions(ViewController view, Options options) {
@@ -47,6 +48,7 @@ public class Presenter {
47 48
         applyOrientation(withDefaultOptions.layout.orientation);
48 49
         applyViewOptions(view, withDefaultOptions);
49 50
         applyStatusBarOptions(withDefaultOptions);
51
+        applyNavigationBarOptions(withDefaultOptions.navigationBar);
50 52
     }
51 53
 
52 54
     public void onViewBroughtToFront(Options options) {
@@ -85,7 +87,6 @@ public class Presenter {
85 87
     }
86 88
 
87 89
     private void applyStatusBarOptions(Options options) {
88
-        setNavigationBarBackgroundColor(options.navigationBar);
89 90
         setStatusBarBackgroundColor(options.statusBar);
90 91
         setTextColorScheme(options.statusBar.textColorScheme);
91 92
         setTranslucent(options.statusBar);
@@ -119,13 +120,6 @@ public class Presenter {
119 120
         }
120 121
     }
121 122
 
122
-    private void setNavigationBarBackgroundColor(NavigationBarOptions navigationBar) {
123
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && navigationBar.backgroundColor.canApplyValue()) {
124
-            int defaultColor = activity.getWindow().getNavigationBarColor();
125
-            activity.getWindow().setNavigationBarColor(navigationBar.backgroundColor.get(defaultColor));
126
-        }
127
-    }
128
-
129 123
     private void setTextColorScheme(TextColorScheme scheme) {
130 124
         final View view = activity.getWindow().getDecorView();
131 125
         if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
@@ -196,4 +190,19 @@ public class Presenter {
196 190
             }
197 191
         }
198 192
     }
193
+
194
+    private void applyNavigationBarOptions(NavigationBarOptions options) {
195
+        setNavigationBarBackgroundColor(options);
196
+    }
197
+
198
+    private void mergeNavigationBarOptions(NavigationBarOptions options) {
199
+        setNavigationBarBackgroundColor(options);
200
+    }
201
+
202
+    private void setNavigationBarBackgroundColor(NavigationBarOptions navigationBar) {
203
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && navigationBar.backgroundColor.canApplyValue()) {
204
+            int defaultColor = activity.getWindow().getNavigationBarColor();
205
+            activity.getWindow().setNavigationBarColor(navigationBar.backgroundColor.get(defaultColor));
206
+        }
207
+    }
199 208
 }