|
@@ -9,6 +9,7 @@ import ReactNative, { |
|
@@ -9,6 +9,7 @@ import ReactNative, { |
9
|
StyleSheet,
|
9
|
StyleSheet,
|
10
|
Dimensions,
|
10
|
Dimensions,
|
11
|
TouchableOpacity,
|
11
|
TouchableOpacity,
|
|
|
12
|
+ TouchableHighlight,
|
12
|
InteractionManager,
|
13
|
InteractionManager,
|
13
|
Platform,
|
14
|
Platform,
|
14
|
} from 'react-native';
|
15
|
} from 'react-native';
|
|
@@ -32,12 +33,8 @@ export default class NewArrival extends Component { |
|
@@ -32,12 +33,8 @@ export default class NewArrival extends Component { |
32
|
super(props);
|
33
|
super(props);
|
33
|
|
34
|
|
34
|
this._renderRow = this._renderRow.bind(this);
|
35
|
this._renderRow = this._renderRow.bind(this);
|
35
|
- this.trigggePullToRefresh = this.trigggePullToRefresh.bind(this);
|
|
|
36
|
this._renderSectionHeader = this._renderSectionHeader.bind(this);
|
36
|
this._renderSectionHeader = this._renderSectionHeader.bind(this);
|
37
|
this._onPressProductFilter = this._onPressProductFilter.bind(this);
|
37
|
this._onPressProductFilter = this._onPressProductFilter.bind(this);
|
38
|
- this._onChangeVisibleRows = this._onChangeVisibleRows.bind(this);
|
|
|
39
|
- this._onMomentumScrollBegin = this._onMomentumScrollBegin.bind(this);
|
|
|
40
|
- this._onMomentumScrollEnd = this._onMomentumScrollEnd.bind(this);
|
|
|
41
|
|
38
|
|
42
|
this.dataSource = new ListView.DataSource({
|
39
|
this.dataSource = new ListView.DataSource({
|
43
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
40
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
@@ -46,26 +43,11 @@ export default class NewArrival extends Component { |
|
@@ -46,26 +43,11 @@ export default class NewArrival extends Component { |
46
|
|
43
|
|
47
|
this.state = {
|
44
|
this.state = {
|
48
|
showBackToTopButton: false,
|
45
|
showBackToTopButton: false,
|
49
|
- selectedVisibleIndex: -1,
|
|
|
50
|
- scrollEnd: false,
|
|
|
51
|
}
|
46
|
}
|
52
|
}
|
47
|
}
|
53
|
|
48
|
|
54
|
componentDidMount() {
|
49
|
componentDidMount() {
|
55
|
- }
|
|
|
56
|
-
|
|
|
57
|
- componentWillReceiveProps(nextProps) {
|
|
|
58
|
-
|
|
|
59
|
- }
|
|
|
60
|
|
50
|
|
61
|
- trigggePullToRefresh() {
|
|
|
62
|
- if (Platform.OS === 'ios') {
|
|
|
63
|
- InteractionManager.runAfterInteractions(() => {
|
|
|
64
|
- this.listView && this.listView.getScrollResponder().startPullToRefresh();
|
|
|
65
|
- });
|
|
|
66
|
- } else {
|
|
|
67
|
- this.props.onRefresh && this.props.onRefresh();
|
|
|
68
|
- }
|
|
|
69
|
}
|
51
|
}
|
70
|
|
52
|
|
71
|
_onPressProductFilter(value){
|
53
|
_onPressProductFilter(value){
|
|
@@ -256,10 +238,7 @@ export default class NewArrival extends Component { |
|
@@ -256,10 +238,7 @@ export default class NewArrival extends Component { |
256
|
productList,
|
238
|
productList,
|
257
|
} = this.props;
|
239
|
} = this.props;
|
258
|
let similarIndex = productList.get('similarIndex');
|
240
|
let similarIndex = productList.get('similarIndex');
|
259
|
- let showSimilarGuider = this.props.showSimilarGuider
|
|
|
260
|
- && this.state.scrollEnd
|
|
|
261
|
- && rowID == this.state.selectedVisibleIndex
|
|
|
262
|
- && rowID != similarIndex;
|
241
|
+
|
263
|
return (
|
242
|
return (
|
264
|
<BrandProductListCell
|
243
|
<BrandProductListCell
|
265
|
style={[styles.listContainer, customStyle]}
|
244
|
style={[styles.listContainer, customStyle]}
|
|
@@ -270,7 +249,6 @@ export default class NewArrival extends Component { |
|
@@ -270,7 +249,6 @@ export default class NewArrival extends Component { |
270
|
onPressProduct={this.props.onPressProductListProduct}
|
249
|
onPressProduct={this.props.onPressProductListProduct}
|
271
|
onLongPressProduct={this.props.onLongPressProduct}
|
250
|
onLongPressProduct={this.props.onLongPressProduct}
|
272
|
onPressFindSimilar={this.props.onPressFindSimilar}
|
251
|
onPressFindSimilar={this.props.onPressFindSimilar}
|
273
|
- showSimilarGuider={showSimilarGuider}
|
|
|
274
|
/>
|
252
|
/>
|
275
|
);
|
253
|
);
|
276
|
}
|
254
|
}
|
|
@@ -325,37 +303,6 @@ export default class NewArrival extends Component { |
|
@@ -325,37 +303,6 @@ export default class NewArrival extends Component { |
325
|
return null;
|
303
|
return null;
|
326
|
}
|
304
|
}
|
327
|
|
305
|
|
328
|
- _onChangeVisibleRows(visibleRows, changedRows) {
|
|
|
329
|
- if (Object.keys(visibleRows).length == 0) {
|
|
|
330
|
- return;
|
|
|
331
|
- }
|
|
|
332
|
-
|
|
|
333
|
- let selectedIndex = -1;
|
|
|
334
|
- let sectionIDs = Object.keys(visibleRows);
|
|
|
335
|
- let targetSection = 'latest';
|
|
|
336
|
- if (!sectionIDs.includes(targetSection)) {
|
|
|
337
|
- return;
|
|
|
338
|
- }
|
|
|
339
|
-
|
|
|
340
|
- let rowIndexs = Object.keys(visibleRows[targetSection]);
|
|
|
341
|
- if (rowIndexs.length > 0) {
|
|
|
342
|
- selectedIndex = rowIndexs[0];
|
|
|
343
|
- }
|
|
|
344
|
- if (rowIndexs.length > 3) {
|
|
|
345
|
- selectedIndex = rowIndexs[2];
|
|
|
346
|
- }
|
|
|
347
|
-
|
|
|
348
|
- this.setState({selectedVisibleIndex: selectedIndex});
|
|
|
349
|
- }
|
|
|
350
|
-
|
|
|
351
|
- _onMomentumScrollBegin(event) {
|
|
|
352
|
- this.setState({scrollEnd: false});
|
|
|
353
|
- }
|
|
|
354
|
-
|
|
|
355
|
- _onMomentumScrollEnd(event) {
|
|
|
356
|
- this.setState({scrollEnd: true});
|
|
|
357
|
- }
|
|
|
358
|
-
|
|
|
359
|
render() {
|
306
|
render() {
|
360
|
|
307
|
|
361
|
let {
|
308
|
let {
|
|
@@ -396,7 +343,6 @@ export default class NewArrival extends Component { |
|
@@ -396,7 +343,6 @@ export default class NewArrival extends Component { |
396
|
renderRow={this._renderRow}
|
343
|
renderRow={this._renderRow}
|
397
|
enableEmptySections={true}
|
344
|
enableEmptySections={true}
|
398
|
renderSectionHeader={this._renderSectionHeader}
|
345
|
renderSectionHeader={this._renderSectionHeader}
|
399
|
- removeClippedSubviews={true}
|
|
|
400
|
renderFooter={()=>{
|
346
|
renderFooter={()=>{
|
401
|
if (endReached) {
|
347
|
if (endReached) {
|
402
|
return <View style={styles.placeholder} />;
|
348
|
return <View style={styles.placeholder} />;
|
|
@@ -422,6 +368,7 @@ export default class NewArrival extends Component { |
|
@@ -422,6 +368,7 @@ export default class NewArrival extends Component { |
422
|
this.setState({showBackToTopButton: true});
|
368
|
this.setState({showBackToTopButton: true});
|
423
|
}
|
369
|
}
|
424
|
}}
|
370
|
}}
|
|
|
371
|
+ onEndReachedThreshold={2000}
|
425
|
/>
|
372
|
/>
|
426
|
{productList.isFilter ?
|
373
|
{productList.isFilter ?
|
427
|
<NewArrivalCategoryList
|
374
|
<NewArrivalCategoryList
|
|
@@ -443,14 +390,21 @@ export default class NewArrival extends Component { |
|
@@ -443,14 +390,21 @@ export default class NewArrival extends Component { |
443
|
onPressCloseMoreFilter={this.props.onPressCloseMoreFilter}
|
390
|
onPressCloseMoreFilter={this.props.onPressCloseMoreFilter}
|
444
|
onPressMoreFilter={this.props.onPressMoreFilter}/> : null}
|
391
|
onPressMoreFilter={this.props.onPressMoreFilter}/> : null}
|
445
|
{this.state.showBackToTopButton?
|
392
|
{this.state.showBackToTopButton?
|
446
|
- <TouchableOpacity
|
|
|
447
|
- style={styles.backToTopButton}
|
|
|
448
|
- onPress={()=>{
|
|
|
449
|
- this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
|
|
|
450
|
- this.setState({showBackToTopButton: false});
|
|
|
451
|
- }}>
|
393
|
+ <TouchableHighlight
|
|
|
394
|
+ style={styles.backToTopButton}
|
|
|
395
|
+ activeOpacity={1}
|
|
|
396
|
+ delayLongPress={1000000}
|
|
|
397
|
+ onPress={() =>{
|
|
|
398
|
+ this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
|
|
|
399
|
+ this.setState({showBackToTopButton: false});
|
|
|
400
|
+ }}
|
|
|
401
|
+ onLongPress={() =>{
|
|
|
402
|
+ this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
|
|
|
403
|
+ this.setState({showBackToTopButton: false});
|
|
|
404
|
+ }}
|
|
|
405
|
+ >
|
452
|
<Image style={{flex:1}} source={require('../../image/backtop.png')}/>
|
406
|
<Image style={{flex:1}} source={require('../../image/backtop.png')}/>
|
453
|
- </TouchableOpacity>: null
|
407
|
+ </TouchableHighlight>: null
|
454
|
}
|
408
|
}
|
455
|
|
409
|
|
456
|
<LoadingIndicator
|
410
|
<LoadingIndicator
|