MenuCell.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import { Colors } from "@/constants/Colors";
  2. import { Images } from "@/constants/images";
  3. import { Image } from "expo-image";
  4. import React from "react";
  5. import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
  6. interface MenuItem {
  7. icon: string;
  8. title: string;
  9. type: string;
  10. tip?: string;
  11. }
  12. interface MenuCellProps {
  13. onItemPress: (type: string) => void;
  14. showWallet?: boolean;
  15. }
  16. export function MenuCell({ onItemPress, showWallet = false }: MenuCellProps) {
  17. const menuList: MenuItem[] = [
  18. ...(showWallet
  19. ? [
  20. {
  21. icon: Images.mine.wallet || "",
  22. title: "钱包",
  23. type: "1_1",
  24. },
  25. ]
  26. : []),
  27. {
  28. icon: Images.mine.kaixinOrders || "",
  29. title: "全部订单",
  30. type: "2_0",
  31. },
  32. {
  33. icon: Images.mine.exchangeIcon || "",
  34. title: "兑换码",
  35. tip: "10:00 ~ 18:00",
  36. type: "6_1",
  37. },
  38. {
  39. icon: Images.mine.customerService || "",
  40. title: "联系客服",
  41. tip: "10:00 ~ 18:00",
  42. type: "4_4",
  43. },
  44. {
  45. icon: Images.mine.address || "",
  46. title: "地址",
  47. type: "4_3",
  48. },
  49. {
  50. icon: Images.mine.opinion || "",
  51. title: "意见反馈",
  52. type: "4_9",
  53. },
  54. {
  55. icon: Images.mine.setting || "",
  56. title: "设置",
  57. type: "4_5",
  58. },
  59. ];
  60. return (
  61. <View style={styles.container}>
  62. {menuList.map((item, index) => (
  63. <TouchableOpacity
  64. key={index}
  65. style={[
  66. styles.menuItem,
  67. index === menuList.length - 1 && styles.lastItem,
  68. ]}
  69. onPress={() => onItemPress(item.type)}
  70. activeOpacity={0.7}
  71. >
  72. <View style={styles.content}>
  73. <Image
  74. source={{ uri: item.icon }}
  75. style={styles.icon}
  76. contentFit="contain"
  77. // Tint icons to neon blue for consistency if they are monochrome
  78. tintColor={Colors.neonBlue}
  79. />
  80. <Text style={styles.title}>{item.title}</Text>
  81. </View>
  82. <View style={styles.arrow}>
  83. <Text style={styles.arrowText}>›</Text>
  84. </View>
  85. </TouchableOpacity>
  86. ))}
  87. </View>
  88. );
  89. }
  90. const styles = StyleSheet.create({
  91. container: {
  92. paddingVertical: 0,
  93. },
  94. menuItem: {
  95. flexDirection: "row",
  96. alignItems: "center",
  97. justifyContent: "space-between",
  98. minHeight: 55,
  99. backgroundColor: "transparent",
  100. borderBottomWidth: 1,
  101. borderBottomColor: "rgba(255, 255, 255, 0.05)",
  102. paddingHorizontal: 15,
  103. },
  104. lastItem: {
  105. borderBottomWidth: 0,
  106. },
  107. content: {
  108. flexDirection: "row",
  109. alignItems: "center",
  110. },
  111. icon: {
  112. width: 20,
  113. height: 20,
  114. marginRight: 12,
  115. },
  116. title: {
  117. fontSize: 14,
  118. fontWeight: "500",
  119. color: Colors.textSecondary,
  120. },
  121. arrow: {
  122. justifyContent: "center",
  123. alignItems: "center",
  124. },
  125. arrowText: {
  126. fontSize: 20,
  127. color: Colors.textTertiary,
  128. marginBottom: 4, // Visual alignment
  129. },
  130. });