问题
how is it possible to position the menu point at the lower edge of the screen? The best solution would be if you could simply change the style of the navigation options for each element.
Here is my App Navigator:
const AppNavigator = createDrawerNavigator(
{
Einkaufsliste: {
screen: MainScreen,
navigationOptions: {
drawerIcon: <Icon name="shopping-cart" />
}
},
Bearbeiten: {
screen: BasketEditScreen,
navigationOptions: {
drawerIcon: <Icon name="edit" />
}
}
},
{
contentComponent: CustomDrawerComponent
}
);
Thanks!
回答1:
According to react-navigation you can make a custom Drawer navigator, so what you need is to create a similar thing to their example:
import { DrawerItems, SafeAreaView } from 'react-navigation';
const CustomDrawerContentComponent = (props) => (
<ScrollView>
<SafeAreaView style={styles.container} forceInset={{ top: 'always', horizontal: 'never' }}>
<DrawerItems {...props} />
</SafeAreaView>
</ScrollView>
);
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
So in your case what you want to do is:
import { DrawerItems, SafeAreaView } from 'react-navigation';
const CustomDrawerContentComponent = (props) => (
<ScrollView>
<SafeAreaView style={styles.container} forceInset={{ top: 'always', horizontal: 'never' }}>
<View style={{flex: 1 }}>
<DrawerItems {...props} />
</View>
<TouchableOpacity style={{flexDirection: 'row', alignItems: 'center'}}>
//Your pencil icon here with correct margin to the right
<Text>Bearbeiten</Text>
</TouchableOpacity>
</SafeAreaView>
</ScrollView>
);
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
来源:https://stackoverflow.com/questions/54494213/position-drawer-element-at-the-bottom-of-the-menu