|
@@ -23,6 +23,7 @@ import NewHotBannerListCell from './NewHotBannerListCell'; |
|
@@ -23,6 +23,7 @@ import NewHotBannerListCell from './NewHotBannerListCell'; |
23
|
import BrandSearch from './search/BrandSearch';
|
23
|
import BrandSearch from './search/BrandSearch';
|
24
|
import LoadingIndicator from '../../../common/components/LoadingIndicator';
|
24
|
import LoadingIndicator from '../../../common/components/LoadingIndicator';
|
25
|
import IndexListView from './IndexListView';
|
25
|
import IndexListView from './IndexListView';
|
|
|
26
|
+import {ScrollToIndex} from '../../utils/Utils';
|
26
|
|
27
|
|
27
|
export default class Brand extends Component {
|
28
|
export default class Brand extends Component {
|
28
|
constructor(props) {
|
29
|
constructor(props) {
|
|
@@ -31,7 +32,8 @@ export default class Brand extends Component { |
|
@@ -31,7 +32,8 @@ export default class Brand extends Component { |
31
|
this.renderSectionHeader = this.renderSectionHeader.bind(this);
|
32
|
this.renderSectionHeader = this.renderSectionHeader.bind(this);
|
32
|
this.renderRow = this.renderRow.bind(this);
|
33
|
this.renderRow = this.renderRow.bind(this);
|
33
|
this.renderHeader = this.renderHeader.bind(this);
|
34
|
this.renderHeader = this.renderHeader.bind(this);
|
34
|
-
|
35
|
+ this.scrollToSection = this.scrollToSection.bind(this);
|
|
|
36
|
+ this.scrollData = [];
|
35
|
this.dataSource = new ListView.DataSource({
|
37
|
this.dataSource = new ListView.DataSource({
|
36
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
38
|
rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
|
37
|
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
|
39
|
sectionHeaderHasChanged: (s1, s2) => !Immutable.is(s1, s2),
|
|
@@ -47,6 +49,11 @@ export default class Brand extends Component { |
|
@@ -47,6 +49,11 @@ export default class Brand extends Component { |
47
|
|
49
|
|
48
|
}
|
50
|
}
|
49
|
|
51
|
|
|
|
52
|
+ scrollToSection(sessionID){
|
|
|
53
|
+ let newSrc = ScrollToIndex(sessionID,this.scrollData);
|
|
|
54
|
+ this.listView.scrollTo({x: 0, y:443+newSrc , animated: false});
|
|
|
55
|
+ }
|
|
|
56
|
+
|
50
|
renderHeader(){
|
57
|
renderHeader(){
|
51
|
let data = this.props.reourceForBoy;
|
58
|
let data = this.props.reourceForBoy;
|
52
|
let brandFliter = this.props.brandFliter;
|
59
|
let brandFliter = this.props.brandFliter;
|
|
@@ -146,12 +153,14 @@ export default class Brand extends Component { |
|
@@ -146,12 +153,14 @@ export default class Brand extends Component { |
146
|
let listDataSource;
|
153
|
let listDataSource;
|
147
|
let contentContainerStyle;
|
154
|
let contentContainerStyle;
|
148
|
let renderSectionHeader = null;
|
155
|
let renderSectionHeader = null;
|
|
|
156
|
+ let showIndexForListView = false;
|
149
|
|
157
|
|
150
|
if (brandFliter == 0) {
|
158
|
if (brandFliter == 0) {
|
151
|
list = data?data.all_list:null;
|
159
|
list = data?data.all_list:null;
|
152
|
listDataSource = list?this.dataSource.cloneWithRowsAndSections(list):null;
|
160
|
listDataSource = list?this.dataSource.cloneWithRowsAndSections(list):null;
|
153
|
contentContainerStyle = styles.contentContainerOne;
|
161
|
contentContainerStyle = styles.contentContainerOne;
|
154
|
renderSectionHeader = this.renderSectionHeader;
|
162
|
renderSectionHeader = this.renderSectionHeader;
|
|
|
163
|
+ showIndexForListView = true;
|
155
|
} else if (brandFliter == 1) {
|
164
|
} else if (brandFliter == 1) {
|
156
|
list = data?data.new_list:null;
|
165
|
list = data?data.new_list:null;
|
157
|
listDataSource = list?this.dataSource.cloneWithRows(list):null;
|
166
|
listDataSource = list?this.dataSource.cloneWithRows(list):null;
|
|
@@ -165,12 +174,14 @@ export default class Brand extends Component { |
|
@@ -165,12 +174,14 @@ export default class Brand extends Component { |
165
|
if (!list) {
|
174
|
if (!list) {
|
166
|
return null;
|
175
|
return null;
|
167
|
}
|
176
|
}
|
|
|
177
|
+ this.scrollData = list;
|
168
|
|
178
|
|
169
|
return (
|
179
|
return (
|
170
|
<View style={styles.container}>
|
180
|
<View style={styles.container}>
|
171
|
<ChannelFliter selectID={channelFliter} onChannelPressFliter={this.props.onChannelPressFliter}/>
|
181
|
<ChannelFliter selectID={channelFliter} onChannelPressFliter={this.props.onChannelPressFliter}/>
|
172
|
|
182
|
|
173
|
<ListView
|
183
|
<ListView
|
|
|
184
|
+ ref={(ref)=>this.listView=ref}
|
174
|
contentContainerStyle={contentContainerStyle}
|
185
|
contentContainerStyle={contentContainerStyle}
|
175
|
enableEmptySections={true}
|
186
|
enableEmptySections={true}
|
176
|
dataSource={listDataSource}
|
187
|
dataSource={listDataSource}
|
|
@@ -180,6 +191,8 @@ export default class Brand extends Component { |
|
@@ -180,6 +191,8 @@ export default class Brand extends Component { |
180
|
/>
|
191
|
/>
|
181
|
|
192
|
|
182
|
<IndexListView dataSource={list}/>
|
193
|
<IndexListView dataSource={list}/>
|
|
|
194
|
+ {showIndexForListView?<IndexListView dataSource={list} onLetterPress={this.scrollToSection}/>: null}
|
|
|
195
|
+ {showSearch ? <BrandSearch style={styles.search} data={search}/> : null}
|
183
|
|
196
|
|
184
|
<LoadingIndicator
|
197
|
<LoadingIndicator
|
185
|
isVisible={isFetching}
|
198
|
isVisible={isFetching}
|