javascript - 尝试修复 React Native 中的暗模式,适用于 Android
问题描述
我必须在主要针对 IOS 的 ReactNative 应用程序上修复暗模式。我想我现在可以在大多数文件中解决一半的问题,但是有一个名为 Colors.js 的文件,带有 DynamicColorsIOS。我尝试使用“外观”,几乎所有东西都变暗了,但它不是动态的。然后我发现了关于 PlatformColor,但我不确定如何使用它。
这是一段代码,如果有人可以帮助我理解。
/* New palette */
pinkPrimary: {
light: primitiveColors.pinkPrimary,
dark: primitiveColors.pinkPrimary,
},
backPrimary: {
light: primitiveColors.blackPrimary,
dark: primitiveColors.blackPrimary,
},
grayPrimary: {
light: primitiveColors.grayPrimary,
dark: primitiveColors.grayPrimary,
},
grayButtonIcon: {
light: primitiveColors.grayButtonIcon,
dark: primitiveColors.grayButtonIcon,
},
gray3: {
light: primitiveColors.gray3,
dark: primitiveColors.gray3,
},
gray4: {
light: primitiveColors.gray4,
dark: primitiveColors.gray4,
},
}
const colorsForPlatform = Object.keys(colors).reduce((memo, name) => {
if (Platform.OS === 'ios') {
memo[name] = DynamicColorIOS(colors[name])
} else {
memo[name] = colors[name].light
// Don't know how PlatformColor works, or if it's what I should use here..
// memo[name] = PlatformColor(colors[name])
//
}
console.log(colors[name])
return memo
}, {})
解决方案
推荐阅读
- javascript - 使用 ASP.NET web api 2 上传 xml 格式的 Excel 文件
- postgresql - 执行 pg_dump 时出现共享内存错误
- shell - 通过 jenkins 中的 shell 脚本将 ipa 上传到 hockeyapp
- java - 使用 github 通用网络钩子触发 Jenkins
- c++ - 致命错误:cuda.h:C++ 没有这样的文件或目录
- apache-nifi - 我们可以从包含一个流的单个进程组中只提升单个流吗?
- string-formatting - 重复动作:开始时间和随后的频率格式约定
- r - 无法通过 RStudio 的任务调度程序启动浏览器
- php - 内爆关联数组
- hyperledger-fabric - 如何将 HyperLedger composer Business 网络与 Hyperledger explorer 集成?