-
-
Save garrettmac/bccb7cd2fc02162a2964e9380d750f6b to your computer and use it in GitHub Desktop.
| a |
<Pagination
dotThemeLight //<--use with backgroundColor:"grey"
listRef={this.refs}//to allow React Native Pagination to scroll to item when clicked (so add "ref={r=>this.refs=r}" to your list)
paginationVisibleItems={this.state.viewableItems}//needs to track what the user sees
paginationItems={this.state.items}//pass the same list as data
paginationItemPadSize={3} //num of items to pad above and below your visable items
more params you can play with
hideEmptyDots
pagingEnabled
dotSwapAxis
dotPositionSwap
disableDotOnPressNavigation
dotOnPress={(item)=>alert(JSON.stringify(item))}
startDotOnPress={(item)=>alert("pressed startDotOnPress")}
endDotOnPress={(item)=>alert("pressed endDotOnPress")}
startDotIconFamily="Ionicons"
startDotIconName="ios-arrow-back"
endDotIconFamily="Ionicons"
endDotIconName="ios-arrow-forward"
dotIconNameActive={"contacts"}
dotTextColor={"red"}
dotTextColorActive={"green"}
dotTextColorNotActive={"red"}
dotTextColorEmpty={"blue"}
dotIconColorActive={"green"}
dotIconColorNotActive={"red"}
dotIconColorEmpty={"blue"}
/>
iconFamily -> iconSet
hideEmptyDots -> showEmptyDots
dotThemeLight => lightTheme
paginationContainerStyle
The best Pagination component for React Native.
React Native Pagination
Roadmap
Horizontal
Vertical
Getting Started
Installation
react-nativefirstExample
or clone the repo and play with the example project
$ git clone https://github.com/garrettmac/react-native-pagination $ cd react-native-pagination/ReactNativePaginationExample $ yarn install $ react-native link $ react-native run-iosone liner
Development
in your project
$ yarn add react-native-pagination $ react-native link #this makes sure react-native-vector-icons load correctly $ react-native run-iosBasic Usage
myApp/index.ios.js, use:Currently only supported for FlatList's
Properties
All properties took text editors auto completion into consideration and follow the basic structure
[
prefix][body][suffix] where[
component name][component attribute][continued component attribute / component change] to provide users with the full list of options when working withprefix's without having to revisit the official docs.Most Common Component Prefix Options:
dot,startDot,endDotMost Common Component Body Options:
Icon,Font,Style,ColorMost Common Component Suffix Options:
Hide,Size,IconFamily,orNotActive,ActiveEmptyResulting props like
dotIconHide,startDotIconHide, orstartFontSize,endDotStyleect.Basic
Basic Props
[]array[]arrayonViewableItemsChangedcallback function (see example)falsebooldotThemeLightprop (setting it totrue) the pagination dots swaps to a a light theme. By default they are dark.falseboolLayoutAnimation.Presets.easeInEaseOutAnimation{}stylefalseboolFlatList) that gives you that paging effect that stops the scroll on every new page.falsebool3numberBasic Styles
paginationStylewhen horizontal{height, alignItems:"center" , justifyContent: 'space-between', position:"absolute", top:0, margin:0, bottom:0, right:0, bottom:0, padding:0, flex:1, }stylepaginationStylewhen not horizontal{width, alignItems:"center", justifyContent: 'space-between', position:"absolute", margin:0, bottom:10, left:0, right:0, padding:0, flex:1,}style{}style object{}style object{}style object{}style objectStart/End Dots
Start/End Dot Basic Props
startDotIconName(whenhorizontal)”chevron-left”icon namestartDotIconName(whenvertical)”chevron-up”icon nameendDotIconName(whenhorizontal)”chevron-right”icon nameendDotIconName(whenvertical)”chevron-down”icon namestartDotIconSize15numberendDotIconSize15numberstartDotIconFamily/endDotIconFamilyMaterialCommunityIconsstringof font family nameEntypo,EvilIcons,FontAwesome,Foundation,Ionicons,MaterialIcons,MaterialCommunityIcons,Octicons,Zocial,SimpleLineIcons(available in react-native-vector-icons package)Start/End Dot Text
11number11numberPagination Dots
These are the list of dots that represent each item in your paginationItems
Pagination Dots Basic Props
dotIconFamily”MaterialCommunityIcons”stringof font family nameEntypo,EvilIcons,FontAwesome,Foundation,Ionicons,MaterialIcons,MaterialCommunityIcons,Octicons,Zocial,SimpleLineIcons(available in react-native-vector-icons package)”close”icon name”checkbox-blank-circle”icon name”checkbox-blank-circle-outline”icon name15number10number”rgba(0,0,0,.5)”color”rgba(0,0,0,.3)”color”rgba(0,0,0,.2)”colorwhen using dotThemeLight
”rgba(255,255,255,.4)”color”rgba(255,255,255,.5)”color”rgba(255,255,255,.2)”colorDot Text
by default it displays
index+1, if you'd like display text add thepaginationDotTextproperty to each one of your items before passing it into thePaginationComponent. Example:
Pagination Dots
numbernumbernumber”rgba(0,0,0,.5)”color”rgba(0,0,0,.3)”color”rgba(0,0,0,.2)”colorwhen using dotThemeLight
”rgba(255,255,255,.4)”color”rgba(255,255,255,.5)”color”rgba(255,255,255,.2)”colorAdvanced Positioning
dotSwapAxis(all pagination dots)/startDotSwapAxis/endDotSwapAxisbooldotPositionSwap(all pagination dots)/startDotPositionSwap/endDotPositionSwapboolflexDirectiondefault style property.Wanna move anything to the left, right, top, or bottom of something? Then use
dotSwapAxisin combination until you find the right mixstartDotPositionSwap.Visibility
dotIconHide/startDotIconHide/endDotIconHidebooldotIconHide/startDotIconHide/endDotIconHidebooldotTextHide/startDotTextHide/endDotTextHidebooldotEmptyHideboolMethods
dotOnPress/startDotOnPress/endDotOnPressdisableDotOnPressNavigationto turn off), if you'd like a callback you can pass in thedotOnPresscallback functionOther
debugModeboolComponents
PaginationpaginationItems,paginationVisibleItemsDotIconnameiconFamily,size,coloriconFamilyoptionIssues
Feel free to contact me or create an issue