Authored by yaya2212

android 刷新组件集成----review 鹿亮亮

... ... @@ -6,6 +6,7 @@ import LoadingIndicator from '../../../common/components/LoadingIndicator';
import LoadMoreIndicator from '../../../common/components/LoadMoreIndicator';
import ListCell from './ListCell';
import ListBannerSwiper from './ListBannerSwiper';
import YH_PtrRefresh from '../../../common/components/YH_PtrRefresh';
import ReactNative, {
View,
... ... @@ -17,6 +18,7 @@ import ReactNative, {
TouchableOpacity,
InteractionManager,
Platform,
RefreshControl,
} from 'react-native';
... ... @@ -45,6 +47,7 @@ export default class List extends Component {
return null;
}
render() {
let {products, banner} = this.props.resource;
let isProductListFetching = products.isFetching;
... ... @@ -65,7 +68,8 @@ export default class List extends Component {
return (
<View style={styles.container}>
{!isFetching?
{
Platform.OS === 'ios' ?
<ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
... ... @@ -93,9 +97,40 @@ export default class List extends Component {
}
}}
/>
:<LoadingIndicator
isVisible={isFetching}
/>}
: <ListView
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
showsVerticalScrollIndicator={false}
dataSource={this.dataSource.cloneWithRowsAndSections(dataBlob)}
renderRow={this.renderRow}
enablePullToRefresh={true}
refreshControl={
<YH_PtrRefresh
refreshing={isFetching}
onRefresh={() => {
this.props.onRefresh && this.props.onRefresh();
}}
/>
}
onEndReached={() => {
if (list && list.length) {
this.props.onEndReached && this.props.onEndReached();
}
}}
renderFooter={()=>{
if (list && list.length && isProductListFetching) {
return <LoadMoreIndicator
isVisible={true}
animating={true}
/>;
} else {
return null;
}
}}
/>
}
</View>
);
}
... ...
... ... @@ -49,7 +49,8 @@ class ListContainer extends Component {
this._onPressDetail = this._onPressDetail.bind(this);
this._onPressBanner = this._onPressBanner.bind(this);
this._onEndReached = this._onEndReached.bind(this);
this._onRefresh = this._onRefresh.bind(this);
this.onRefresh = this.onRefresh.bind(this);
// this._onRefresh = this._onRefresh.bind(this);
}
componentDidMount() {
... ... @@ -61,11 +62,15 @@ class ListContainer extends Component {
}
_onRefresh() {
this.props.actions.fetchBanner();
this.props.actions.getProductList(true);
onRefresh() {
InteractionManager.runAfterInteractions(() => {
this.props.actions.fetchBanner();
this.props.actions.getProductList(true);
});
}
_onPressDetail(product_skn, index) {
if (!product_skn) {
return;
... ... @@ -117,7 +122,7 @@ class ListContainer extends Component {
onPressDetail={this._onPressDetail}
onEndReached={this._onEndReached}
onPressBanner={this._onPressBanner}
onRefresh={this._onRefresh}
onRefresh={this.onRefresh}
/>
);
}
... ...