forked from magrinj/react-native-webbrowser
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Jérémy Magrin
committed
Jun 17, 2016
1 parent
5dbb83f
commit 37401c1
Showing
4 changed files
with
105 additions
and
6 deletions.
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,74 @@ | ||
'use strict'; | ||
|
||
import React, { | ||
PropTypes, | ||
} from 'react'; | ||
|
||
import ReactNative, { | ||
Image, | ||
} from 'react-native'; | ||
|
||
import BaseComponent from './BaseComponent' | ||
import styles from './styles' | ||
import Button from './Button'; | ||
|
||
class BackButton extends BaseComponent { | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
visible: props.visible, | ||
}; | ||
|
||
this._bind( | ||
'onBackPress' | ||
); | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
this.setState({ | ||
visible: nextProps.visible | ||
}); | ||
} | ||
|
||
buttonStyle() { | ||
return [styles.backButton, this.props.foregroundColor && {tintColor:this.props.foregroundColor}]; | ||
} | ||
|
||
onBackPress() { | ||
const { onPress } = this.props; | ||
|
||
onPress && onPress(); | ||
} | ||
|
||
render() { | ||
const { visible } = this.props; | ||
|
||
if (!visible) { | ||
return false; | ||
} | ||
|
||
return ( | ||
<Button | ||
onPress={ this.onBackPress.bind(this) }> | ||
<Image | ||
style={this.buttonStyle()} | ||
source={require('./assets/images/arrow-left.png')} | ||
/> | ||
</Button> | ||
); | ||
} | ||
} | ||
|
||
BackButton.propTypes = { | ||
visible: PropTypes.bool, | ||
onPress: PropTypes.func, | ||
foregroundColor: PropTypes.string | ||
}; | ||
|
||
BackButton.defaultProps = { | ||
visible: true, | ||
}; | ||
|
||
module.exports = BackButton; |
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