Skip to content

Commit

Permalink
Allow navigationBarColor change within mergeOptions, addition to PR #…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielang authored and guyca committed Nov 5, 2019
1 parent 9b52fdc commit 8720628
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ public void setDefaultOptions(Options defaultOptions) {

public void mergeOptions(View view, Options options) {
mergeStatusBarOptions(view, options.statusBar);
mergeNavigationBarOptions(options.navigationBar);
}

public void applyOptions(ViewController view, Options options) {
Options withDefaultOptions = options.copy().withDefaultOptions(defaultOptions);
applyOrientation(withDefaultOptions.layout.orientation);
applyViewOptions(view, withDefaultOptions);
applyStatusBarOptions(withDefaultOptions);
applyNavigationBarOptions(withDefaultOptions.navigationBar);
}

public void onViewBroughtToFront(Options options) {
Expand Down Expand Up @@ -85,7 +87,6 @@ private void applyBackgroundColor(ViewController view, Options options) {
}

private void applyStatusBarOptions(Options options) {
setNavigationBarBackgroundColor(options.navigationBar);
setStatusBarBackgroundColor(options.statusBar);
setTextColorScheme(options.statusBar.textColorScheme);
setTranslucent(options.statusBar);
Expand Down Expand Up @@ -119,13 +120,6 @@ private void setStatusBarBackgroundColor(StatusBarOptions statusBar) {
}
}

private void setNavigationBarBackgroundColor(NavigationBarOptions navigationBar) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && navigationBar.backgroundColor.canApplyValue()) {
int defaultColor = activity.getWindow().getNavigationBarColor();
activity.getWindow().setNavigationBarColor(navigationBar.backgroundColor.get(defaultColor));
}
}

private void setTextColorScheme(TextColorScheme scheme) {
final View view = activity.getWindow().getDecorView();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return;
Expand Down Expand Up @@ -196,4 +190,19 @@ private void mergeStatusBarVisible(View view, Bool visible, Bool drawBehind) {
}
}
}

private void applyNavigationBarOptions(NavigationBarOptions options) {
setNavigationBarBackgroundColor(options);
}

private void mergeNavigationBarOptions(NavigationBarOptions options) {
setNavigationBarBackgroundColor(options);
}

private void setNavigationBarBackgroundColor(NavigationBarOptions navigationBar) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && navigationBar.backgroundColor.canApplyValue()) {
int defaultColor = activity.getWindow().getNavigationBarColor();
activity.getWindow().setNavigationBarColor(navigationBar.backgroundColor.get(defaultColor));
}
}
}

0 comments on commit 8720628

Please sign in to comment.