npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-bsrefresh-list-view

v2.5.0

Published

A list component that can be pulled up & down to refresh

Downloads

4

Readme

功能

  1. 这是一个支持自定义的下拉刷新组件
  2. 这是一个支持自定义的上拉加载更多的组件
  3. 这是一个基于FlatList,SectionList组件。支持两者的可选配置

效果

image
gitHub地址: https://github.com/FreeBaiShun/bsrefresh-list-view

npm集成

npm i react-native-bsrefresh-list-view
npm i

用法

import React, {Component} from 'react';
import RequestManager from '../network/RequestManager';
import config from '../network/NetworkConfig';
import RefreshListView, { RefreshState } from 'react-native-bsrefresh-list-view'

import {
Platform,
View,
Text,
Image,
Button,
FlatList,
} from 'react-native'

import Case from './Case'
var pageCur = 1;
var arrMList = [];

export default class Home extends Component {
_flatList;


static navigationOptions = ({navigation}) => {
return {
headerStyle:{
backgroundColor: 'red',
},
headerTitle: (
<Text style={{color:'red'}}>
首页
</Text>
)
};
}

state = {
dataFlatList:[],
refreshState: RefreshState.Idle,
}

_renderItem = (item) => {
var dictCur = item.item;
var txt =  dictCur.title + '---' + dictCur.content;
return(
<View style = {{height: 50.0}}>
<Text>
{txt}
</Text>
</View>
)
}
_keyExtractor = (item, index) => {
return index;
}
render() {
return (
<View>
<RefreshListView
//FlatList
componentName = {'FlatList'}
data = {this.state.dataFlatList}
//SectionList
//componentName = {'SectionList'}
//sections = {this.state.dataFlatList}

renderItem = {this._renderItem}
refreshState={this.state.refreshState}
onHeaderRefresh={this.onHeaderRefresh}
onFooterRefresh={this.onFooterRefresh}
keyExtractor={this._keyExtractor}

// 可选
footerRefreshingText='玩命加载中 >.<'
footerFailureText='我擦嘞,居然失败了 =.=!'
footerNoMoreDataText='-我是有底线的-'
footerEmptyDataText='-好像什么东西都没有-'
>

</RefreshListView>
</View>

)
}

componentDidMount() {
this.onHeaderRefresh();
}

//请求数据
fetchData(page,callback){
RequestManager.get(config.api.getText,
{
page:page,
count:50,
},(json,error) => {
if(error){
if(callback){
callback(null,error);
}
}else{
if(page == 1){
pageCur = 1;
arrMList = [];
}
arrMList = arrMList.concat(json.result);
if(callback){
callback(arrMList,null);
}
}
});
}

onHeaderRefresh = () => {
this.setState({ refreshState: RefreshState.HeaderRefreshing });
this.fetchData(1,(arr, error) => {
if(error){
this.setState({ refreshState: RefreshState.Failure });
}else{
this.setState({
dataFlatList: arr,
refreshState: arr.length < 1 ? RefreshState.EmptyData : RefreshState.Idle,
})
}
});
}

onFooterRefresh = () => {
pageCur++;
console.log('pageCur = ' + pageCur);
this.setState({ refreshState: RefreshState.FooterRefreshing })
this.fetchData(pageCur,(arr, error) => {
if(error){
this.setState({ refreshState: RefreshState.Failure });
}else{
this.setState({
dataFlatList: arr,
refreshState: (arr.length%50 != 0) ? RefreshState.NoMoreData : RefreshState.Idle,
})
}
});
}
}

该Demo启动

  1. 在react-native路径下执行
$ npm i
  1. 在ios路径下执行
$ pod install
  1. 在node_modules路径下执行(启服)
$ npm start
  1. 运行 用xcode打开BottomTest.xcworkspace工程文件运行即可