Skip to content

Add listener API to OverrideColorScheme for dynamic dark mode updates#54791

Closed
alanleedev wants to merge 1 commit intofacebook:mainfrom
alanleedev:export-D88427482
Closed

Add listener API to OverrideColorScheme for dynamic dark mode updates#54791
alanleedev wants to merge 1 commit intofacebook:mainfrom
alanleedev:export-D88427482

Conversation

@alanleedev
Copy link
Copy Markdown
Contributor

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 addListener() method to the OverrideColorScheme interface with a default no-op implementation for backward compatibility
  2. Automatic listener registration in AppearanceModule's init block that triggers onConfigurationChanged() when the color scheme changes

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

Differential Revision: D88427482

@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
Copy Markdown

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 D88427482.

alanleedev added a commit to alanleedev/react-native that referenced this pull request Dec 5, 2025
…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
…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
@meta-codesync
Copy link
Copy Markdown

meta-codesync bot commented Dec 10, 2025

This pull request has been merged in 80e384a.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Dec 10, 2025
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @alanleedev in 80e384a

When will my fix make it into a release? | How to file a pick request?

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 Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants