1.2.0 • Published 2 years ago

react-native-rnrecyclerviews v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-rnrecyclerviews

  • 使用Android原生RecyclerView实现。
  • 列表内容由React Native项目自行决定,故不对外提供item点击事件。
  • 提供滑动到顶、底及任意position回调
  • version 1.1.8 后提供吸顶布局 ,使用Android Material Design CoordinatorLayout + AppBarLayout + CollapsingToolbarLayout

Getting started

"react-native-rnrecyclerviews": "https://develop.dianpings.com/gitlab/frontend/FtWaterFall_Android.git" $ npm install react-native-rnrecyclerviews

Manually install only for Android project(npm install后无须此操作)

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.library.rnrecyclerview.RNRnrecyclerviewPackage; to the imports at the top of the file
  • Add new RNRnrecyclerviewPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-rnrecyclerviews'
    project(':react-native-rnrecyclerviews').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-rnrecyclerviews/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-rnrecyclerviews')

Usage

Look at the use case RNRecyclerViewTest

RNRecyclerView Props

Prop nameDescriptionTypeDefaultExample
layoutType1.设置LayoutManager(必传)2.设置spanCount3.设置loadMore回调条目数array必传1.线性布局{0}、{0,4}2.网格布局{1,2}、{1,2,4}3.瀑布流{2,2}、{2,2,4}
dataSourceThe datasource that contains the data to renderDataSource
renderItem需要渲染的itemcomponent
invertedinverted the listbool
ListHeaderComponentComponent to render as header 瀑布流不要使用componentnone
ListFooterComponentComponent to render as footer 瀑布流不要使用componentnone
ListEmptyComponentComponent to render in case of no items 空布局componentnone
onBottom列表滑动到底回调function
onLoadMore加载更多回调,可用于提前n条数据开始回调(layoutType最后一个参数设置n)function
onTop滑动到顶回调function

Methods

Method nameParamsDescription
scrollToIndex{ index, animated, velocity, viewPosition, viewOffset }Scroll the list to the index item such that it is positioned in the viewable area such that viewPosition 0 places it at the top, 1 at the bottom, and 0.5 centered in the middle. viewOffset is a fixed number of pixels to offset the final target position. It can be animated. velocity is the amount of milliseconds per inch.
scrollToEnd{ animated, velocity }Scroll to the end of the list. It can be animated. velocity is the amount of milliseconds per inch.
scrollToTop{ animated, velocity }Scroll to the top of the list. It can be animated. velocity is the amount of milliseconds per inch.
setLayoutManagerlayoutTypeReset layoutManager for resolving the refresh question
setReverseinvertedinverted the list

DataSource

It wraps your array, giving you some useful methods to update the data.

Methods

Method nameParamsDescription
pushitemAdd an item to the end of the array
unshiftitemAdd an item to the beginning of the array
spliceindex,deleteCount,...itemsEquals to Array.prototype.splice
setindex, itemSet the item at the specified index
getindexReturns the item at the specified index
sizeReturns the length of the array
setDirtyForces the RecyclerViewList to render again the visible items
moveUpindexMove the item up of 1 position
moveDownindexMove the item down of 1 position
  • note:
  1. Reset layoutManager for resolving the refresh question (非顶部全局重置数据必须使用)
  2. See RNRecyclerViewTest.js.reset()

Thanks for react-native-recyclerview-list-android

see @https://www.npmjs.com/package/react-native-recyclerview-list-android




Version 1.1.8

  • 新增吸顶布局CollapsedView,结合RNRecyclerView使用

  • Look at the use case CollapsedViewTest

    CollapsedView Props

Prop nameDescriptionTypeDefault
CollapseComponent需要折叠布局component必传
StableComponent吸顶固定布局component必传
NormalComponent列表布局component必传
onCollapsedState折叠状态回调(0、1、2) 0:展开状态 1:吸顶状态 2:中间状态functionnone
1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.0.9

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago