|
@@ -3,7 +3,8 @@ |
|
@@ -3,7 +3,8 @@ |
3
|
|
3
|
|
4
|
import React, {Component} from 'react';
|
4
|
import React, {Component} from 'react';
|
5
|
import ScreenSubCell from '../cell/ScreenSubCell';
|
5
|
import ScreenSubCell from '../cell/ScreenSubCell';
|
6
|
-
|
6
|
+import Immutable, {Map} from 'immutable';
|
|
|
7
|
+import IndexListView from '../../../classify/components/brand/IndexListView'
|
7
|
import ReactNative, {
|
8
|
import ReactNative, {
|
8
|
View,
|
9
|
View,
|
9
|
Text,
|
10
|
Text,
|
|
@@ -20,18 +21,33 @@ export default class ScreenSub extends Component { |
|
@@ -20,18 +21,33 @@ export default class ScreenSub extends Component { |
20
|
|
21
|
|
21
|
constructor(props) {
|
22
|
constructor(props) {
|
22
|
super(props);
|
23
|
super(props);
|
23
|
-
|
24
|
+ this.scrollToSection = this.scrollToSection.bind(this);
|
24
|
this.renderRow = this.renderRow.bind(this);
|
25
|
this.renderRow = this.renderRow.bind(this);
|
|
|
26
|
+ this.renderSectionHeader = this.renderSectionHeader.bind(this);
|
25
|
this.dataSource = new ListView.DataSource({
|
27
|
this.dataSource = new ListView.DataSource({
|
26
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
28
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
|
|
29
|
+ sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
|
27
|
});
|
30
|
});
|
28
|
|
31
|
|
29
|
}
|
32
|
}
|
30
|
|
33
|
|
|
|
34
|
+ scrollToSection(index,sectionID){
|
|
|
35
|
+ console.log(sectionID);
|
|
|
36
|
+ }
|
|
|
37
|
+
|
|
|
38
|
+ renderSectionHeader(sectionData, sectionID) {
|
|
|
39
|
+ return(
|
|
|
40
|
+ <View style={styles.Header}>
|
|
|
41
|
+ <Text style={styles.HeaderText}>{sectionID}</Text>
|
|
|
42
|
+ </View>
|
|
|
43
|
+ );
|
|
|
44
|
+ }
|
|
|
45
|
+
|
31
|
renderRow(rowData,sectionID,rowID,highlightRow) {
|
46
|
renderRow(rowData,sectionID,rowID,highlightRow) {
|
32
|
let {resource} = this.props;
|
47
|
let {resource} = this.props;
|
33
|
let obj = resource&&resource.get('filterSub')?resource.get('filterSub'):null;
|
48
|
let obj = resource&&resource.get('filterSub')?resource.get('filterSub'):null;
|
34
|
let key = obj?obj.get('key'):null;
|
49
|
let key = obj?obj.get('key'):null;
|
|
|
50
|
+
|
35
|
return(
|
51
|
return(
|
36
|
<ScreenSubCell resource={rowData} keys={key} selectItem={this.props.selectItem}/>
|
52
|
<ScreenSubCell resource={rowData} keys={key} selectItem={this.props.selectItem}/>
|
37
|
);
|
53
|
);
|
|
@@ -40,19 +56,42 @@ export default class ScreenSub extends Component { |
|
@@ -40,19 +56,42 @@ export default class ScreenSub extends Component { |
40
|
|
56
|
|
41
|
render() {
|
57
|
render() {
|
42
|
let {resource} = this.props;
|
58
|
let {resource} = this.props;
|
|
|
59
|
+
|
43
|
let obj = resource&&resource.get('filterSub')?resource.get('filterSub'):null;
|
60
|
let obj = resource&&resource.get('filterSub')?resource.get('filterSub'):null;
|
|
|
61
|
+ let key = obj?obj.get('key'):null;
|
44
|
let list = obj?obj.get('list'):null;
|
62
|
let list = obj?obj.get('list'):null;
|
|
|
63
|
+ if (key == 'brand') {
|
|
|
64
|
+ let dataSourceList = list?list.toJS():{};
|
|
|
65
|
+ let keyList = list.keySeq()?list.keySeq().toJS():[];
|
|
|
66
|
+ keyList.shift();
|
|
|
67
|
+ keyList = Immutable.fromJS(keyList);
|
|
|
68
|
+ return (
|
|
|
69
|
+ <View style={styles.container}>
|
|
|
70
|
+ <ListView
|
|
|
71
|
+ ref='brandList'
|
|
|
72
|
+ contentContainerStyle={styles.contentContainer}
|
|
|
73
|
+ enableEmptySections={true}
|
|
|
74
|
+ dataSource={this.dataSource.cloneWithRowsAndSections(dataSourceList)}
|
|
|
75
|
+ renderRow={this.renderRow}
|
|
|
76
|
+ renderSectionHeader={this.renderSectionHeader}
|
|
|
77
|
+ />
|
|
|
78
|
+ <IndexListView dataSource={keyList.toArray()} onLetterPress={this.scrollToSection}/>
|
|
|
79
|
+ </View>
|
|
|
80
|
+ );
|
|
|
81
|
+ }else {
|
|
|
82
|
+ let dataSourceList = list?list.toJS():[];
|
45
|
return (
|
83
|
return (
|
46
|
<View style={styles.container}>
|
84
|
<View style={styles.container}>
|
47
|
{list?<ListView
|
85
|
{list?<ListView
|
48
|
ref='ScreenSubList'
|
86
|
ref='ScreenSubList'
|
49
|
enableEmptySections={true}
|
87
|
enableEmptySections={true}
|
50
|
- dataSource={this.dataSource.cloneWithRows(list.toArray())}
|
88
|
+ dataSource={this.dataSource.cloneWithRows(dataSourceList)}
|
51
|
renderRow={this.renderRow}
|
89
|
renderRow={this.renderRow}
|
52
|
/>:null}
|
90
|
/>:null}
|
53
|
</View>
|
91
|
</View>
|
54
|
);
|
92
|
);
|
55
|
}
|
93
|
}
|
|
|
94
|
+ }
|
56
|
}
|
95
|
}
|
57
|
|
96
|
|
58
|
let {width, height} = Dimensions.get('window');
|
97
|
let {width, height} = Dimensions.get('window');
|
|
@@ -61,4 +100,15 @@ let styles = StyleSheet.create({ |
|
@@ -61,4 +100,15 @@ let styles = StyleSheet.create({ |
61
|
flex: 1,
|
100
|
flex: 1,
|
62
|
backgroundColor: '#f4f4f4',
|
101
|
backgroundColor: '#f4f4f4',
|
63
|
},
|
102
|
},
|
|
|
103
|
+ HeaderText: {
|
|
|
104
|
+ marginLeft: 10,
|
|
|
105
|
+ fontSize: 18,
|
|
|
106
|
+ fontWeight: 'bold',
|
|
|
107
|
+ color: 'rgb(146, 146, 146)'
|
|
|
108
|
+ },
|
|
|
109
|
+ Header: {
|
|
|
110
|
+ justifyContent: 'center',
|
|
|
111
|
+ width: width,
|
|
|
112
|
+ height: 30,
|
|
|
113
|
+ }
|
64
|
}); |
114
|
}); |