...
|
...
|
@@ -9,6 +9,8 @@ import ReactNative, { |
|
|
StyleSheet,
|
|
|
Dimensions,
|
|
|
TouchableOpacity,
|
|
|
Animated,
|
|
|
LayoutAnimation,
|
|
|
} from 'react-native';
|
|
|
import immutable from 'immutable';
|
|
|
|
...
|
...
|
@@ -17,44 +19,99 @@ export default class CategoryList extends Component { |
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.renderRow = this.renderRow.bind(this);
|
|
|
this.renderSeparator=this.renderSeparator.bind(this);
|
|
|
this._pressLeftRow=this._pressLeftRow.bind(this);
|
|
|
this.dataSource = new ListView.DataSource({rowHasChanged: (r1, r2) => !immutable.is(r1, r2)});
|
|
|
this.subRenderRow=this.subRenderRow.bind(this);
|
|
|
this.state = {
|
|
|
offsetx: 0,
|
|
|
};
|
|
|
}
|
|
|
componentWillMount() {
|
|
|
// Animate creation
|
|
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);
|
|
|
}
|
|
|
|
|
|
_pressLeftRow(value,rowID){
|
|
|
this.props.pressLeftRow(value,rowID);
|
|
|
if(rowID==this.props.currentCateId){
|
|
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);
|
|
|
if(this.state.offsetx<0){
|
|
|
this.setState({offsetx:0});
|
|
|
}else{
|
|
|
this.setState({offsetx: -width/2});
|
|
|
}
|
|
|
}else{
|
|
|
if(this.state.offsetx==0){
|
|
|
this.setState({offsetx: -width/2});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
subRenderRow(rowData, sectionID, rowID, highlightRow) {
|
|
|
|
|
|
let selectText = rowData.get('category_name');
|
|
|
return (
|
|
|
<TouchableOpacity onPress={() => this.props.pressSubCateRow(rowData.toJS())}>
|
|
|
<View style={styles.subRow} >
|
|
|
<Text style={styles.title} numberOfLines={1}>
|
|
|
{selectText}
|
|
|
</Text>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderRow(rowData, sectionID, rowID, highlightRow) {
|
|
|
let selectText = this.props.filterNameFactors.get(rowData.get('category_name'));
|
|
|
console.log('=========renderRow========');
|
|
|
console.log(rowData);
|
|
|
console.log(selectText);
|
|
|
console.log('==========renderRow=======');
|
|
|
let selectText = rowData.get('category_name');
|
|
|
return (
|
|
|
<TouchableOpacity onPress={() => this._pressLeftRow(rowData.toJS())}>
|
|
|
<TouchableOpacity onPress={() => this._pressLeftRow(rowData.toJS(),rowID)}>
|
|
|
<View style={styles.row} >
|
|
|
<Text style={styles.title} numberOfLines={1}>
|
|
|
{selectText}
|
|
|
</Text>
|
|
|
<Image style={styles.arrow} source={require('../../images/shared_enterbuttom_normal.png')}/>
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
|
|
|
renderSeparator(sectionID, rowID, adjacentRowHighlighted) {
|
|
|
return (
|
|
|
<View key={'sep' + rowID} style={styles.separator}>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let {categoryList} = this.props;
|
|
|
let subList = [];
|
|
|
console.log('=========sss========');
|
|
|
console.log(categoryList);
|
|
|
console.log(categoryList.get('categoryListForBoy').toArray());
|
|
|
console.log('==========ddddd=======');
|
|
|
subList=categoryList.get('categoryListForBoy').toArray();
|
|
|
let cateList = [];
|
|
|
let subCateList=[];
|
|
|
if(categoryList.get(this.props.currentChannelId)){
|
|
|
cateList=categoryList.get(this.props.currentChannelId).toArray();
|
|
|
}
|
|
|
if(cateList[0]){
|
|
|
subCateList=categoryList.get(this.props.currentChannelId).get(this.props.currentCateId).get('sub').toArray();
|
|
|
}
|
|
|
return (
|
|
|
<View style={styles.container}>
|
|
|
<ListView
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRows(subList)}
|
|
|
style={styles.contentContainer}
|
|
|
dataSource={this.dataSource.cloneWithRows(cateList)}
|
|
|
enableEmptySections={true}
|
|
|
renderRow={this.renderRow}
|
|
|
renderSeparator={this.renderSeparator}
|
|
|
scrollsToTop={false}
|
|
|
/>
|
|
|
<ListView
|
|
|
style={[styles.subContentContainer, {marginLeft: this.state.offsetx}]}
|
|
|
dataSource={this.dataSource.cloneWithRows(subCateList)}
|
|
|
enableEmptySections={true}
|
|
|
renderRow={this.subRenderRow}
|
|
|
renderSeparator={this.renderSeparator}
|
|
|
scrollsToTop={false}
|
|
|
/>
|
|
|
|
|
|
</View>
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -62,26 +119,55 @@ export default class CategoryList extends Component { |
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
container: {
|
|
|
flex: 1,
|
|
|
flexDirection: 'row',
|
|
|
position: 'absolute',
|
|
|
top: 37,
|
|
|
left: 0,
|
|
|
width: width,
|
|
|
height: height - 37,
|
|
|
backgroundColor: 'white',
|
|
|
},
|
|
|
contentContainer: {
|
|
|
backgroundColor: '#f4f4f4',
|
|
|
width: width,
|
|
|
},
|
|
|
subContentContainer: {
|
|
|
// position: 'absolute',
|
|
|
backgroundColor: '#e0e0e0',
|
|
|
width: width/2,
|
|
|
height: height - 37,
|
|
|
|
|
|
},
|
|
|
row: {
|
|
|
justifyContent: 'center',
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
height: 50,
|
|
|
width: width,
|
|
|
paddingLeft: 15,
|
|
|
backgroundColor: '#f4f4f4',
|
|
|
},
|
|
|
subRow: {
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
height: 40,
|
|
|
width: width,
|
|
|
paddingLeft: 15,
|
|
|
backgroundColor: '#e0e0e0',
|
|
|
},
|
|
|
separator: {
|
|
|
width: width,
|
|
|
top: -2,
|
|
|
height: 1,
|
|
|
backgroundColor: '#e5e5e5',
|
|
|
},
|
|
|
title: {
|
|
|
flex: 1,
|
|
|
fontSize: 17,
|
|
|
color: '#444444',
|
|
|
},
|
|
|
arrow: {
|
|
|
marginRight: 8,
|
|
|
width: 12,
|
|
|
height: 12,
|
|
|
},
|
|
|
}); |
...
|
...
|
|