...
|
...
|
@@ -27,46 +27,62 @@ export default class Recommend extends React.Component { |
|
|
componentDidMount() {
|
|
|
}
|
|
|
|
|
|
_pressRow(rowData){
|
|
|
this.props.onPressRecommendItem(rowData.url)
|
|
|
}
|
|
|
|
|
|
renderRow(rowData,sectionID,rowID,highlightRow) {
|
|
|
return (
|
|
|
<View style={styles.thumbnail}>
|
|
|
<Image
|
|
|
source={{uri: rowData.src}}
|
|
|
style={styles.thumbnail}
|
|
|
resizeMode={'cover'}>
|
|
|
</Image>
|
|
|
<TouchableOpacity activeOpacity={0.5} onPress={() => this._pressRow(rowData)}>
|
|
|
<View style={styles.thumbnail}>
|
|
|
<Image
|
|
|
source={{uri: rowData.src}}
|
|
|
style={styles.thumbnail}
|
|
|
resizeMode={'cover'}>
|
|
|
|
|
|
<View style={styles.itemTitle}>
|
|
|
<Text style={styles.itemText}>{rowData.name}</Text>
|
|
|
</View>
|
|
|
</Image>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderHeader(){
|
|
|
let data = this.props.resource.toJS();
|
|
|
if (data === '') {
|
|
|
return null;
|
|
|
}
|
|
|
return(
|
|
|
<View style={styles.container}>
|
|
|
<View style={styles.title}>
|
|
|
<Text style={styles.text}>{data.title}</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let data = JSON.parse(this.props.src);
|
|
|
let data = this.props.resource.toJS();
|
|
|
let list = data.list;
|
|
|
let backgroundWidth = Dimensions.get('window').width;
|
|
|
let backgroundHeight = 64 + 20 + Math.ceil(data.length/4) * Dimensions.get('window').width/4;
|
|
|
let backgroundHeight = 64 + 20 + Math.ceil(list.size/4) * Dimensions.get('window').width/4;
|
|
|
|
|
|
return (
|
|
|
<View style={{width: backgroundWidth,height:backgroundHeight,backgroundColor:'#f0f0f0'}}>
|
|
|
<ListView
|
|
|
automaticallyAdjustContentInsets={false}
|
|
|
contentContainerStyle={styles.grid}
|
|
|
dataSource={this.dataSource.cloneWithRows(data)}
|
|
|
dataSource={this.dataSource.cloneWithRows(list)}
|
|
|
renderRow={this.renderRow.bind(this)}
|
|
|
renderHeader = {this.renderHeader.bind(this)}
|
|
|
pageSize={Math.ceil(data.length/4)}
|
|
|
/>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderHeader(){
|
|
|
return(
|
|
|
<View style={styles.container}>
|
|
|
<View style={styles.title}>
|
|
|
<Text style={styles.text}>热门品类</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
const styles = StyleSheet.create({
|
...
|
...
|
@@ -74,10 +90,12 @@ const styles = StyleSheet.create({ |
|
|
flex: 1,
|
|
|
flexDirection: 'row',
|
|
|
flexWrap: 'wrap',
|
|
|
alignItems:'flex-start'
|
|
|
alignItems:'flex-start',
|
|
|
},
|
|
|
|
|
|
thumbnail:{
|
|
|
borderWidth: 0.5,
|
|
|
borderColor: '#CCC',
|
|
|
height:Dimensions.get('window').width/4,
|
|
|
width:Dimensions.get('window').width/4,
|
|
|
},
|
...
|
...
|
@@ -88,6 +106,19 @@ const styles = StyleSheet.create({ |
|
|
width:Dimensions.get('window').width,
|
|
|
backgroundColor:'white',
|
|
|
},
|
|
|
itemTitle:{
|
|
|
marginTop:Dimensions.get('window').width/4 - 30,
|
|
|
justifyContent: 'center',
|
|
|
height:30,
|
|
|
width:Dimensions.get('window').width/4,
|
|
|
backgroundColor:'transparent',
|
|
|
},
|
|
|
itemText: {
|
|
|
fontWeight: 'bold',
|
|
|
textAlign: 'center',
|
|
|
color: 'gray',
|
|
|
fontSize: 10,
|
|
|
},
|
|
|
text: {
|
|
|
fontWeight: 'bold',
|
|
|
textAlign: 'center',
|
...
|
...
|
|