Commit 80e384a
Add listener API to OverrideColorScheme for dynamic dark mode updates (facebook#54791)
Summary:
Pull Request resolved: facebook#54791
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 `{add|remove}SchemeChangeListener()` function to `OverrideColorScheme` interface to support dynamic appearance updates via override
Reviewed By: javache
Differential Revision: D88427482
fbshipit-source-id: 02b71335bb5bebd1f44bf9723c3120f9a1fc182c1 parent 17b3c1c commit 80e384a
File tree
2 files changed
+44
-1
lines changed- packages/react-native/ReactAndroid
- api
- src/main/java/com/facebook/react/modules/appearance
2 files changed
+44
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2465 | 2465 | | |
2466 | 2466 | | |
2467 | 2467 | | |
| 2468 | + | |
2468 | 2469 | | |
2469 | 2470 | | |
2470 | 2471 | | |
| |||
2475 | 2476 | | |
2476 | 2477 | | |
2477 | 2478 | | |
| 2479 | + | |
2478 | 2480 | | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
2479 | 2487 | | |
2480 | 2488 | | |
2481 | 2489 | | |
| |||
Lines changed: 36 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 | + | |
| 39 | + | |
| 40 | + | |
31 | 41 | | |
32 | | - | |
| 42 | + | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
36 | 46 | | |
37 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
38 | 67 | | |
39 | 68 | | |
40 | 69 | | |
| |||
98 | 127 | | |
99 | 128 | | |
100 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
101 | 136 | | |
102 | 137 | | |
103 | 138 | | |
| |||
0 commit comments