I am using DrawerNavigator for React-Native, and inside the Drawer the following CustomDrawerContentComponent...
const uiTheme = {
palette: {
primaryColor: COLOR.blue500,
},
toolbar: {
container: {
height: 80,
},
},
};
const propTypes = {
navigation: PropTypes.shape({
goBack: PropTypes.func.isRequired,
}).isRequired,
};
const CustomDrawerContentComponent = props => (
<Container>
<Toolbar
leftElement="arrow-back"
onLeftElementPress={() => this.props.navigation.goBack()}
centerElement="Menu"
/>
<View>
<Drawer.Header>
<Drawer.Header.Account
avatar={<Avatar text="K" />}
footer={{
dense: true,
centerElement: {
primaryText: 'Account',
secondaryText: 'xxxx@yahoo.com',
},
rightElement: 'arrow-drop-down',
}}
/>
</Drawer.Header>
<DrawerItems {...props} />
</View>
</Container>
);
const MainRoot = DrawerNavigator(
{
Login: {
path: '/login',
screen: Login,
},
Profile: {
path: '/profile',
screen: Profile,
},
Settings: {
path: '/settings',
screen: Settings,
},
},
{
initialRouteName: 'Settings',
contentOptions: {
activeTintColor: '#2089b0',
activeBackgroundColor: 'transparent',
inactiveTintColor: '#000000',
inactiveBackgroundColor: 'transparent',
labelStyle: {
fontSize: 18,
marginLeft: 0,
fontFamily: 'sans-serif-thin',
},
},
drawerWidth: SCREEN_WIDTH * 0.8,
contentComponent: CustomDrawerContentComponent,
drawerOpenRoute: 'DrawerOpen',
drawerCloseRoute: 'DrawerClose',
drawerToggleRoute: 'DrawerToggle',
}
);
export default class AppContainer extends Component {
render() {
return (
<ThemeContext.Provider value={getTheme(uiTheme)}>
<MainRoot />
</ThemeContext.Provider>
);
}
}
Expo.registerRootComponent(AppContainer);
What I want to do is position the elements of the Toolbar toward the bottom...
How does one do this..? (Sorry relatively new to React-Native...)
Also the code onLeftElementPress={() => this.props.navigation.goBack()} returns null for this.props.navigation.
Is something need to be passed in..?
Thnks.
Am using react-native-material-ui, so Toolbar has leftElementContainer and centerElementContainer elements. So they can be styled using:
const uiTheme = {
palette: {
primaryColor: COLOR.blue500,
},
toolbar: {
container: {
height: 80,
},
leftElementContainer: {
marginTop: 20,
},
centerElementContainer: {
marginTop: 20,
},
},
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.