一个智能的下拉刷新和上拉加载更多的 react-native listview,适用于 iOS,采用纯 JS 编写,适用于 Android,采用 JS 和 Java 编写。
一个智能的下拉刷新和上拉加载更多的 react-native listview,适用于 iOS,采用纯 JS 编写,适用于 Android,采用 JS 和 Java 编写。
A smart pull-down-refresh and pull-up-loadmore react-native listview, for ios, written in pure JS, for android, written in JS and Java.
This component is compatible with React Native 0.25 and newer.

easy to customize the 'RefreshView' style and content, bounce effect for both pull down refresh and pull up load more, if you want, you can also use the 'autoLoad' mode for pull up load more. demonstration
if you want, the listRow can remove its children to release memory when its position is outside viewport of device, and will undo when its position is inside viewport of device. demonstration
it also supports sticky header with pull to refresh demonstration
npm install react-native-smart-pull-to-refresh-listview --saveandroid/settings.gradle...
include ':react-native-smart-swipe-refresh-layout'
project(':react-native-smart-swipe-refresh-layout').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-smart-pull-to-refresh-listview/android')android/app/build.gradle...
dependencies {
...
// From node_modules
compile project(':react-native-smart-swipe-refresh-layout')
}...
import com.reactnativecomponent.swiperefreshlayout.RCTSwipeRefreshLayoutPackage; //import package
...
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
@Override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new RCTSwipeRefreshLayoutPackage() //register Module
);
}
...
If you're using react-native 0.30-, follow these extra steps
In node_modules/react-native-smart-pull-to-refresh-listview/android/src/main/java/com/reactnativecomponent/swiperefreshlayout/
In TouchEvent.java
...
public TouchEvent(int viewTag, long timestampMs, int movement) {
super(viewTag, timestampMs); //for older version
//super(viewTag); //for newer version
this.movement = movement;
}
...In TouchUpEvent.java
...
public TouchUpEvent(int viewTag, long timestampMs) {
super(viewTag, timestampMs); //for older verion
//super(viewTag); //for newer version
}
...…| Prop | Type | Optional | Default | Description |
|---|---|---|---|---|
| ...ListView.propTypes | see react-native documents | |||
| viewType | enum | Yes | Symbol | determines the viewType which will be used(ScrollView, ListView) |
| autoLoadMore | bool | Yes | false | when the value is true, pull up load more will be auto |
| onRefresh | func | Yes | when refreshing, this function will be called | |
| onLoadMore | func | Yes | when loadingMore, this function will be called | |
| onEndReachedThreshold | number | Yes | 0 | threshold in pixels (virtual, not physical) for calling onLoadMore |
| pullUpDistance | number | Yes | 35 | determines the pull up max distance |
| pullUpStayDistance | number | Yes | 50 | determines the pull up stay distance |
| pullDownDistance | number | Yes | 35 | determines the pull down max distance |
| pullDownStayDistance | number | Yes | 50 | determines the pull down stay distance |
| enabledPullUp | bool | Yes | true | when the value is false, pull up load more will be disabled |
| enabledPullDown | bool | Yes | true | when the value is false, pull down refresh will be disabled |
| listItemProps | object | Yes | see react-native documents | |
| renderRowWithVisibility | bool | Yes | when the value is true, the children of the listRow can be controlled with 'hidden' state | |
| pageTop | number | Yes | 0 | determines the top relative to the page of the float section header(sticky header) view |
| floatSectionHeaderWidth | number | Yes | deviceWidth | determines the width of the float section header(sticky header) view |
| renderFloatSectionHeader | number | Yes | 0 | determines the width of the float section header(sticky header) view |
| listSectionProps | object | Yes | see react-native documents |
listItemProps: when set this prop, listView will use special 'listRow', the listRow will remove its children to release memory when its position is outside viewport of device, and will undo when its position is inside viewport of device. Usually it is used with 'react-native-smart-image-loader'
renderRowWithVisibility: when the value is true, the children of the listRow can be controlled with 'hidden' state. This prop is valid when 'listItemProps' is being set, and it is only valid for android. Usually it is used with 'react-native-smart-image-loader'
pageTop, floatSectionHeaderWidth, renderFloatSectionHeader, listSectionProps are used for android to support ios-like sticky header
暂无开放 Issues,或尚未同步最近议题。