Last active
January 19, 2019 15:03
-
-
Save achuvm/fd336b091413be2ca7b17fa861603ab1 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
import React, { Component } from 'react'; | |
import { | |
ViroScene, | |
ViroImage, | |
ViroButton, | |
} from 'react-viro'; | |
let imageOne = {uri: "http://wiki.magicc.org/images/c/ce/MAGICC_logo_small.jpg"}; | |
let imageTwo = {uri: "http://planetpixelemporium.com/images/fullsize/541moon.jpg"}; | |
var SwapImageTest = React.createClass({ | |
getInitialState: function() { | |
return { | |
showImageOne : true, | |
}; | |
}, | |
render: function() { | |
return ( | |
<ViroScene> | |
<ViroImage position={[0,0,-1]} source={this.state.showImageOne ? imageOne : imageTwo} | |
onClick={this._onImageClick} /> | |
<ViroButton position={[.5,-1,-1]} source={imageOne} onClick={this._onImageOneClick}/> | |
<ViroButton position={[-.5,-1,-1]} source={imageTwo} onClick={this._onImageTwoClick}/> | |
</ViroScene> | |
); | |
}, | |
_onImageClick() { | |
this.setState({ | |
showImageOne : !this.state.showImageOne | |
}) | |
}, | |
_onImageOneClick() { | |
this.setState({ | |
showImageOne : true | |
}) | |
}, | |
_onImageTwoClick() { | |
this.setState({ | |
showImageOne : false | |
}) | |
} | |
}); | |
module.exports = SwapImageTest; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment