Repository navigation
fix(android): update the tab bar after Appearance.setColorScheme() - #628
Open
oleksandrzavarzin-callstack wants to merge 1 commit into
Open
oleksandrzavarzin-callstack wants to merge 1 commit into
oleksandrzavarzin-callstack wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #397.
PR Description
On Android, the tab bar kept its old colors after
Appearance.setColorScheme(). Only a system dark mode change or a new mount of the tab bar changed the colors.React Native implements
setColorSchemewithAppCompatDelegate.setDefaultNightMode. AppCompat updates the Activity configuration, but Android does not callonConfigurationChangedon the views. The code from #305 that creates the bar again runs only in that view callback, so it never ran.This PR adds a second trigger for the same code. While the view is attached, it listens to the Activity with
addOnConfigurationChangedListenerfrom androidx. A change can also happen while the view is detached. For that case, the view compares the configuration each time it attaches.A tab bar with
tabBarStyle.backgroundColororbarTintColorkeeps the current behavior: the library does not create it again.How to test?
Appearance.setColorScheme('dark'), for example from a button.Appearance.setColorScheme('light').Tested on Android 8.1 (API 27), Android 13 (API 33), and the Android 17 beta (API 37). The system dark mode path still works on all 3.
Videos
397-android-37-before-light-to-dark.mp4
397-android-37-before-dark-to-light.mp4
397-android-37-after-light-to-dark.mp4
397-android-37-after-dark-to-light.mp4