...
|
...
|
@@ -37,19 +37,11 @@ export default class BrandStore extends Component { |
|
|
this.renderRow = this.renderRow.bind(this);
|
|
|
this._onPressProductFilter = this._onPressProductFilter.bind(this);
|
|
|
this._onPressStoreFilter = this._onPressStoreFilter.bind(this);
|
|
|
this._onChangeVisibleRows = this._onChangeVisibleRows.bind(this);
|
|
|
this._onMomentumScrollBegin = this._onMomentumScrollBegin.bind(this);
|
|
|
this._onMomentumScrollEnd = this._onMomentumScrollEnd.bind(this);
|
|
|
|
|
|
this.dataSource = new ListView.DataSource({
|
|
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
|
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
|
|
|
});
|
|
|
|
|
|
this.state = {
|
|
|
selectedVisibleIndex: -1,
|
|
|
scrollEnd: false,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
componentDidUpdate() {
|
...
|
...
|
@@ -271,9 +263,6 @@ export default class BrandStore extends Component { |
|
|
resource={rowData}
|
|
|
onPressProduct={this.props.onPressFloorProduct}
|
|
|
onPressMoreProducts={this.props.onPressMoreProducts}
|
|
|
similarIndex={this.props.similarIndex}
|
|
|
onLongPressProduct={this.props.onLongPressProduct}
|
|
|
onPressFindSimilar={this.props.onPressFindSimilar}
|
|
|
/>
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -284,30 +273,19 @@ export default class BrandStore extends Component { |
|
|
} else if (sectionID == 'storeFilter') {
|
|
|
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
|
|
|
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
|
|
|
let showSimilarGuider = this.props.showSimilarGuider
|
|
|
&& this.state.scrollEnd
|
|
|
&& rowID == this.state.selectedVisibleIndex
|
|
|
&& rowID != this.props.similarIndex;
|
|
|
|
|
|
return (
|
|
|
<BrandProductListCell
|
|
|
style={[styles.listContainer, customStyle]}
|
|
|
key={'row' + rowID}
|
|
|
rowID={rowID}
|
|
|
data={rowData}
|
|
|
similarIndex={this.props.similarIndex}
|
|
|
onPressProduct={this.props.onPressProduct}
|
|
|
onLongPressProduct={this.props.onLongPressProduct}
|
|
|
onPressFindSimilar={this.props.onPressFindSimilar}
|
|
|
showSimilarGuider={showSimilarGuider}
|
|
|
/>
|
|
|
);
|
|
|
} else if (sectionID == 'productList') {
|
|
|
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
|
|
|
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
|
|
|
let showSimilarGuider = this.props.showSimilarGuider
|
|
|
&& this.state.scrollEnd
|
|
|
&& rowID == this.state.selectedVisibleIndex
|
|
|
&& rowID != this.props.similarIndex;
|
|
|
|
|
|
return (
|
|
|
<BrandProductListCell
|
...
|
...
|
@@ -316,10 +294,6 @@ export default class BrandStore extends Component { |
|
|
rowID={rowID}
|
|
|
data={rowData}
|
|
|
onPressProduct={this.props.onPressProductListProduct}
|
|
|
similarIndex={this.props.similarIndex}
|
|
|
onLongPressProduct={this.props.onLongPressProduct}
|
|
|
onPressFindSimilar={this.props.onPressFindSimilar}
|
|
|
showSimilarGuider={showSimilarGuider}
|
|
|
/>
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -327,46 +301,6 @@ export default class BrandStore extends Component { |
|
|
return null;
|
|
|
}
|
|
|
|
|
|
_onChangeVisibleRows(visibleRows, changedRows) {
|
|
|
if (Object.keys(visibleRows).length == 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let selectedIndex = -1;
|
|
|
let sectionIDs = Object.keys(visibleRows);
|
|
|
let targetSection = 'storeFilter';
|
|
|
let targetSection2 = 'productList';
|
|
|
if (sectionIDs.includes(targetSection)) {
|
|
|
let rowIndexs = Object.keys(visibleRows[targetSection]);
|
|
|
if (rowIndexs.length > 0) {
|
|
|
selectedIndex = rowIndexs[0];
|
|
|
}
|
|
|
if (rowIndexs.length > 3) {
|
|
|
selectedIndex = rowIndexs[2];
|
|
|
}
|
|
|
|
|
|
this.setState({selectedVisibleIndex: selectedIndex});
|
|
|
} else if (sectionIDs.includes(targetSection2)) {
|
|
|
let rowIndexs = Object.keys(visibleRows[targetSection2]);
|
|
|
if (rowIndexs.length > 0) {
|
|
|
selectedIndex = rowIndexs[0];
|
|
|
}
|
|
|
if (rowIndexs.length > 3) {
|
|
|
selectedIndex = rowIndexs[2];
|
|
|
}
|
|
|
|
|
|
this.setState({selectedVisibleIndex: selectedIndex});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
_onMomentumScrollBegin(event) {
|
|
|
this.setState({scrollEnd: false});
|
|
|
}
|
|
|
|
|
|
_onMomentumScrollEnd(event) {
|
|
|
this.setState({scrollEnd: true});
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
|
|
|
let {
|
...
|
...
|
|