Authored by 李犇

Merge remote-tracking branch 'origin/5.4.1' into 5.4.1

@@ -14,6 +14,7 @@ import ReactNative, { @@ -14,6 +14,7 @@ import ReactNative, {
14 Platform, 14 Platform,
15 RefreshControl, 15 RefreshControl,
16 } from 'react-native'; 16 } from 'react-native';
  17 +import TimerMixin from 'react-timer-mixin';
17 import Immutable, {Map} from 'immutable'; 18 import Immutable, {Map} from 'immutable';
18 import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator'; 19 import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
19 import YH_SortView from '../../../common/components/YH_SortView'; 20 import YH_SortView from '../../../common/components/YH_SortView';
@@ -84,6 +85,11 @@ export default class Home extends Component { @@ -84,6 +85,11 @@ export default class Home extends Component {
84 } 85 }
85 } 86 }
86 87
  88 + componentWillUnmount() {
  89 + this.requestAnimationFrame && TimerMixin.cancelAnimationFrame(this.requestAnimationFrame);
  90 + }
  91 +
  92 +
87 trigggePullToRefresh(changeChannel=false) { 93 trigggePullToRefresh(changeChannel=false) {
88 let data = this._currentChannelData(); 94 let data = this._currentChannelData();
89 if (changeChannel) { 95 if (changeChannel) {
@@ -150,8 +156,8 @@ export default class Home extends Component { @@ -150,8 +156,8 @@ export default class Home extends Component {
150 <DivideImage/> 156 <DivideImage/>
151 <SingleImage 157 <SingleImage
152 data={rowData} 158 data={rowData}
153 - onPressSlideItem={this.props.onPressSlideItem}  
154 - onPressTitleMore={this.props.onPressTitleMore} 159 + onPressSlideItem={this.props.onPressChangeChannel}
  160 + onPressTitleMore={this.props.onPressChangeChannel}
155 /> 161 />
156 </View> 162 </View>
157 ); 163 );
@@ -444,15 +450,22 @@ export default class Home extends Component { @@ -444,15 +450,22 @@ export default class Home extends Component {
444 450
445 _onScroll(event) { 451 _onScroll(event) {
446 if (event.nativeEvent.contentOffset.y < height) { 452 if (event.nativeEvent.contentOffset.y < height) {
447 - this.setState({showBackTop: false, currentY: event.nativeEvent.contentOffset.y}); 453 + if (this.state.showBackTop) {
  454 + this.setState({showBackTop: false, currentY: event.nativeEvent.contentOffset.y});
  455 + }
448 }else { 456 }else {
449 - this.setState({showBackTop: true, currentY: event.nativeEvent.contentOffset.y}); 457 + if (!this.state.showBackTop) {
  458 + this.setState({showBackTop: true, currentY: event.nativeEvent.contentOffset.y});
  459 + }
450 } 460 }
451 } 461 }
452 462
453 _backTop() { 463 _backTop() {
454 - this.setState({showBackTop: false});  
455 - this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true}); 464 + // this.setState({showBackTop: false});
  465 + console.log(this.state.showBackTop);
  466 + InteractionManager.runAfterInteractions(() =>{
  467 + this.listView && this.listView.scrollTo({x: 0, y: 0, animated: true});
  468 + });
456 } 469 }
457 470
458 _renderFooter() { 471 _renderFooter() {
@@ -76,6 +76,7 @@ class HomeContainer extends Component { @@ -76,6 +76,7 @@ class HomeContainer extends Component {
76 this.onPressProductListProduct = this.onPressProductListProduct.bind(this); 76 this.onPressProductListProduct = this.onPressProductListProduct.bind(this);
77 this.onPressToProductDetail = this.onPressToProductDetail.bind(this); 77 this.onPressToProductDetail = this.onPressToProductDetail.bind(this);
78 this.onPressReloadData = this.onPressReloadData.bind(this); 78 this.onPressReloadData = this.onPressReloadData.bind(this);
  79 + this.onPressChangeChannel = this.onPressChangeChannel.bind(this);
79 80
80 this.subscription = NativeAppEventEmitter.addListener( 81 this.subscription = NativeAppEventEmitter.addListener(
81 'ChannelDidChangeEvent', 82 'ChannelDidChangeEvent',
@@ -280,6 +281,17 @@ class HomeContainer extends Component { @@ -280,6 +281,17 @@ class HomeContainer extends Component {
280 this.props.actions.fetchFloor(); 281 this.props.actions.fetchFloor();
281 } 282 }
282 283
  284 + onPressChangeChannel() {
  285 + let {app} = this.props;
  286 + if (app.channel == 1) {
  287 + console.log(1111111);
  288 + ReactNative.NativeModules.YH_CommonHelper.switchChannelByTheme(0);
  289 + }else if (app.channel == 2) {
  290 + console.log(2222222);
  291 + ReactNative.NativeModules.YH_CommonHelper.switchChannelByTheme(1);
  292 + }
  293 + }
  294 +
283 render() { 295 render() {
284 let {app, home} = this.props; 296 let {app, home} = this.props;
285 return ( 297 return (
@@ -318,6 +330,7 @@ class HomeContainer extends Component { @@ -318,6 +330,7 @@ class HomeContainer extends Component {
318 onClickRecommendProduct={this.onClickRecommendProduct} 330 onClickRecommendProduct={this.onClickRecommendProduct}
319 onPressToProductDetail={this.onPressToProductDetail} 331 onPressToProductDetail={this.onPressToProductDetail}
320 onPressReloadData={this.onPressReloadData} 332 onPressReloadData={this.onPressReloadData}
  333 + onPressChangeChannel={this.onPressChangeChannel}
321 /> 334 />
322 </View> 335 </View>
323 ); 336 );