...
|
...
|
@@ -9,6 +9,7 @@ import ReactNative, { |
|
|
StyleSheet,
|
|
|
Dimensions,
|
|
|
TouchableOpacity,
|
|
|
TouchableHighlight,
|
|
|
InteractionManager,
|
|
|
Platform,
|
|
|
} from 'react-native';
|
...
|
...
|
@@ -32,12 +33,8 @@ export default class NewArrival extends Component { |
|
|
super(props);
|
|
|
|
|
|
this._renderRow = this._renderRow.bind(this);
|
|
|
this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);
|
|
|
this._renderSectionHeader = this._renderSectionHeader.bind(this);
|
|
|
this._onPressProductFilter = this._onPressProductFilter.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),
|
...
|
...
|
@@ -46,26 +43,11 @@ export default class NewArrival extends Component { |
|
|
|
|
|
this.state = {
|
|
|
showBackToTopButton: false,
|
|
|
selectedVisibleIndex: -1,
|
|
|
scrollEnd: false,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
|
}
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
|
|
}
|
|
|
|
|
|
trigggePullToRefresh() {
|
|
|
if (Platform.OS === 'ios') {
|
|
|
InteractionManager.runAfterInteractions(() => {
|
|
|
this.listView && this.listView.getScrollResponder().startPullToRefresh();
|
|
|
});
|
|
|
} else {
|
|
|
this.props.onRefresh && this.props.onRefresh();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
_onPressProductFilter(value){
|
...
|
...
|
@@ -256,10 +238,7 @@ export default class NewArrival extends Component { |
|
|
productList,
|
|
|
} = this.props;
|
|
|
let similarIndex = productList.get('similarIndex');
|
|
|
let showSimilarGuider = this.props.showSimilarGuider
|
|
|
&& this.state.scrollEnd
|
|
|
&& rowID == this.state.selectedVisibleIndex
|
|
|
&& rowID != similarIndex;
|
|
|
|
|
|
return (
|
|
|
<BrandProductListCell
|
|
|
style={[styles.listContainer, customStyle]}
|
...
|
...
|
@@ -270,7 +249,6 @@ export default class NewArrival extends Component { |
|
|
onPressProduct={this.props.onPressProductListProduct}
|
|
|
onLongPressProduct={this.props.onLongPressProduct}
|
|
|
onPressFindSimilar={this.props.onPressFindSimilar}
|
|
|
showSimilarGuider={showSimilarGuider}
|
|
|
/>
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -325,37 +303,6 @@ export default class NewArrival extends Component { |
|
|
return null;
|
|
|
}
|
|
|
|
|
|
_onChangeVisibleRows(visibleRows, changedRows) {
|
|
|
if (Object.keys(visibleRows).length == 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let selectedIndex = -1;
|
|
|
let sectionIDs = Object.keys(visibleRows);
|
|
|
let targetSection = 'latest';
|
|
|
if (!sectionIDs.includes(targetSection)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let rowIndexs = Object.keys(visibleRows[targetSection]);
|
|
|
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 {
|
...
|
...
|
@@ -396,7 +343,6 @@ export default class NewArrival extends Component { |
|
|
renderRow={this._renderRow}
|
|
|
enableEmptySections={true}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
removeClippedSubviews={true}
|
|
|
renderFooter={()=>{
|
|
|
if (endReached) {
|
|
|
return <View style={styles.placeholder} />;
|
...
|
...
|
@@ -422,6 +368,7 @@ export default class NewArrival extends Component { |
|
|
this.setState({showBackToTopButton: true});
|
|
|
}
|
|
|
}}
|
|
|
onEndReachedThreshold={2000}
|
|
|
/>
|
|
|
{productList.isFilter ?
|
|
|
<NewArrivalCategoryList
|
...
|
...
|
@@ -443,14 +390,21 @@ export default class NewArrival extends Component { |
|
|
onPressCloseMoreFilter={this.props.onPressCloseMoreFilter}
|
|
|
onPressMoreFilter={this.props.onPressMoreFilter}/> : null}
|
|
|
{this.state.showBackToTopButton?
|
|
|
<TouchableOpacity
|
|
|
<TouchableHighlight
|
|
|
style={styles.backToTopButton}
|
|
|
onPress={()=>{
|
|
|
activeOpacity={1}
|
|
|
delayLongPress={1000000}
|
|
|
onPress={() =>{
|
|
|
this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
|
|
|
this.setState({showBackToTopButton: false});
|
|
|
}}>
|
|
|
}}
|
|
|
onLongPress={() =>{
|
|
|
this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
|
|
|
this.setState({showBackToTopButton: false});
|
|
|
}}
|
|
|
>
|
|
|
<Image style={{flex:1}} source={require('../../image/backtop.png')}/>
|
|
|
</TouchableOpacity>: null
|
|
|
</TouchableHighlight>: null
|
|
|
}
|
|
|
|
|
|
<LoadingIndicator
|
...
|
...
|
|