Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | 4x 4x 4x 3x 9x | import { Pressable, ScrollView } from 'react-native';
import { Text, XStack, YStack } from 'tamagui';
import { IconSymbol } from '@/src/components/ui/IconSymbol';
import { useThemeColors, useIsDarkMode } from '@/src/hooks/useThemeColors';
interface BrandFilterMenuProps {
visible: boolean;
brandList: string[];
brandCounts: Record<string, number>;
selectedBrand: string;
onSelectBrand: (brand: string) => void;
onClose: () => void;
}
/**
* 品牌筛选菜单组件
* 显示所有可用品牌及其猫粮数量
*/
export function BrandFilterMenu({
visible,
brandList,
brandCounts,
selectedBrand,
onSelectBrand,
onClose,
}: BrandFilterMenuProps) {
const colors = useThemeColors();
const isDark = useIsDarkMode();
if (!visible) return null;
return (
<YStack
paddingHorizontal="$4"
paddingVertical="$4"
backgroundColor={colors.backgroundMuted as any}
borderBottomWidth={2}
borderBottomColor={colors.border as any}
>
<XStack alignItems="center" justifyContent="space-between" marginBottom="$3.5">
<XStack alignItems="center" gap="$2.5">
<YStack
width={40}
height={40}
borderRadius="$10"
backgroundColor={colors.warning as any}
alignItems="center"
justifyContent="center"
>
<IconSymbol name="building.2.fill" size={20} color="white" />
</YStack>
<YStack>
<Text fontSize={18} fontWeight="800" color={colors.text as any} letterSpacing={0.3}>
选择品牌
</Text>
<Text fontSize={12} color={colors.textSecondary as any} fontWeight="600">
共 {brandList.length - 1} 个品牌
</Text>
</YStack>
</XStack>
<Pressable onPress={onClose}>
<XStack
paddingHorizontal="$3"
paddingVertical="$2"
backgroundColor={colors.cardBackground as any}
borderRadius="$8"
alignItems="center"
gap="$2"
borderWidth={1.5}
borderColor={colors.border as any}
>
<IconSymbol name="xmark" size={14} color={colors.warning as any} />
<Text fontSize={13} color={colors.warning as any} fontWeight="700">
收起
</Text>
</XStack>
</Pressable>
</XStack>
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
contentContainerStyle={{ gap: 10 }}
>
{brandList.map((brand) => (
<Pressable key={brand} onPress={() => onSelectBrand(brand)}>
<YStack
paddingHorizontal="$4"
paddingVertical="$3"
borderRadius="$10"
backgroundColor={
(selectedBrand === brand ? colors.primary : colors.cardBackground) as any
}
borderWidth={2}
borderColor={(selectedBrand === brand ? colors.primaryDark : colors.border) as any}
minWidth={90}
alignItems="center"
gap="$1.5"
>
<Text
fontSize={15}
color={(selectedBrand === brand ? 'white' : colors.text) as any}
fontWeight="800"
numberOfLines={1}
letterSpacing={0.3}
>
{brand === 'all' ? '全部' : brand}
</Text>
<YStack
paddingHorizontal="$2"
paddingVertical="$0.5"
backgroundColor={
(selectedBrand === brand
? 'rgba(255,255,255,0.2)'
: colors.backgroundMuted) as any
}
borderRadius="$6"
>
<Text
fontSize={12}
color={(selectedBrand === brand ? 'white' : colors.textSecondary) as any}
fontWeight="700"
>
{brandCounts[brand] || 0} 个
</Text>
</YStack>
</YStack>
</Pressable>
))}
</ScrollView>
</YStack>
);
}
|