Created
February 10, 2016 23:37
-
-
Save sharathprabhal/a21dd6aadcd21454b2b4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module.exports = React.createClass({ | |
displayName: 'ImageTester', | |
getInitialState() { | |
return { | |
showImage: false | |
}; | |
}, | |
render() { | |
var imageSrc = 'http://www.eatornotapp.com/img/Home.png?cBuster' + Math.random(); | |
var image; | |
var buttonLabel; | |
if (!this.state.showImage) { | |
buttonLabel = 'Show Image'; | |
image = ( | |
<View | |
style={{ | |
height: 534, | |
width: 300, | |
backgroundColor: '#CCC' | |
}} | |
> | |
</View> | |
); | |
} else { | |
buttonLabel = 'Hide Image'; | |
image = ( | |
<Image | |
style={{ | |
height: 534, | |
width: 300, | |
backgroundColor: '#CCC' | |
}} | |
source={{ | |
uri: imageSrc | |
}} /> | |
); | |
} | |
return ( | |
<View | |
style={{ | |
flex: 1, | |
alignItems: 'center', | |
justifyContent: 'center', | |
}} | |
> | |
<TouchableOpacity | |
style={{ | |
padding: 30 | |
}} | |
onPress={() => { | |
this.setState({showImage: !this.state.showImage}); | |
}} | |
> | |
<Text>{buttonLabel}</Text> | |
</TouchableOpacity> | |
{image} | |
</View> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment