Authored by 鹿亮亮

潮童热门品牌推荐楼层 review by days

... ... @@ -65,4 +65,3 @@ let styles = StyleSheet.create({
},
});
... ...
/**
* Description:
* <p> kids_brands:热门品牌推荐 潮童
* Author: Bruce.Lu
* Version: 1.0
* Created on 2017/2/9.
*/
'use strict'
import React, {
Component
} from 'react';
import ReactNative, {
Text,
ListView,
Image,
View,
StyleSheet,
Dimensions,
TouchableOpacity
} from 'react-native';
import Immutable, {
Map
} from 'immutable';
import HeadTitleCell from './HeadTitleCell';
export default class KidsBrandCell extends Component {
constructor(props) {
super(props);
this.dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
});
}
shouldComponentUpdate(nextProps) {
if (Immutable.is(nextProps.resource, this.props.resource)) {
return false;
} else {
return true;
}
}
_getImageUrl(rowId){
if (rowId == 7){
return require('../../images/brandicon_more.png');
} else {
return {uri:'http://imgsrc.baidu.com/baike/pic/item/e61190ef76c6a7ef560572e1f8faaf51f2de66d2.jpg'};
}
}
_renderRow(rowData,sectionID,rowID,highlightRow){
console.log(sectionID+',' + rowID);
return (
<TouchableOpacity activeOpacity={0.5}>
<View style={styles.row}>
<Image style={styles.image}
source={this._getImageUrl(rowID)}
resizeMode={'contain'}/>
<Text style={styles.text} numberOfLines={1}>
测试标题
</Text>
</View>
</TouchableOpacity>
);
}
render() {
let data = [1,1,1,1,1,1,1,1]
if (!data.length) {
return null;
}
return (
<View style={styles.container}>
<HeadTitleCell title={'潮童热门品牌推荐'}/>
<ListView
contentContainerStyle={styles.list}
dataSource={this.dataSource.cloneWithRows(data)}
initialListSize={data.length}
renderRow={this._renderRow.bind(this)}
/>
</View>
);
}
}
let {width, height} = Dimensions.get('window');
let itemWidth = width / 4;
let itemHeight = 70;
let styles = StyleSheet.create({
container:{
backgroundColor:'white'
},
list: {
backgroundColor: 'white',
borderColor: 'rgb(215, 215, 215)',
borderBottomWidth: 0.5,
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent:'space-around',
alignItems:'flex-start',
},
cell: {
marginLeft: 0,
width: itemWidth,
height: itemWidth + 20,
backgroundColor: 'white',
flexDirection:'column'
},
image:{
width:itemWidth,
height:itemWidth,
},
text:{
width:itemWidth,
height:20,
backgroundColor:'transparent',
fontWeight: 'bold',
color: 'gray',
textAlign:'center',
fontSize:12,
}
});
... ...
... ... @@ -18,6 +18,7 @@ import Focus from './Focus';
import AppIconList from './AppIconList'
import AppHotBrands from './AppHotBrands'
import TrendsetterCollocation from '../floor/TrendsetterCollocation'
import KidsBrandCell from '../cell/KidsBrandsCell';
export default class Home extends Component {
... ... @@ -88,6 +89,12 @@ export default class Home extends Component {
)
}
break;
case 'kidsBrands':{
return (
<KidsBrandCell />
)
}
break;
default:
{
return null;
... ... @@ -126,6 +133,7 @@ export default class Home extends Component {
'appIconList':[1],
'appHotBrands':[1],
'trendsetterCollocation':[1],
'kidsBrands':[1]
};
let isPullToRefresh = ptr && isFetching;
... ...