All files / app/detail/components NutrientAnalysisSection.tsx

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 2/2

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                        2x   1x                                                                                                  
/**
 * 营养分析卡片 - 显示营养成分分析结果
 */
import { Text, XStack, YStack } from 'tamagui';
import { IconSymbol } from '@/src/components/ui/IconSymbol';
import { infoScale, neutralScale } from '@/src/design-system/tokens';
 
interface NutrientAnalysisSectionProps {
  nutrient: string;
}
 
export function NutrientAnalysisSection({ nutrient }: NutrientAnalysisSectionProps) {
  if (!nutrient) return null;
 
  return (
    <YStack
      marginHorizontal="$3"
      marginBottom="$3"
      borderRadius={20}
      backgroundColor="white"
      overflow="hidden"
      borderWidth={1}
      borderColor={neutralScale.neutral3}
    >
      {/* 标题栏 */}
      <XStack
        padding="$4"
        alignItems="center"
        gap="$3"
        borderBottomWidth={1}
        borderBottomColor={neutralScale.neutral2}
      >
        <YStack
          width={44}
          height={44}
          borderRadius={22}
          backgroundColor={infoScale.info2}
          alignItems="center"
          justifyContent="center"
        >
          <IconSymbol name="chart.bar.fill" size={22} color={infoScale.info7} />
        </YStack>
        <YStack flex={1}>
          <Text fontSize="$5" fontWeight="700" color={neutralScale.neutral12}>
            营养分析
          </Text>
          <Text fontSize={11} color={neutralScale.neutral8} marginTop={2}>
            Nutrition Analysis
          </Text>
        </YStack>
      </XStack>
 
      {/* 内容区域 */}
      <YStack padding="$4">
        <YStack padding="$4" backgroundColor={infoScale.info1} borderRadius={12}>
          <Text fontSize="$3" lineHeight={24} color={neutralScale.neutral11} fontWeight="500">
            {nutrient}
          </Text>
        </YStack>
      </YStack>
    </YStack>
  );
}