QuickEntry.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { Colors } from "@/constants/Colors";
  2. import { TabItem } from "@/services/base";
  3. import { Image } from "expo-image";
  4. import React from "react";
  5. import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
  6. // 小程序 item 宽度 162rpx = 81pt
  7. const ITEM_WIDTH = 81;
  8. interface QuickEntryProps {
  9. data: TabItem[];
  10. onPress?: (item: TabItem) => void;
  11. }
  12. export function QuickEntry({ data, onPress }: QuickEntryProps) {
  13. return (
  14. <View style={styles.container}>
  15. <View style={styles.center}>
  16. {data.map((item, index) => (
  17. <TouchableOpacity
  18. key={index}
  19. style={styles.item}
  20. activeOpacity={0.7}
  21. onPress={() => onPress?.(item)}
  22. >
  23. <View style={styles.itemBox}>
  24. <Image
  25. source={item.cover}
  26. style={styles.icon}
  27. contentFit="contain"
  28. />
  29. <Text style={styles.title}>{item.title}</Text>
  30. </View>
  31. </TouchableOpacity>
  32. ))}
  33. </View>
  34. </View>
  35. );
  36. }
  37. const styles = StyleSheet.create({
  38. container: {
  39. width: "100%",
  40. marginTop: 10,
  41. marginBottom: 5,
  42. paddingHorizontal: 10,
  43. },
  44. center: {
  45. width: "100%",
  46. flexDirection: "row",
  47. flexWrap: "wrap",
  48. justifyContent: "space-around",
  49. },
  50. item: {
  51. width: ITEM_WIDTH,
  52. alignItems: "center",
  53. },
  54. itemBox: {
  55. alignItems: "center",
  56. // Glow effect for icons
  57. shadowColor: Colors.neonBlue,
  58. shadowOffset: { width: 0, height: 0 },
  59. shadowOpacity: 0.3,
  60. shadowRadius: 5,
  61. },
  62. icon: {
  63. width: 48, // Reduced slightly from ITEM_WIDTH to fit better
  64. height: 48,
  65. marginBottom: 4,
  66. },
  67. title: {
  68. fontSize: 11,
  69. fontWeight: "500",
  70. color: Colors.textSecondary,
  71. textShadowColor: "rgba(0, 243, 255, 0.3)",
  72. textShadowOffset: { width: 0, height: 0 },
  73. textShadowRadius: 3,
  74. },
  75. });