Add ThemePreferences listener for dark mode updates #54808
Closed
+44
−1
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.
Summary:
This change implements the internal Facebook-specific listener mechanism for dynamic dark mode updates in FB4A. It builds on the OSS changes in D88427482 which added the
addListener()API toOverrideColorSchemeinterface.Why this is needed:
Previously, when users toggled dark mode in FB4A Settings, React Native JavaScript would not be notified of the change. The
AppearanceModulewould only reflect the initial color scheme state from instantiation, causing UI inconsistencies when users changed their theme preference in native settings UI.How it works:
ThemePreferences.setDarkMode()is calledThemePreferencesnotifies all registered listeners (includingFB4AThemeOverrideColorScheme)FB4AThemeOverrideColorSchemeforwards the notification toAppearanceModulevia the listener callbackAppearanceModule.onConfigurationChanged()is invoked (set up in OSS changes)appearanceChangedevent is emitted to React Native JavaScriptReviewed By: xiphirx
Differential Revision: D88431860