Commit 4978134
Add listener API to OverrideColorScheme for dynamic dark mode updates (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: mdvacca
Differential Revision: D884274821 parent 95cc1e7 commit 4978134
File tree
2 files changed
+35
-1
lines changed- packages/react-native/ReactAndroid
- api
- src/main/java/com/facebook/react/modules/appearance
2 files changed
+35
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2475 | 2475 | | |
2476 | 2476 | | |
2477 | 2477 | | |
| 2478 | + | |
2478 | 2479 | | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
2479 | 2486 | | |
2480 | 2487 | | |
2481 | 2488 | | |
| |||
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
31 | 39 | | |
32 | | - | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
38 | 65 | | |
39 | 66 | | |
40 | 67 | | |
| |||
0 commit comments