Authored by 孙凯

add 切换瓶倒后 listView推倒顶部 review by hongmo

@@ -36,6 +36,7 @@ export default class BrandStore extends Component { @@ -36,6 +36,7 @@ export default class BrandStore extends Component {
36 this.renderSectionHeader = this.renderSectionHeader.bind(this); 36 this.renderSectionHeader = this.renderSectionHeader.bind(this);
37 this.renderRow = this.renderRow.bind(this); 37 this.renderRow = this.renderRow.bind(this);
38 this._onPressProductFilter = this._onPressProductFilter.bind(this); 38 this._onPressProductFilter = this._onPressProductFilter.bind(this);
  39 + this._onPressStoreFilter = this._onPressStoreFilter.bind(this);
39 40
40 this.dataSource = new ListView.DataSource({ 41 this.dataSource = new ListView.DataSource({
41 rowHasChanged: (r1, r2) => !Immutable.is(r1, r2), 42 rowHasChanged: (r1, r2) => !Immutable.is(r1, r2),
@@ -50,17 +51,26 @@ export default class BrandStore extends Component { @@ -50,17 +51,26 @@ export default class BrandStore extends Component {
50 this._showToast && this._showToast(showToastMessage); 51 this._showToast && this._showToast(showToastMessage);
51 } 52 }
52 } 53 }
53 - _onPressProductFilter(value){  
54 54
  55 + _onPressStoreFilter(value){
  56 + this.props.onPressStoreFilter && this.props.onPressStoreFilter(value);
  57 + if (value != 3) {
  58 + if (value == 0) {
  59 + this.refs.brandStoreList && this.refs.brandStoreList.scrollTo({x: 0, y: Math.ceil((200 / 640) * width), animated: false});
  60 + }else {
  61 + this.refs.brandStoreList && this.refs.brandStoreList.scrollTo({x: 0, y: storeFilter_y_Position, animated: false});
  62 + }
  63 + }
  64 + }
  65 +
  66 + _onPressProductFilter(value){
55 if(value === 'filter'){ 67 if(value === 'filter'){
56 this.refs.brandStoreList && this.refs.brandStoreList.scrollTo({x: 0, y: yPosition, animated: false}); 68 this.refs.brandStoreList && this.refs.brandStoreList.scrollTo({x: 0, y: yPosition, animated: false});
57 } 69 }
58 if(value==='default'){ 70 if(value==='default'){
59 this.refs.brandStoreList && this.refs.brandStoreList.scrollTo({x: 0, y: yPosition, animated: false}); 71 this.refs.brandStoreList && this.refs.brandStoreList.scrollTo({x: 0, y: yPosition, animated: false});
60 -  
61 } 72 }
62 this.props.onPressProductFilter && this.props.onPressProductFilter(value); 73 this.props.onPressProductFilter && this.props.onPressProductFilter(value);
63 -  
64 } 74 }
65 75
66 _showToast(message){ 76 _showToast(message){
@@ -88,20 +98,21 @@ export default class BrandStore extends Component { @@ -88,20 +98,21 @@ export default class BrandStore extends Component {
88 98
89 renderSectionHeader(sectionData, sectionID) { 99 renderSectionHeader(sectionData, sectionID) {
90 switch(sectionID) { 100 switch(sectionID) {
91 - case 'brandReource': {  
92 - return (  
93 - <BrandStoreFilter  
94 - selectID={this.props.storeFilter}  
95 - onPressFilter={this.props.onPressStoreFilter}  
96 - />  
97 - );  
98 - } 101 + case 'brandReource':
99 case 'storeFilter': { 102 case 'storeFilter': {
  103 +
100 return ( 104 return (
101 - <BrandStoreFilter  
102 - selectID={this.props.storeFilter}  
103 - onPressFilter={this.props.onPressStoreFilter}  
104 - /> 105 + <View
  106 + style={styles.brandFilterContainer}
  107 + onLayout={(evt) => {
  108 + storeFilter_y_Position = evt.nativeEvent.layout.y;
  109 + }}
  110 + >
  111 + <BrandStoreFilter
  112 + selectID={this.props.storeFilter}
  113 + onPressFilter={this._onPressStoreFilter}
  114 + />
  115 + </View>
105 ); 116 );
106 } 117 }
107 case 'productList': { 118 case 'productList': {
@@ -359,6 +370,7 @@ let rowHeight = Math.ceil(254 * width / 320); @@ -359,6 +370,7 @@ let rowHeight = Math.ceil(254 * width / 320);
359 let rowMarginTop = Math.ceil(10 * width / 320); 370 let rowMarginTop = Math.ceil(10 * width / 320);
360 let rowMarginHorizontal = (width - rowWidth * 2) / 3; 371 let rowMarginHorizontal = (width - rowWidth * 2) / 3;
361 let yPosition = 0; 372 let yPosition = 0;
  373 +let storeFilter_y_Position = 0;
362 374
363 let styles = StyleSheet.create({ 375 let styles = StyleSheet.create({
364 container: { 376 container: {