Authored by 鹿亮亮

hot_category_individualization:热门品类楼层 + title,大数据版 review by 陈林

/**
* Description:
* hot_category_individualization:热门品类楼层 + title,大数据版
* Author: Bruce.Lu
* Version: 1.0
* Created on 2017/2/14.
*/
import React, {Component} from 'react';
import ReactNative, {
Image,
Text,
StyleSheet,
ListView,
View,
TouchableOpacity,
Dimensions,
} from 'react-native';
import Swiper from 'react-native-swiper';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Immutable from 'immutable';
import SlicedImage from '../../../common/components/SlicedImage';
import HeadTitleCell from '../cell/HeadTitleCell';
export default class HotCategoryIndividualization extends Component {
constructor(props) {
super(props);
this._renderRow = this._renderRow.bind(this);
this._onPressItem = this._renderRow.bind(this);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
_getImageUrl(rowId) {
return {uri: 'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'};
}
_onPressItem() {
console.log('_onPressItem');
}
_renderRow(rowData, sectionID, rowID, highlightRow) {
return (
<TouchableOpacity style={styles.cellContainer} onPress={this._onPressItem}>
<Image style={styles.image}
source={this._getImageUrl(rowID)}
resizeMode={'cover'}/>
<Text style={styles.text}>项目</Text>
</TouchableOpacity>
);
}
render() {
let data = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
return (
<View>
<HeadTitleCell title={'热门品类'}/>
<View style={styles.line}/>
<ListView
contentContainerStyle={styles.listContent}
dataSource={this.dataSource.cloneWithRows(data)}
renderRow={this._renderRow}
initialListSize={12}
showsHorizontalScrollIndicator={false}
/>
<View style={styles.line}/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let cellWidth = width / 4;
let imageWidth = (width - 14 * 8) / 4;
let imageHeight = imageWidth * 168 / 126;
const styles = StyleSheet.create({
line: {
height: 0.5,
backgroundColor: '#f7f7f7'
},
listContent: {
backgroundColor: 'transparent',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'flex-start',
alignItems: 'flex-start',
},
cellContainer: {
backgroundColor: '#f5f7f6',
flexDirection: 'column',
justifyContent: 'center',
},
image: {
width: imageWidth,
height: imageHeight,
marginLeft: 14,
marginRight: 14,
},
text: {
backgroundColor: 'transparent',
fontSize: 12,
color: '#444444',
textAlign: 'center',
marginBottom: 7,
marginLeft: 14,
marginRight: 14
}
});
... ...
... ... @@ -32,6 +32,7 @@ import SmallPic from '../floor/SmallPic';
import NewUserFloor from '../floor/NewUserFloor';
import VipUserFloor from '../floor/VipUserFloor';
import ActivityProductFloor from '../floor/ActivityProductFloor';
import HotCategoryIndividualization from '../floor/HotCategoryIndividualization';
export default class Home extends Component {
... ... @@ -205,6 +206,10 @@ export default class Home extends Component {
return <ActivityProductFloor
data = {rowData.get('data')}/>
}
case 'hot_category_individualization':{
return <HotCategoryIndividualization
data = {rowData.get('data')}/>
}
default:
return null;
}
... ...