Created
October 4, 2020 07:28
-
-
Save afaquejam/72d0880c25a76f2e3f44b297a07c40ef to your computer and use it in GitHub Desktop.
React Pagination Dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StatusBar } from 'expo-status-bar'; | |
import React, { useState } from 'react'; | |
import { StyleSheet, Text, View, Button } from 'react-native'; | |
import PaginationDot from 'react-native-animated-pagination-dot'; | |
export default function App() { | |
const [currentPage, setCurrentPage] = useState(0); | |
const maxPage = 20; | |
const color = 'black'; | |
return ( | |
<View style={styles.container}> | |
<Button | |
onPress={() => { | |
if (currentPage !== 0) { | |
setCurrentPage(currentPage - 1); | |
} | |
}} | |
title="Before" | |
/> | |
<PaginationDot | |
activeDotColor={color} | |
curPage={currentPage} | |
maxPage={maxPage} | |
sizeRatio={1.0} | |
/> | |
<Button | |
onPress={() => { | |
if (currentPage !== maxPage) { | |
setCurrentPage(currentPage + 1); | |
} | |
}} | |
title="After" | |
/> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
flexDirection: 'row', | |
backgroundColor: '#fff', | |
alignItems: 'center', | |
justifyContent: 'center', | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment