[android] PlatformColor does not respond to dark | light mode changes on android ?
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
PlatformColor on android does not pickup the correct color on theme changes as it does on IOS.
it's worth mentioning that useColorScheme does pick up the device theme correctly.
Version
66.4
Output of npx react-native info
System:
OS: macOS 11.6.1
CPU: (8) x64 Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Memory: 295.98 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.1 - /usr/local/bin/node
Yarn: 1.22.15 - ~/.yarn/bin/yarn
npm: 8.1.2 - ~/n/bin/npm
Watchman: 2021.12.20.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK:
API Levels: 28, 29, 30, 31
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 31.0.0
System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: Arctic Fox 2020.3.1 Patch 3 Arctic Fox 2020.3.1 Patch 3
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_292 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.66.4 => 0.66.4
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
after creating a react native project.
[1] create a values-night/colors.xml and values/colors.xml inside android/app/src/main/res
[2] add both dark mode and light mode colors to both colors.xml files accordingly.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="text">#000000</color>
<color name="background">#FFFFFF</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="text">#FFFFFF</color>
<color name="background">#000000</color>
</resources>
[3] rebuild the app.
[4] change your device theme from settings
observation:
colors don't react to the device theme.
[5] try changing your device theme then reloading from dev menu.
observation:
colors change & respect the device theme after reload.
[6] removing uiMode from android:configChanges inside inside AndroidManifest.xml does resolve the issue however it's performant ( the application would then be torn down and recreated with the theme change ).
Snack, code example, screenshot, or link to a repository
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 issue 中描述的 values/colors.xml 和 values-night/colors.xml 资源,通过链接的 platformColorAndroidIssue 示例重现该行为。在更改设备主题的同时,将 PlatformColor 与 useColorScheme 进行比较,并检查 AndroidManifest.xml,尤其是 android:configChanges 和 uiMode。当主题发生变化时 PlatformColor 能够更新,且不需要重新加载或拆除应用程序,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, react-native
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100