Skip to content

Conversation

@alanleedev
Copy link
Contributor

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 to OverrideColorScheme interface.

Why this is needed:
Previously, when users toggled dark mode in FB4A Settings, React Native JavaScript would not be notified of the change. The AppearanceModule would 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:

  1. User toggles dark mode in FB4A Settings → ThemePreferences.setDarkMode() is called
  2. ThemePreferences notifies all registered listeners (including FB4AThemeOverrideColorScheme)
  3. FB4AThemeOverrideColorScheme forwards the notification to AppearanceModule via the listener callback
  4. AppearanceModule.onConfigurationChanged() is invoked (set up in OSS changes)
  5. If the color scheme changed, an appearanceChanged event is emitted to React Native JavaScript

Reviewed By: xiphirx

Differential Revision: D88431860

…facebook#54791)

Summary:

This change adds a listener mechanism to the `OverrideColorScheme` interface to enable dynamic updates when the user's dark mode preference changes via `OverrideColorScheme`.

Previously, `AppearanceModule` would only reflect the initial color scheme state when instantiated. If a user toggled dark mode through an `OverrideColorScheme` implementation, React Native JavaScript would not be notified of the change, causing UI inconsistencies.

This implementation adds:
1. An optional `addSchemeChangeListener()` method to the `OverrideColorScheme` interface with a default no-op implementation for backward compatibility. Also adding matching `removeSchemeChangeListener()`.
2. Automatic listener registration in `AppearanceModule`'s init block that triggers `onConfigurationChanged()` when the color scheme changes

Changelog:
[Android][Added] - Add `addSchemeChangeListener()` function to `OverrideColorScheme` interface to support dynamic appearance updates via override

Reviewed By: javache

Differential Revision: D88427482
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 to `OverrideColorScheme` interface.

**Why this is needed:**
Previously, when users toggled dark mode in FB4A Settings, React Native JavaScript would not be notified of the change. The `AppearanceModule` would 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:**
1. User toggles dark mode in FB4A Settings → `ThemePreferences.setDarkMode()` is called
2. `ThemePreferences` notifies all registered listeners (including `FB4AThemeOverrideColorScheme`)
3. `FB4AThemeOverrideColorScheme` forwards the notification to `AppearanceModule` via the listener callback
4. `AppearanceModule.onConfigurationChanged()` is invoked (set up in OSS changes)
5. If the color scheme changed, an `appearanceChanged` event is emitted to React Native JavaScript

Reviewed By: xiphirx

Differential Revision: D88431860
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 5, 2025
@meta-codesync
Copy link

meta-codesync bot commented Dec 5, 2025

@alanleedev has exported this pull request. If you are a Meta employee, you can view the originating Diff in D88431860.

@javache
Copy link
Member

javache commented Dec 11, 2025

Closed internally

@javache javache closed this Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants