Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improverment - Statusbar background color based on theme #2218

Conversation

AlessandroFrangiamone
Copy link
Contributor

The following PR includes the functionality requested in issue #1665.

Implementation description:

I have created the methodosetBarsColourBasedOnCurrentTheme which takes the UserPreferences.Theme as input and assigns the corresponding appearance to the stasubar and navbar.
Note that the UserPreferences.Theme was passed as input so that in the Theme.System and Theme.Sunrise cases the same method can be recursively called while keeping the code clean.

Result:

Screen.Recording.2024-02-11.at.17.36.26.mp4

}
bottomNavigation.setBackgroundColor(Color.BLACK)
}
UserPreferences.Theme.Dark -> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe all of these (excluding Black and Night) can be combined under either isDarkThemeOn() and !isDarkThemeOn() (or just else). That should simplify this and avoid any potential discrepancies in sunriseSunsetTheme (it would be very rare for that to happen though).

Ex.

when {
theme == UserPreferences.Theme.Black || theme == UserPreferences.Theme.Night ->
// Same as today
}
isDarkThemeOn() -> {
window.statusBarColor = ColorUtils.backgroundColor(window.decorView.rootView.context)
}
else -> {
// Light
window.statusBarColor = ColorUtils.backgroundColor(window.decorView.rootView.context)
WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightStatusBars = true
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the code is simpler that way. Fixed.

@kylecorry31
Copy link
Owner

Thanks, I left one comment - if you prefer I make that change after, let me know and I'll merge as is.

@AlessandroFrangiamone
Copy link
Contributor Author

Thanks, I left one comment - if you prefer I make that change after, let me know and I'll merge as is.

Just fixed

@kylecorry31 kylecorry31 merged commit 0294438 into kylecorry31:main Feb 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants