MenuCell.tsx 2.6 KB

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