All files / app/detail/components AIReportButton.tsx

100% Statements 5/5
100% Branches 4/4
100% Functions 1/1
100% Lines 5/5

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                          3x 1x                                     2x 1x     1x                                                  
import { Feather } from '@expo/vector-icons';
import { Spinner, Text, XStack, YStack } from 'tamagui';
import { Button } from '@/src/design-system/components';
 
import { infoScale } from '@/src/design-system/tokens';
 
interface AIReportButtonProps {
  hasReport: boolean;
  isLoading: boolean;
  onPress: () => void;
}
 
export function AIReportButton({ hasReport, isLoading, onPress }: AIReportButtonProps) {
  if (isLoading) {
    return (
      <YStack
        paddingHorizontal="$4"
        paddingVertical="$3"
        backgroundColor={infoScale.info2}
        borderRadius="$4"
        borderWidth={1}
        borderColor={infoScale.info4}
      >
        <XStack gap="$2" alignItems="center" justifyContent="center">
          <Spinner size="small" color={infoScale.info9} />
          <Text fontSize="$4" color={infoScale.info9}>
            加载中...
          </Text>
        </XStack>
      </YStack>
    );
  }
 
  if (!hasReport) {
    return null;
  }
 
  return (
    <Button
      size="$4"
      height={48}
      fontSize={16}
      theme="blue"
      icon={<Feather name="file-text" size={18} />}
      onPress={onPress}
      backgroundColor={infoScale.info4}
      borderColor={infoScale.info6}
      borderWidth={1}
      pressStyle={{
        backgroundColor: infoScale.info5,
        scale: 0.98,
      }}
      hoverStyle={{
        backgroundColor: infoScale.info5,
      }}
    >
      <Text fontSize="$4" fontWeight="600" color={infoScale.info10}>
        查看 AI 分析报告
      </Text>
    </Button>
  );
}