-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f193aa3
commit 0cf995b
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React, { PureComponent } from 'react'; | ||
import { View, TouchableOpacity } from 'react-native'; | ||
import { Header } from 'react-native-elements'; | ||
import Icon from 'react-native-vector-icons/FontAwesome'; | ||
|
||
import styles from '../Components/Shared.style'; | ||
|
||
const containerStyle = { | ||
alignItems: 'center', | ||
height: 50, | ||
justifyContent: 'center', | ||
paddingHorizontal: 0, | ||
paddingTop: 0, | ||
width: '100%' | ||
}; | ||
|
||
const centerContainerStyle = { paddingRight: 20 }; | ||
|
||
const buttonStyle = { | ||
alignItems: 'center', | ||
height: 48, | ||
justifyContent: 'center', | ||
paddingRight: 5, | ||
width: 40 | ||
}; | ||
|
||
const textStyle = { color: '#fff' }; | ||
|
||
const withHeader = ({ title = '' }) => (WrappedComponent) => { | ||
class HOC extends PureComponent { | ||
goBack = () => this.props.history.goBack(); | ||
|
||
goHome = () => this.props.history.replace('/'); | ||
|
||
horizontalComponent = (name, size, onPress) => ( | ||
<TouchableOpacity onPress={onPress} style={buttonStyle}> | ||
<Icon name={name} size={size} color='#fff' /> | ||
</TouchableOpacity> | ||
); | ||
|
||
centerComponent = (title) => ({ | ||
text: title.toUpperCase(), | ||
style: textStyle | ||
}); | ||
|
||
render() { | ||
return ( | ||
<View style={styles.container}> | ||
<Header | ||
containerStyle={containerStyle} | ||
centerContainerStyle={centerContainerStyle} | ||
leftComponent={this.horizontalComponent('chevron-left', 20, this.goBack)} | ||
centerComponent={this.centerComponent(title)} | ||
rightComponent={this.horizontalComponent('home', 25, this.goHome)} | ||
/> | ||
<WrappedComponent /> | ||
</View> | ||
); | ||
} | ||
} | ||
|
||
return HOC; | ||
} | ||
|
||
export default withHeader; |