1
|
'use strict';
|
1
|
'use strict';
|
2
|
|
2
|
|
3
|
import React, {Component} from 'react';
|
3
|
import React, {Component} from 'react';
|
4
|
-import {Dimensions, ListView, StyleSheet, Text, View, TouchableOpacity, Image} from 'react-native';
|
4
|
+import {Dimensions, ListView, StyleSheet, Text, View, TouchableOpacity, Image, SectionList} from 'react-native';
|
5
|
|
5
|
|
6
|
import {Immutable, default as Immutables} from 'immutable';
|
6
|
import {Immutable, default as Immutables} from 'immutable';
|
7
|
import GuideModal from "./GuideModal";
|
7
|
import GuideModal from "./GuideModal";
|
|
@@ -34,8 +34,8 @@ export default class Home extends Component { |
|
@@ -34,8 +34,8 @@ export default class Home extends Component { |
34
|
});
|
34
|
});
|
35
|
}
|
35
|
}
|
36
|
|
36
|
|
37
|
- _renderSectionHeader(sectionData, sectionID) {
|
|
|
38
|
- switch (sectionID) {
|
37
|
+ _renderSectionHeader({ section: { title } }) {
|
|
|
38
|
+ switch (title) {
|
39
|
case 'categoryList': {
|
39
|
case 'categoryList': {
|
40
|
let { productList } = this.props.data;
|
40
|
let { productList } = this.props.data;
|
41
|
let selectedCategoryIndex = productList.selectedCategoryIndex;
|
41
|
let selectedCategoryIndex = productList.selectedCategoryIndex;
|
|
@@ -55,11 +55,14 @@ export default class Home extends Component { |
|
@@ -55,11 +55,14 @@ export default class Home extends Component { |
55
|
}
|
55
|
}
|
56
|
}
|
56
|
}
|
57
|
|
57
|
|
58
|
- _renderRow(rowData, sectionID, rowID) {
|
58
|
+ _renderRow(item) {
|
|
|
59
|
+ let rowID = item.index;
|
|
|
60
|
+ let rowData = item.item;
|
|
|
61
|
+
|
59
|
let paddingLeft = rowID % 2 === 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
|
62
|
let paddingLeft = rowID % 2 === 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
|
60
|
let customStyle = rowID === 0 || rowID === 1 ? {paddingLeft} : {paddingLeft};
|
63
|
let customStyle = rowID === 0 || rowID === 1 ? {paddingLeft} : {paddingLeft};
|
61
|
|
64
|
|
62
|
- switch (sectionID) {
|
65
|
+ switch (item.section.title) {
|
63
|
case 'resourceList': {
|
66
|
case 'resourceList': {
|
64
|
return this._floorCellRender(rowData, rowID);
|
67
|
return this._floorCellRender(rowData, rowID);
|
65
|
}
|
68
|
}
|
|
@@ -75,7 +78,7 @@ export default class Home extends Component { |
|
@@ -75,7 +78,7 @@ export default class Home extends Component { |
75
|
)
|
78
|
)
|
76
|
}
|
79
|
}
|
77
|
|
80
|
|
78
|
- case 'productList': {
|
81
|
+ case 'categoryList': {
|
79
|
return (
|
82
|
return (
|
80
|
<ProductCell
|
83
|
<ProductCell
|
81
|
style={[styles.listContainer, customStyle]}
|
84
|
style={[styles.listContainer, customStyle]}
|
|
@@ -159,11 +162,10 @@ export default class Home extends Component { |
|
@@ -159,11 +162,10 @@ export default class Home extends Component { |
159
|
} = this.props;
|
162
|
} = this.props;
|
160
|
|
163
|
|
161
|
|
164
|
|
162
|
- let dataSource = {
|
|
|
163
|
- resourceList: resourceInfo.resourceList ? resourceInfo.resourceList.toArray() : [],
|
|
|
164
|
- categoryList: data.productList.msort_list ? ['1'] : [],
|
|
|
165
|
- productList: data.productList.product_list ? data.productList.product_list.toArray() : [],
|
|
|
166
|
- };
|
165
|
+ let dataSource = [
|
|
|
166
|
+ {title: 'resourceList', data: resourceInfo.resourceList ? resourceInfo.resourceList.toArray() : []},
|
|
|
167
|
+ {title: 'categoryList', data: data.productList.product_list ? data.productList.product_list.toArray() : []},
|
|
|
168
|
+ ];
|
167
|
let productList = data.productList.product_list ? data.productList.product_list.toArray() : [];
|
169
|
let productList = data.productList.product_list ? data.productList.product_list.toArray() : [];
|
168
|
|
170
|
|
169
|
return (
|
171
|
return (
|
|
@@ -171,16 +173,15 @@ export default class Home extends Component { |
|
@@ -171,16 +173,15 @@ export default class Home extends Component { |
171
|
<GuideModal
|
173
|
<GuideModal
|
172
|
isShowGuide={this.props.isShowGuide}
|
174
|
isShowGuide={this.props.isShowGuide}
|
173
|
hiddenGuideDialog={this.props.hiddenGuideDialog}/>
|
175
|
hiddenGuideDialog={this.props.hiddenGuideDialog}/>
|
174
|
- <ListView
|
176
|
+ <SectionList
|
175
|
ref={(c) => {
|
177
|
ref={(c) => {
|
176
|
this.listView = c;
|
178
|
this.listView = c;
|
177
|
}}
|
179
|
}}
|
|
|
180
|
+ sections={dataSource}
|
178
|
renderSectionHeader={this._renderSectionHeader}
|
181
|
renderSectionHeader={this._renderSectionHeader}
|
179
|
yh_viewVisible={true}
|
182
|
yh_viewVisible={true}
|
180
|
contentContainerStyle={styles.contentContainer}
|
183
|
contentContainerStyle={styles.contentContainer}
|
181
|
- enableEmptySections={true}
|
|
|
182
|
- dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
183
|
- renderRow={this._renderRow}
|
184
|
+ renderItem={this._renderRow}
|
184
|
onEndReached={() => {
|
185
|
onEndReached={() => {
|
185
|
if (productList && productList.size !== 0) {
|
186
|
if (productList && productList.size !== 0) {
|
186
|
this.props.onEndReached && this.props.onEndReached();
|
187
|
this.props.onEndReached && this.props.onEndReached();
|