|
|
'use strict';
|
|
|
|
|
|
import React from 'react';
|
|
|
import ReactNative from 'react-native';
|
|
|
|
|
|
const {
|
|
|
AppRegistry,
|
|
|
StyleSheet,
|
|
|
Text,
|
|
|
View,
|
|
|
Image,
|
|
|
ListView,
|
|
|
Dimensions,
|
|
|
TouchableOpacity,
|
|
|
} = ReactNative;
|
|
|
|
|
|
import NewArrivalFilter from './NewArrivalFilter';
|
|
|
import immutable from 'immutable';
|
|
|
|
|
|
export default class ProductCategoryList extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
|
|
|
this.leftRenderRow = this.leftRenderRow.bind(this);
|
|
|
this.rightRenderRow = this.rightRenderRow.bind(this);
|
|
|
this._pressLeftRow = this._pressLeftRow.bind(this);
|
|
|
this._pressRightRow = this._pressRightRow.bind(this);
|
|
|
|
|
|
this.dataSourceL = new ListView.DataSource({rowHasChanged: (r1, r2) => !immutable.is(r1, r2)});
|
|
|
this.dataSourceR = new ListView.DataSource({rowHasChanged: (r1, r2) => !immutable.is(r1, r2)});
|
|
|
}
|
|
|
|
|
|
_pressLeftRow(rowData) {
|
|
|
this.refs.subCategoryList && this.refs.subCategoryList.scrollTo({x: 0, y: 0, animated: false});
|
|
|
this.props.onPressProductFilterLeftItem(rowData);
|
|
|
}
|
|
|
|
|
|
_pressRightRow(rowData) {
|
|
|
let items = this.props.categoryFilterList.toJS().filter((item) => {
|
|
|
return item.isSelect;
|
|
|
});
|
|
|
|
|
|
if (items.length > 0) {
|
|
|
this.props.onPressProductFilterRightItem(items[0], rowData);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
leftRenderRow(rowData, sectionID, rowID, highlightRow) {
|
|
|
let selectText = this.props.filterNameFactors.get(rowData.get('key'));
|
|
|
let arrow = rowData.get('isSelect') ? <Image style={styles.arrow} source={require('../../image/filter_category_select_icon.png')}/> : null;
|
|
|
|
|
|
return (
|
|
|
<TouchableOpacity onPress={() => this._pressLeftRow(rowData.toJS())}>
|
|
|
<View style={[styles.leftRow]} >
|
|
|
|
|
|
<View style={styles.leftRowText} >
|
|
|
<Text style={styles.title} numberOfLines={1}>
|
|
|
{rowData.get('name')}:{" " + selectText}
|
|
|
</Text>
|
|
|
{arrow}
|
|
|
</View>
|
|
|
<View style={[styles.underline]}></View>
|
|
|
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
rightRenderRow(rowData, sectionID, rowID, highlightRow) {
|
|
|
|
|
|
let colorStyle = rowData.get('isSelect') ? {backgroundColor: '#DBDBDB'} : {backgroundColor: '#f4f4f4'};
|
|
|
return (
|
|
|
<TouchableOpacity onPress={() => this._pressRightRow(rowData.toJS())}>
|
|
|
<View style={[styles.rightRow, colorStyle]}>
|
|
|
<Text style={styles.subtitle} numberOfLines={1}>
|
|
|
{rowData.get('name')}
|
|
|
</Text>
|
|
|
<View style={[styles.underline]}></View>
|
|
|
|
|
|
</View>
|
|
|
</TouchableOpacity>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let {categoryFilterList, filterCategoryDetailFilterList, filterNameFactors} = this.props;
|
|
|
let subList = [];
|
|
|
|
|
|
let items = categoryFilterList.toJS().filter((item) => {
|
|
|
return item.isSelect;
|
|
|
});
|
|
|
|
|
|
if (items.length > 0) {
|
|
|
subList = filterCategoryDetailFilterList.get(items[0].key);
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
<View style={styles.allcontainer}>
|
|
|
<NewArrivalFilter
|
|
|
onPressFilter={this.props.onPressFilter}
|
|
|
lastSelected={this.props.productList.isFilter}
|
|
|
moreFilter={this.props.productList.isMoreFilter}
|
|
|
selectOrder={this.props.productList.order}/>
|
|
|
|
|
|
<View style={styles.container}>
|
|
|
<ListView
|
|
|
style={styles.leftContentContainer}
|
|
|
dataSource={this.dataSourceL.cloneWithRows(categoryFilterList.toArray())}
|
|
|
renderRow={this.leftRenderRow}
|
|
|
scrollsToTop={false}
|
|
|
/>
|
|
|
<ListView
|
|
|
ref='subCategoryList'
|
|
|
style={styles.rightContentContainer}
|
|
|
dataSource={this.dataSourceR.cloneWithRows(subList.toArray())}
|
|
|
renderRow={this.rightRenderRow}
|
|
|
scrollsToTop={false}
|
|
|
/>
|
|
|
</View>
|
|
|
</View>
|
|
|
);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let {width, height} = Dimensions.get('window');
|
|
|
let rowHeight = Math.ceil(height - 37);
|
|
|
let rowWidth = Math.ceil(width / 2);
|
|
|
|
|
|
let styles = StyleSheet.create({
|
|
|
allcontainer:{
|
|
|
flex: 1,
|
|
|
flexDirection: 'column',
|
|
|
left: 0,
|
|
|
width: width,
|
|
|
height: height ,
|
|
|
backgroundColor: '#ffffff',
|
|
|
borderTopColor: '#e0e0e0',
|
|
|
borderTopWidth: 0.5,
|
|
|
borderLeftColor: '#ffffff',
|
|
|
borderLeftWidth: 0,
|
|
|
borderRightWidth: 0,
|
|
|
borderBottomWidth: 0,
|
|
|
|
|
|
},
|
|
|
container:{
|
|
|
flex: 1,
|
|
|
flexDirection: 'row',
|
|
|
position: 'absolute',
|
|
|
left: 0,
|
|
|
width: width,
|
|
|
height: height - 40 - 44 - 64,
|
|
|
backgroundColor: '#ffffff',
|
|
|
borderTopWidth: 0,
|
|
|
borderLeftWidth: 0,
|
|
|
borderRightWidth: 0,
|
|
|
borderBottomWidth: 0,
|
|
|
},
|
|
|
leftContentContainer: {
|
|
|
backgroundColor: '#ffffff',
|
|
|
},
|
|
|
leftRow: {
|
|
|
justifyContent: 'center',
|
|
|
height: 44,
|
|
|
width: rowWidth,
|
|
|
paddingLeft: 15,
|
|
|
backgroundColor: '#ffffff',
|
|
|
},
|
|
|
leftRowText: {
|
|
|
flexDirection: 'row',
|
|
|
alignItems: 'center',
|
|
|
height: 43.5,
|
|
|
width: rowWidth,
|
|
|
},
|
|
|
rightContentContainer: {
|
|
|
backgroundColor: '#f4f4f4',
|
|
|
},
|
|
|
rightRow: {
|
|
|
flexDirection: 'column',
|
|
|
justifyContent: 'center',
|
|
|
height: 44,
|
|
|
width: rowWidth,
|
|
|
paddingLeft: 15,
|
|
|
},
|
|
|
underline:{
|
|
|
width: rowWidth,
|
|
|
height: 0.5,
|
|
|
backgroundColor:'#e0e0e0',
|
|
|
position: 'absolute',
|
|
|
bottom: 0,
|
|
|
|
|
|
},
|
|
|
title: {
|
|
|
fontSize: 14,
|
|
|
color: '#444444',
|
|
|
width: rowWidth - 15 - 6,
|
|
|
},
|
|
|
subtitle: {
|
|
|
fontSize: 14,
|
|
|
color: '#b0b0b0',
|
|
|
},
|
|
|
arrow: {
|
|
|
justifyContent: 'flex-end',
|
|
|
alignItems: 'center',
|
|
|
width: 6,
|
|
|
height: 12,
|
|
|
},
|
|
|
}); |
...
|
...
|
|