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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | 3x 3x 3x 6x | /**
* 详情页头部组件 - 显示猫粮图片、名称和标签
* 采用现代购物App风格设计
*/
import { Image, View } from 'react-native';
import { LinearGradient } from 'expo-linear-gradient';
import { Text, XStack, YStack } from 'tamagui';
import { IconSymbol } from '@/src/components/ui/IconSymbol';
import { useResponsiveLayout } from '@/src/hooks/useResponsiveLayout';
import { primaryScale, neutralScale } from '@/src/design-system/tokens';
interface ReportHeaderProps {
name: string;
tags: string[];
imageUrl?: string | null;
}
export function ReportHeader({ name, tags, imageUrl }: ReportHeaderProps) {
const { isExtraSmallScreen, isSmallScreen } = useResponsiveLayout();
const imageSize = isExtraSmallScreen ? 200 : isSmallScreen ? 220 : 240;
return (
<YStack
marginHorizontal="$3"
marginTop="$2"
marginBottom="$3"
borderRadius={20}
overflow="hidden"
backgroundColor="white"
borderWidth={1}
borderColor={neutralScale.neutral3}
>
{/* 顶部渐变背景区域 */}
<YStack position="relative" paddingTop="$6" paddingBottom="$4">
{/* 背景渐变 */}
<YStack position="absolute" width="100%" height="100%">
<LinearGradient
colors={[primaryScale.primary2, primaryScale.primary1, '#FFFFFF']}
start={{ x: 0, y: 0 }}
end={{ x: 0, y: 1 }}
style={{ width: '100%', height: '100%' }}
/>
</YStack>
{/* 装饰性背景圆环 */}
<YStack
position="absolute"
top={-60}
right={-60}
width={180}
height={180}
borderRadius={90}
backgroundColor={primaryScale.primary3}
opacity={0.3}
/>
<YStack
position="absolute"
bottom={-40}
left={-40}
width={120}
height={120}
borderRadius={60}
backgroundColor={primaryScale.primary4}
opacity={0.2}
/>
{/* 猫粮图片 */}
<YStack alignItems="center" zIndex={1}>
{imageUrl ? (
<YStack borderRadius={20} overflow="hidden" borderWidth={4} borderColor="white">
<Image
source={{ uri: imageUrl }}
style={{
width: imageSize,
height: imageSize,
backgroundColor: neutralScale.neutral2,
}}
resizeMode="cover"
/>
</YStack>
) : (
<YStack
width={imageSize}
height={imageSize}
borderRadius={20}
backgroundColor={primaryScale.primary2}
alignItems="center"
justifyContent="center"
borderWidth={4}
borderColor="white"
>
<IconSymbol name="photo" size={imageSize * 0.3} color={primaryScale.primary6} />
<Text fontSize="$3" color={primaryScale.primary7} marginTop="$2" fontWeight="500">
暂无图片
</Text>
</YStack>
)}
</YStack>
</YStack>
{/* 底部信息区域 */}
<YStack padding="$4" paddingTop="$2" gap="$3" alignItems="center">
{/* 猫粮名称 */}
<View testID="catfood-name">
<Text
fontSize="$7"
fontWeight="800"
color={neutralScale.neutral12}
textAlign="center"
lineHeight={32}
letterSpacing={-0.5}
>
{name}
</Text>
</View>
{/* 标签 */}
{tags && tags.length > 0 && (
<XStack gap="$2" flexWrap="wrap" justifyContent="center" paddingHorizontal="$2">
{tags.slice(0, 5).map((tag, index) => (
<YStack
key={index}
backgroundColor={
index === 0
? primaryScale.primary3
: index === 1
? '#FEF3C7'
: neutralScale.neutral2
}
paddingHorizontal="$3"
paddingVertical="$1.5"
borderRadius={20}
borderWidth={1}
borderColor={
index === 0
? primaryScale.primary5
: index === 1
? '#FCD34D'
: neutralScale.neutral4
}
>
<Text
color={
index === 0
? primaryScale.primary10
: index === 1
? '#92400E'
: neutralScale.neutral10
}
fontSize="$2"
fontWeight="600"
>
{tag}
</Text>
</YStack>
))}
{tags.length > 5 && (
<YStack
backgroundColor={neutralScale.neutral2}
paddingHorizontal="$3"
paddingVertical="$1.5"
borderRadius={20}
borderWidth={1}
borderColor={neutralScale.neutral4}
>
<Text color={neutralScale.neutral9} fontSize="$2" fontWeight="600">
+{tags.length - 5}
</Text>
</YStack>
)}
</XStack>
)}
</YStack>
</YStack>
);
}
|