Skip to content

Instantly share code, notes, and snippets.

@achuvm
Last active January 19, 2019 15:03
Show Gist options
  • Save achuvm/fd336b091413be2ca7b17fa861603ab1 to your computer and use it in GitHub Desktop.
Save achuvm/fd336b091413be2ca7b17fa861603ab1 to your computer and use it in GitHub Desktop.
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