Created
February 4, 2015 05:37
-
-
Save paramaggarwal/898597bf634f164f55b2 to your computer and use it in GitHub Desktop.
React Native clone's example JS file for rows in the search results.
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
/** @jsx Rubber.createElement */ | |
var Rubber = require('./rubber'); | |
var TableRowItem = Rubber.createClass({ | |
getInitialState: function() { | |
return { | |
name: '', | |
key: null, | |
didSelectRow: null | |
} | |
}, | |
onClick: function () { | |
this.didSelectRow && this.didSelectRow(this.state.key); | |
}, | |
render: function(props) { | |
var product = props.product; | |
var key = props.key; | |
this.state.name = props.product.product; | |
this.state.key = props.key; | |
this.didSelectRow = props.didSelectRow; | |
return ( | |
<View style={{height: 100, flexDirection: 'row'}} onClick={this.onClick} needsClickHandler={true} > | |
<Image style={{ | |
flex: 1 | |
}} | |
src={product.search_image} /> | |
<View style={{ | |
flex: 3 | |
}}> | |
<Text style={{ | |
flex: 2, | |
color: '#333333' | |
}} | |
value={product.product} /> | |
<Text style={{ | |
flex: 1, | |
color: '#666666' | |
}} | |
value={product.discounted_price ? 'Rs. ' + product.discounted_price : ''} /> | |
</View> | |
</View> | |
); | |
} | |
}); | |
module.exports = TableRowItem; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment