PaginationIndicator.tsx 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from "react";
  2. import { View, StyleSheet } from "react-native";
  3. const Circle = ({ isActive }: { isActive: boolean }) => {
  4. return <View style={isActive ? styles.activeCircle : styles.circle} />;
  5. };
  6. const PaginationIndicator = ({ totalPages, currentPage }: { totalPages: number; currentPage: number }) => {
  7. return (
  8. <View style={styles.container}>
  9. {Array.from({ length: totalPages }, (_, index) => (
  10. <Circle key={index} isActive={index === currentPage} />
  11. ))}
  12. </View>
  13. );
  14. };
  15. const styles = StyleSheet.create({
  16. container: {
  17. flexDirection: "row",
  18. justifyContent: "center",
  19. alignItems: "center",
  20. flex:1,
  21. },
  22. circle: {
  23. width: 16,
  24. height: 16,
  25. borderRadius: 10,
  26. backgroundColor: "#D9D9D9",
  27. margin: 5,
  28. },
  29. activeCircle: {
  30. width: 16,
  31. height: 16,
  32. borderRadius: 10,
  33. backgroundColor: "#02677D",
  34. margin: 5,
  35. },
  36. });
  37. export default PaginationIndicator;