reactjs - 如何使用 react native 在我的抽屉中添加标题?
问题描述
我正在使用本机反应来开发移动应用程序,所以在我的抽屉里,我想做一些功能组并命名每个组,但我不知道该怎么做
我的抽屉看起来像:
我正在寻找的一个例子(我想以现代方式添加标题):
我的代码的一部分是:
\\The drawer page
const DrawerNavigator = createDrawerNavigator({
Accueil:{
screen:Accueil1,
navigationOptions:{
title:"Accueil ",
drawerIcon:({tintColor})=><Feather name="home" size={16}
color='#ff9900'/>
}
},
{
contentComponent :props => <BarDrawer {...props} />,
contentOptions:{
activeBackgroundColor:"#58ACFA",
activeTintColor:"white",
}
});
export default createAppContainer(DrawerNavigator);
\\The barDrawer that contains the image of @
export default BarDrawer = props =>(
<ScrollView>
<Block style={styles.container} forceInset={{ top: 'always', horizontal: 'never' }}>
<Block style={styles.header}>
<Image style={styles.logo} source={require('./netOne.jpg')} />
<Block right style={styles.headerIcon}>
<FontAwesome5 name="bars" size={15} color={'black'} />
</Block>
</Block>
</Block>
<View Style={styles.contain}>
<DrawerNavigatorItems {...props} />
</View>
</ScrollView>
);
解决方案
您可以使用 DrawerContentScrollView 和 DrawerItem 来实现
<DrawerContentScrollView {...props}>
<View style={{height:150, backgroundColor:COLOR.pink}}>
<Avatar.Image size={24} source={require('../assets/avatar.png')} />
<Text>HeaderTitle</Title>
</View>
<Drawer.Section>
<DrawerItem
icon={({ color, size }) => (
<MaterialCommunityIcons
name="account-outline"
color={color}
size={size}
/>
)}
label="Profile"
onPress={() => {}}
/>
<DrawerItem
icon={({ color, size }) => (
<MaterialCommunityIcons
name="account-outline"
color={color}
size={size}
/>
)}
label="Profile"
onPress={() => {}}
/>
</Drawer.Section>
<Drawer.Section>
<DrawerItem
icon={({ color, size }) => (
<MaterialCommunityIcons
name="account-outline"
color={color}
size={size}
/>
)}
label="Profile"
onPress={() => {}}
/>
<DrawerItem
icon={({ color, size }) => (
<MaterialCommunityIcons
name="account-outline"
color={color}
size={size}
/>
)}
label="Profile"
onPress={() => {}}
/>
</Drawer.Section>
</DrawerContentScrollView >
Drawer.Session 创建单独的 Sessions 可以有不同的样式。在有完整实现的地方使用下面的链接
https://reactnavigation.org/blog/2020/01/29/using-react-navigation-5-with-react-native-paper
推荐阅读
- go - 将接口放入结构
- wordpress - 将 Next.js 连接到 Wordpress
- python - 如何在键盘记录程序中将输出组合成单行?
- python - 如何让 Python 区分大小写字符。
- visual-studio-code - Visual Studio Code - 在资源管理器中排除 NPM 脚本
- opennlp - 在 OpenNLP 中创建日语 NER 训练模型?
- go - 在 Go 中搜索和更新 HCL 中的字符串
- c - struct的C分段错误数组
- javascript - 从一年到一年的 Javascript 季度数组
- google-app-engine - 部署到谷歌应用引擎失败