我如何使Expo Image Picker Dark主题
这是我当前的图像拾取器功能,
const pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.images,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
})
console.log(result)
if (!result.cancelled) {
setImage(result.uri)
}
}
我正在尝试使弹出画廊以黑暗为主题。我该怎么做?
This is my current image picker function
const pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.images,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
})
console.log(result)
if (!result.cancelled) {
setImage(result.uri)
}
}
I am trying to make the pop-up gallery dark-themed. How do I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
React Navigation具有一个理想选择的主题组件!您可以使用他们的默认主题,也可以根据需要自定义!查看详细信息在这里。
在项目中添加主题实际上非常容易。假设您已经在使用React-Navigation,那么您甚至不需要下载额外的依赖项。
创建一个新的.js文件,称为您想要的任何内容,典型名称将为
theme.js
。粘贴内部:此主题组件有很多道具可供选择,因此请务必检查一下。
这是文档中的一个示例:
现在,对于黑暗模式部分,React-Navigation已内置为主题,默认和黑暗:
import {defaultTheme,darktheme,darktheme} from'@react-navigation/naters';
>在导航容器内部,现在您要做的就是调用您要使用的主题:
这是从轻度和黑暗主题开始的绝佳方法。一旦掌握了它,您也可以实现状态,以使您的应用在默认模式和黑暗模式之间切换!
React Navigation has a Theme component that would be perfect for this! You can use their default theme, or customize it however you want! Check out details here.
Adding a theme to your project is actually super easy. Assuming you're already using React-Navigation, then you don't even need to download an additional dependency.
Create a new .js file called whatever you want, typical name would be
theme.js
. Inside paste this:This theme component has a whole bunch of props to choose from so make sure to check it out.
Here is an example from the docs:
Now for the dark mode portion, React-Navigation has built in themes, default and dark:
import { DefaultTheme, DarkTheme } from '@react-navigation/native';
Inside your navigation container, now all you have to do is call the theme you'd like to use:
This is a great rudimentary way to get start with light and dark themes. Once you get the hang of it, you can implement State as well to make your app toggle between default and dark mode!