...
|
...
|
@@ -31,67 +31,65 @@ export default class HotCategoryIndividualization extends Component { |
|
|
});
|
|
|
}
|
|
|
|
|
|
_renderRow(rowData, sectionID, rowID, highlightRow) {
|
|
|
let title = rowData.get('title');
|
|
|
let actionUrl = rowData.get('url');
|
|
|
let imgUrl = SlicedImage.getSlicedUrl(rowData.get('src'),imageWidth,imageHeight,2);
|
|
|
return (
|
|
|
<TouchableOpacity style={styles.cellContainer}
|
|
|
onPress={()=>this.props.onPressVipBannerItem&&this.props.onPressVipBannerItem(actionUrl,rowID)}>
|
|
|
<YH_Image style={styles.image}
|
|
|
url={imgUrl}/>
|
|
|
<Text style={styles.text}>{title}</Text>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let data = this.props.data;
|
|
|
let title = data.get('title').get('title');
|
|
|
let categoryData = data.get('list');
|
|
|
let rowH = 40 + 2 + cellHeight * 3;
|
|
|
let title = this.props.data.get('title');
|
|
|
let data = this.props.data.get('list').toArray();
|
|
|
let lineNumber = parseInt((data.length + 3) / 4);
|
|
|
let listHeight = Math.floor(lineNumber * cellHeight);
|
|
|
let containerHeight = listHeight + 40;
|
|
|
return (
|
|
|
<View style={{width:width,height:rowH}}>
|
|
|
<HeadTitleCell title={title}/>
|
|
|
<View style={styles.line}/>
|
|
|
<ListView
|
|
|
contentContainerStyle={styles.listContent}
|
|
|
dataSource={this.dataSource.cloneWithRows(categoryData.toArray())}
|
|
|
renderRow={this._renderRow}
|
|
|
initialListSize={12}
|
|
|
showsHorizontalScrollIndicator={false}
|
|
|
/>
|
|
|
<View style={styles.line}/>
|
|
|
<View style={[styles.container, {height: containerHeight}]}>
|
|
|
<HeadTitleCell title={title.get('title')} moreUrl={title.get('more_url')} onPressTitleMore={this.props.onPressTitleMore}/>
|
|
|
<View style={[styles.list, {height: listHeight}]}>
|
|
|
{data.map((item, i) => {
|
|
|
let url = YH_Image.getSlicedUrl(item.get('src'), imageWidth, imageHeight, 2);
|
|
|
return (
|
|
|
<TouchableOpacity
|
|
|
key={i}
|
|
|
style={styles.cellContainer}
|
|
|
activeOpacity={1}
|
|
|
onPress={() => {
|
|
|
this.props.onPressVipBannerItem && this.props.onPressVipBannerItem(item.get('url'), i + 1);
|
|
|
}}>
|
|
|
<YH_Image url={url} style={styles.image} />
|
|
|
<Text style={styles.text}>{item.get('title')}</Text>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
})}
|
|
|
<View style={[styles.vLine1, {height: listHeight}]} />
|
|
|
<View style={[styles.vLine2, {height: listHeight}]} />
|
|
|
<View style={[styles.vLine3, {height: listHeight}]} />
|
|
|
<View style={styles.hLine1} />
|
|
|
<View style={styles.hLine2} />
|
|
|
</View>
|
|
|
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let cellWidth = width / 4-0.5;
|
|
|
let cellWidth = width / 4;
|
|
|
let imageWidth = cellWidth - 14 * 2;
|
|
|
let imageHeight = imageWidth * 168 / 126;
|
|
|
let cellHeight = imageHeight + 20;
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
line: {
|
|
|
height: 0.5,
|
|
|
backgroundColor: '#f7f7f7'
|
|
|
container: {
|
|
|
width: width,
|
|
|
flexDirection: 'column',
|
|
|
},
|
|
|
listContent: {
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
list: {
|
|
|
flexDirection: 'row',
|
|
|
flexWrap: 'wrap',
|
|
|
justifyContent: 'flex-start',
|
|
|
alignItems: 'flex-start',
|
|
|
width:width,
|
|
|
},
|
|
|
cellContainer: {
|
|
|
backgroundColor: '#f5f7f6',
|
|
|
width:cellWidth,
|
|
|
justifyContent:'center',
|
|
|
height:cellHeight,
|
|
|
alignItems:'center',
|
|
|
marginRight:0.5,
|
|
|
marginBottom:0.5
|
|
|
flexDirection:'column'
|
|
|
},
|
|
|
image: {
|
|
|
width: imageWidth,
|
...
|
...
|
@@ -104,5 +102,42 @@ const styles = StyleSheet.create({ |
|
|
textAlign: 'center',
|
|
|
width:cellWidth,
|
|
|
height:20
|
|
|
}
|
|
|
},
|
|
|
vLine1: {
|
|
|
position: 'absolute',
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
width: 0.5,
|
|
|
top: 0,
|
|
|
left: cellWidth,
|
|
|
},
|
|
|
vLine2: {
|
|
|
position: 'absolute',
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
width: 0.5,
|
|
|
top: 0,
|
|
|
left: cellWidth * 2,
|
|
|
},
|
|
|
vLine3: {
|
|
|
position: 'absolute',
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
width: 0.5,
|
|
|
top: 0,
|
|
|
left: cellWidth * 3,
|
|
|
},
|
|
|
hLine1: {
|
|
|
position: 'absolute',
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
width,
|
|
|
height: 0.5,
|
|
|
top: cellHeight,
|
|
|
left: 0,
|
|
|
},
|
|
|
hLine2: {
|
|
|
position: 'absolute',
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
width,
|
|
|
height: 0.5,
|
|
|
top: cellHeight * 2,
|
|
|
left: 0,
|
|
|
},
|
|
|
}); |
...
|
...
|
|