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
 
40
 
41
     public void mergeOptions(View view, Options options) {
41
     public void mergeOptions(View view, Options options) {
42
         mergeStatusBarOptions(view, options.statusBar);
42
         mergeStatusBarOptions(view, options.statusBar);
43
+        mergeNavigationBarOptions(options.navigationBar);
43
     }
44
     }
44
 
45
 
45
     public void applyOptions(ViewController view, Options options) {
46
     public void applyOptions(ViewController view, Options options) {
47
         applyOrientation(withDefaultOptions.layout.orientation);
48
         applyOrientation(withDefaultOptions.layout.orientation);
48
         applyViewOptions(view, withDefaultOptions);
49
         applyViewOptions(view, withDefaultOptions);
49
         applyStatusBarOptions(withDefaultOptions);
50
         applyStatusBarOptions(withDefaultOptions);
51
+        applyNavigationBarOptions(withDefaultOptions.navigationBar);
50
     }
52
     }
51
 
53
 
52
     public void onViewBroughtToFront(Options options) {
54
     public void onViewBroughtToFront(Options options) {
85
     }
87
     }
86
 
88
 
87
     private void applyStatusBarOptions(Options options) {
89
     private void applyStatusBarOptions(Options options) {
88
-        setNavigationBarBackgroundColor(options.navigationBar);
89
         setStatusBarBackgroundColor(options.statusBar);
90
         setStatusBarBackgroundColor(options.statusBar);
90
         setTextColorScheme(options.statusBar.textColorScheme);
91
         setTextColorScheme(options.statusBar.textColorScheme);
91
         setTranslucent(options.statusBar);
92
         setTranslucent(options.statusBar);
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
     private void setTextColorScheme(TextColorScheme scheme) {
123
     private void setTextColorScheme(TextColorScheme scheme) {
130
         final View view = activity.getWindow().getDecorView();
124
         final View view = activity.getWindow().getDecorView();
131
         if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
125
         if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
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
 }