我正在使用 React Navigation V5,我想要自定义抽屉导航内容,其中包含顶部的图像和其他一些导航项
这是我的抽屉里的物品:
- 图片(自定义视图)
- 轮廓
- 产品
- 订单
这是我的自定义抽屉内容的代码。
export const CustomDrawerContent = props => {
return (
<SafeAreaView style={styles.customDrawer}>
<View
style={{ flex: 1 }}
>
<DrawerContentScrollView {...props}>
<TouchableNativeFeedback onPress={() => { console.log('go profile'); }}>
<View style={styles.userContainer}>
<View style={styles.imageContainer}>
<Image
style={styles.image}
source={{ uri: 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTLCta_MQcJFd2kpz8HwXFm-6vxVqXzRUgCOIuhs94Q32GG8EeJ' }}
/>
</View>
<Text style={styles.name}>Nguyen van Admin</Text>
</View>
</TouchableNativeFeedback>
<DrawerItemList {...props} />
</DrawerContentScrollView>
<DrawerItem
label="Đăng xuất"
style={{
borderWidth: 1,
}}
labelStyle={{
color: 'black'
}}
icon={({ focused, color, size }) => <Ionicons
size={23}
color={color}
name={Platform.OS === 'android' ? 'md-exit' : 'ios-exit-outline'}
/>}
/>
</View>
</SafeAreaView>
);
}
因此,如果配置文件屏幕存在于抽屉中,通过单击图像我可以使用
props.navigate("profile")
但是,如果我从抽屉屏幕中删除配置文件屏幕。我无法导航到个人资料了。我如何存档导航到配置文件屏幕而不添加抽屉屏幕?
或者我可以从抽屉项目中隐藏个人资料项目吗?