IPFilter.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { Colors } from "@/constants/Colors";
  2. import { IPItem } from "@/services/award";
  3. import React from "react";
  4. import {
  5. ScrollView,
  6. StyleSheet,
  7. Text,
  8. TouchableOpacity,
  9. View,
  10. } from "react-native";
  11. const ITEM_WIDTH = 87;
  12. const ITEM_HEIGHT = 42;
  13. interface IPFilterProps {
  14. data: IPItem[];
  15. activeIndex: number;
  16. onSelect?: (item: IPItem, index: number) => void;
  17. }
  18. export function IPFilter({ data, activeIndex, onSelect }: IPFilterProps) {
  19. return (
  20. <View style={styles.container}>
  21. <ScrollView
  22. horizontal
  23. showsHorizontalScrollIndicator={false}
  24. contentContainerStyle={styles.content}
  25. >
  26. {data.map((item, index) => {
  27. const isActive = activeIndex === index;
  28. return (
  29. <TouchableOpacity
  30. key={item.id || index}
  31. activeOpacity={0.7}
  32. onPress={() => onSelect?.(item, index)}
  33. style={[
  34. styles.item,
  35. isActive ? styles.itemActive : styles.itemInactive,
  36. ]}
  37. >
  38. <Text
  39. style={[styles.text, isActive && styles.textActive]}
  40. numberOfLines={1}
  41. >
  42. {item.name}
  43. </Text>
  44. {/* Active Indicator */}
  45. {isActive && <View style={styles.indicator} />}
  46. </TouchableOpacity>
  47. );
  48. })}
  49. </ScrollView>
  50. </View>
  51. );
  52. }
  53. const styles = StyleSheet.create({
  54. container: {
  55. width: "100%",
  56. paddingTop: 10,
  57. marginBottom: 5,
  58. },
  59. content: {
  60. paddingHorizontal: 8,
  61. },
  62. item: {
  63. width: ITEM_WIDTH,
  64. height: ITEM_HEIGHT,
  65. justifyContent: "center",
  66. alignItems: "center",
  67. marginHorizontal: 6,
  68. borderRadius: 4,
  69. borderWidth: 1,
  70. },
  71. itemInactive: {
  72. backgroundColor: "rgba(255, 255, 255, 0.05)",
  73. borderColor: Colors.textTertiary,
  74. },
  75. itemActive: {
  76. backgroundColor: "rgba(0, 243, 255, 0.1)", // Low opacity neon blue
  77. borderColor: Colors.neonBlue,
  78. shadowColor: Colors.neonBlue,
  79. shadowOffset: { width: 0, height: 0 },
  80. shadowOpacity: 0.5,
  81. shadowRadius: 5,
  82. elevation: 5,
  83. },
  84. text: {
  85. fontWeight: "bold",
  86. fontSize: 14,
  87. color: Colors.textSecondary,
  88. },
  89. textActive: {
  90. color: "#fff",
  91. textShadowColor: Colors.neonBlue,
  92. textShadowRadius: 5,
  93. },
  94. indicator: {
  95. position: "absolute",
  96. bottom: -1,
  97. width: "40%",
  98. height: 2,
  99. backgroundColor: Colors.neonBlue,
  100. },
  101. });