|
|
'use strict';
|
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
import ReactNative, {
|
|
|
View,
|
|
|
Text,
|
|
|
Image,
|
|
|
ListView,
|
|
|
StyleSheet,
|
|
|
Dimensions,
|
|
|
TouchableOpacity,
|
|
|
InteractionManager,
|
|
|
Platform,
|
|
|
} from 'react-native';
|
|
|
|
|
|
import Immutable, {Map} from 'immutable';
|
|
|
import RrecommendForYouCell from './RrecommendForYouCell'
|
|
|
export default class RecommendForYou extends Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => r1 !== r2,
|
|
|
});
|
|
|
this._renderRow = this._renderRow.bind(this);
|
|
|
}
|
|
|
|
|
|
_renderRow(rowData, rowID, sectionID) {
|
|
|
let title = '';
|
|
|
switch (sectionID) {
|
|
|
case 'hotBrandList':
|
|
|
title = '热门品牌';
|
|
|
break;
|
|
|
case 'browseBrandList':
|
|
|
title = '浏览过的品牌';
|
|
|
break;
|
|
|
case 'newBrandList':
|
|
|
title = '新入驻品牌';
|
|
|
break;
|
|
|
default:
|
|
|
}
|
|
|
return (
|
|
|
<RrecommendForYouCell
|
|
|
title={title}
|
|
|
dataSource={rowData}
|
|
|
/>
|
|
|
)
|
|
|
}
|
|
|
_renderSeperator(){
|
|
|
return (
|
|
|
<View style={styles.seperatorView}>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
_renderHeader(){
|
|
|
return (
|
|
|
<View style={styles.seperatorView}>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let {resource} = this.props;
|
|
|
let dataSource = {
|
|
|
hotBrandList: resource.get('hotBrandList').toArray(),
|
|
|
browseBrandList: resource.get('browseBrandList').toArray(),
|
|
|
newBrandList: resource.get('newBrandList').toArray(),
|
|
|
};
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<ListView
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRows(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
renderSeparator={this._renderSeperator}
|
|
|
renderHeader={this._renderHeader}
|
|
|
enableEmptySections={true}
|
|
|
/>
|
|
|
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
backgroundColor: '#f0f0f0',
|
|
|
},
|
|
|
contentContainer: {
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
seperatorView: {
|
|
|
height: 15,
|
|
|
backgroundColor: '#f0f0f0',
|
|
|
},
|
|
|
}); |
...
|
...
|
|