activity-card.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Image } from 'expo-image';
  2. import type { ComponentProps } from 'react';
  3. import React from 'react';
  4. import { Pressable, Text, View } from 'react-native';
  5. import { StatusBadge } from './status-badge';
  6. interface ActivityCardProps {
  7. avatarUri?: string;
  8. name: string;
  9. loanType: string;
  10. time: string;
  11. description: string;
  12. badgeText: string;
  13. badgeVariant?: ComponentProps<typeof StatusBadge>['variant'];
  14. onPress?: () => void;
  15. }
  16. /**
  17. * 动态卡片 — 展示客户最近操作动态
  18. * 采用浅底色和细边框,避免阴影带来的悬浮感。
  19. */
  20. export function ActivityCard({
  21. avatarUri,
  22. name,
  23. loanType,
  24. time,
  25. description,
  26. badgeText,
  27. badgeVariant = 'secondary',
  28. onPress,
  29. }: ActivityCardProps) {
  30. return (
  31. <Pressable
  32. onPress={onPress}
  33. className="bg-surface-container-lowest border border-outline-variant p-4 rounded-xl flex-row items-center gap-4"
  34. >
  35. {/* 头像 */}
  36. <View className="w-12 h-12 rounded-full overflow-hidden bg-surface-container">
  37. {avatarUri ? (
  38. <Image source={{ uri: avatarUri }} className="w-full h-full" contentFit="cover" />
  39. ) : (
  40. <View className="w-full h-full bg-secondary-container items-center justify-center">
  41. <Text className="text-on-secondary-container font-bold">{name[0]}</Text>
  42. </View>
  43. )}
  44. </View>
  45. {/* 正文 */}
  46. <View className="flex-1">
  47. <View className="flex-row justify-between items-start mb-1">
  48. <Text className="font-bold text-on-surface" numberOfLines={1}>
  49. {name} - {loanType}
  50. </Text>
  51. <Text className="text-[10px] text-on-surface-variant ml-2">{time}</Text>
  52. </View>
  53. <Text className="text-xs text-on-surface-variant" numberOfLines={1}>
  54. {description}
  55. </Text>
  56. </View>
  57. {/* 状态 */}
  58. <StatusBadge text={badgeText} variant={badgeVariant} />
  59. </Pressable>
  60. );
  61. }