|
|
'use strict';
|
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
import {Dimensions, ListView, StyleSheet, Text, View, TouchableOpacity, Image} from 'react-native';
|
|
|
import {Dimensions, ListView, StyleSheet, Text, View, TouchableOpacity, Image, SectionList} from 'react-native';
|
|
|
|
|
|
import {Immutable, default as Immutables} from 'immutable';
|
|
|
import GuideModal from "./GuideModal";
|
...
|
...
|
@@ -34,8 +34,8 @@ export default class Home extends Component { |
|
|
});
|
|
|
}
|
|
|
|
|
|
_renderSectionHeader(sectionData, sectionID) {
|
|
|
switch (sectionID) {
|
|
|
_renderSectionHeader({ section: { title } }) {
|
|
|
switch (title) {
|
|
|
case 'categoryList': {
|
|
|
let { productList } = this.props.data;
|
|
|
let selectedCategoryIndex = productList.selectedCategoryIndex;
|
...
|
...
|
@@ -55,11 +55,14 @@ export default class Home extends Component { |
|
|
}
|
|
|
}
|
|
|
|
|
|
_renderRow(rowData, sectionID, rowID) {
|
|
|
_renderRow(item) {
|
|
|
let rowID = item.index;
|
|
|
let rowData = item.item;
|
|
|
|
|
|
let paddingLeft = rowID % 2 === 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
|
|
|
let customStyle = rowID === 0 || rowID === 1 ? {paddingLeft} : {paddingLeft};
|
|
|
|
|
|
switch (sectionID) {
|
|
|
switch (item.section.title) {
|
|
|
case 'resourceList': {
|
|
|
return this._floorCellRender(rowData, rowID);
|
|
|
}
|
...
|
...
|
@@ -75,7 +78,7 @@ export default class Home extends Component { |
|
|
)
|
|
|
}
|
|
|
|
|
|
case 'productList': {
|
|
|
case 'categoryList': {
|
|
|
return (
|
|
|
<ProductCell
|
|
|
style={[styles.listContainer, customStyle]}
|
...
|
...
|
@@ -159,11 +162,10 @@ export default class Home extends Component { |
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
let dataSource = {
|
|
|
resourceList: resourceInfo.resourceList ? resourceInfo.resourceList.toArray() : [],
|
|
|
categoryList: data.productList.msort_list ? ['1'] : [],
|
|
|
productList: data.productList.product_list ? data.productList.product_list.toArray() : [],
|
|
|
};
|
|
|
let dataSource = [
|
|
|
{title: 'resourceList', data: resourceInfo.resourceList ? resourceInfo.resourceList.toArray() : []},
|
|
|
{title: 'categoryList', data: data.productList.product_list ? data.productList.product_list.toArray() : []},
|
|
|
];
|
|
|
let productList = data.productList.product_list ? data.productList.product_list.toArray() : [];
|
|
|
|
|
|
return (
|
...
|
...
|
@@ -171,16 +173,15 @@ export default class Home extends Component { |
|
|
<GuideModal
|
|
|
isShowGuide={this.props.isShowGuide}
|
|
|
hiddenGuideDialog={this.props.hiddenGuideDialog}/>
|
|
|
<ListView
|
|
|
<SectionList
|
|
|
ref={(c) => {
|
|
|
this.listView = c;
|
|
|
}}
|
|
|
sections={dataSource}
|
|
|
renderSectionHeader={this._renderSectionHeader}
|
|
|
yh_viewVisible={true}
|
|
|
contentContainerStyle={styles.contentContainer}
|
|
|
enableEmptySections={true}
|
|
|
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
|
|
|
renderRow={this._renderRow}
|
|
|
renderItem={this._renderRow}
|
|
|
onEndReached={() => {
|
|
|
if (productList && productList.size !== 0) {
|
|
|
this.props.onEndReached && this.props.onEndReached();
|
...
|
...
|
|