...
|
...
|
@@ -63,47 +63,31 @@ export default class Tags extends React.Component { |
|
|
width: 45,
|
|
|
},
|
|
|
};
|
|
|
|
|
|
this._renderRow = this._renderRow.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => r1 != r2,
|
|
|
});
|
|
|
}
|
|
|
|
|
|
_renderRow(rowData, sectionID, rowID) {
|
|
|
let item = this.config[rowData];
|
|
|
if (!item) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
let width = Math.ceil(item.width * DEVICE_WIDTH_RATIO);
|
|
|
let marginLeft = rowID == 0 ? 0 : 2;
|
|
|
let iconStyle = {width, height: tagHeight, marginLeft};
|
|
|
|
|
|
return (
|
|
|
<Image style={[styles.icon, iconStyle]} source={item.image}/>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
|
|
|
let {style, items} = this.props;
|
|
|
// let tags = ['is_discount', 'resale', ];
|
|
|
|
|
|
let ary = items?items.toArray():[];
|
|
|
|
|
|
return (
|
|
|
<View style={[styles.container]}>
|
|
|
<ListView
|
|
|
style={[styles.container]}
|
|
|
contentContainerStyle={[styles.contentContainer]}
|
|
|
enableEmptySections={true}
|
|
|
dataSource={this.dataSource.cloneWithRows(ary)}
|
|
|
renderRow={this._renderRow}
|
|
|
scrollEnabled={false}
|
|
|
scrollsToTop={false}
|
|
|
horizontal={true}
|
|
|
showsHorizontalScrollIndicator={false}
|
|
|
/>
|
|
|
{ary.map((m, i) => {
|
|
|
|
|
|
let item = this.config[m];
|
|
|
if (!item) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
let width = Math.ceil(item.width * DEVICE_WIDTH_RATIO);
|
|
|
let marginLeft = i == 0 ? 0 : 2;
|
|
|
let iconStyle = {width, height: tagHeight, marginLeft};
|
|
|
|
|
|
return (
|
|
|
<Image style={[styles.icon, iconStyle]} source={item.image}/>
|
|
|
);
|
|
|
})}
|
|
|
</View>
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -116,10 +100,8 @@ let tagHeight = Math.ceil(14 * DEVICE_WIDTH_RATIO); |
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
|
|
|
},
|
|
|
contentContainer: {
|
|
|
height: tagHeight,
|
|
|
flexDirection: 'row',
|
|
|
},
|
|
|
icon: {
|
|
|
resizeMode: 'contain',
|
...
|
...
|
|