Commit 6cd33f6
Add ThemePreferences listener for dark mode updates
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: D884318601 parent f965a0c commit 6cd33f6
File tree
2 files changed
+13
-4
lines changed- packages/react-native/ReactAndroid
- api
- src/main/java/com/facebook/react/modules/appearance
2 files changed
+13
-4
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 | | |
| |||
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
128 | 136 | | |
129 | 137 | | |
130 | 138 | | |
| |||
0 commit comments