Commit b51bc8f
Add listener API to OverrideColorScheme for dynamic dark mode updates
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: D884274821 parent 1a28d9e commit b51bc8f
File tree
2 files changed
+25
-2
lines changed- packages/react-native/ReactAndroid
- api
- src/main/java/com/facebook/react/modules/appearance
2 files changed
+25
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2475 | 2475 | | |
2476 | 2476 | | |
2477 | 2477 | | |
| 2478 | + | |
2478 | 2479 | | |
2479 | 2480 | | |
2480 | 2481 | | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
2481 | 2486 | | |
2482 | 2487 | | |
2483 | 2488 | | |
| |||
6764 | 6769 | | |
6765 | 6770 | | |
6766 | 6771 | | |
6767 | | - | |
| |||
Lines changed: 20 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 | + | |
38 | 57 | | |
39 | 58 | | |
40 | 59 | | |
| |||
0 commit comments