Authored by 孙凯

优化 性能 review by hongmo

... ... @@ -168,7 +168,7 @@ export default class ProductListCell extends Component {
this.props.onLongPressProduct&&this.props.onLongPressProduct(rowID);
}}
>
<View>
<View style={{overflow: 'hidden'}} >
{this._renderTags()}
... ...
... ... @@ -63,47 +63,31 @@ export default class Tags extends React.Component {
width: 45,
},
};
}
this._renderRow = this._renderRow.bind(this);
render() {
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 != r2,
});
}
let {style, items} = this.props;
let ary = items?items.toArray():[];
_renderRow(rowData, sectionID, rowID) {
let item = this.config[rowData];
return (
<View style={[styles.container]}>
{ary.map((m, i) => {
let item = this.config[m];
if (!item) {
return null;
}
let width = Math.ceil(item.width * DEVICE_WIDTH_RATIO);
let marginLeft = rowID == 0 ? 0 : 2;
let marginLeft = i == 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}
/>
})}
</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',
... ...
... ... @@ -227,6 +227,7 @@ export default class RedBrand extends Component {
yh_viewVisible = {true}
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
removeClippedSubviews={true}
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderRow={this.renderRow}
renderSectionHeader={this.renderSectionHeader}
... ...