我想在我的RN应用程序的抽屉导航底部添加注销按钮.
我试图用以下方式使用contentComponent
:
const DrawerWithLogoutButton = (props) => (
<ScrollView>
<SafeAreaView style={styles.container} forceInset={{ top: 'always', horizontal: 'never' }}>
<DrawerItems {...props} />
</SafeAreaView>
<Button
style={styles.logoutButton}
title="Logout"
onPress={() => props.navigation.navigate('Login') }/>
</ScrollView>
);
export default Home = createDrawerNavigator({
// screens
}, {
// other settings
contentComponent: DrawerWithLogoutButton,
});
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
},
logoutButton: {
backgroundColor: 'red',
position: 'absolute',
bottom: 0
}
});
结果,我在菜单底部有一个注销按钮.但我想把它放在抽屉面板的底部
此外,我希望注销按钮看起来像其他菜单项,并有一个图标
有没有一种方法可以创建一个抽屉导航器,它的菜单项没有屏幕,只是像我的例子中那样的注销操作?