PaginationIndicator.tsx 890 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. },
  21. circle: {
  22. width: 16,
  23. height: 16,
  24. borderRadius: 10,
  25. backgroundColor: "#D9D9D9",
  26. margin: 5,
  27. },
  28. activeCircle: {
  29. width: 16,
  30. height: 16,
  31. borderRadius: 10,
  32. backgroundColor: "#02677D",
  33. margin: 5,
  34. },
  35. });
  36. export default PaginationIndicator;