application-amicale/components/CustomHeader.js

59 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-06-25 22:20:24 +02:00
import React from "react";
import {Body, Button, Header, Icon, Left, Right, Title} from "native-base";
import {StyleSheet} from "react-native";
import {getStatusBarHeight} from "react-native-status-bar-height";
2019-06-27 10:17:51 +02:00
import Touchable from 'react-native-platform-touchable';
2019-06-25 22:20:24 +02:00
export default class CustomHeader extends React.Component {
render() {
2019-06-27 10:17:51 +02:00
let button;
let rightMenu;
if (this.props.backButton !== undefined && this.props.backButton === true)
button =
<Touchable
style={{padding: 6}}
onPress={() => this.props.navigation.goBack()}>
<Icon
style={{color: "#fff"}}
name="arrow-left"
type={'MaterialCommunityIcons'}/>
</Touchable>;
else
button =
<Touchable
style={{padding: 6}}
onPress={() => this.props.navigation.toggleDrawer()}>
<Icon
style={{color: "#fff"}}
name="menu"
type={'MaterialCommunityIcons'}/>
</Touchable>;
if (this.props.rightMenu)
rightMenu = this.props.rightMenu;
else
rightMenu = <Right/>;
2019-06-25 22:20:24 +02:00
return (
<Header style={styles.header}>
<Left>
2019-06-27 10:17:51 +02:00
{button}
2019-06-25 22:20:24 +02:00
</Left>
<Body>
<Title>{this.props.title}</Title>
</Body>
2019-06-27 10:17:51 +02:00
{rightMenu}
2019-06-25 22:20:24 +02:00
</Header>);
}
};
// Fix header in status bar on Android
const styles = StyleSheet.create({
header: {
paddingTop: getStatusBarHeight(),
height: 54 + getStatusBarHeight(),
},
2019-06-27 10:17:51 +02:00
});