import { Colors } from '@/constants/Colors'; import { useColorScheme } from '@/hooks/useColorScheme'; import { Ionicons } from '@expo/vector-icons'; import dayjs from 'dayjs'; import React from 'react'; import { Dimensions, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; export interface GoalItem { id: string; title: string; description?: string; time: string; category: 'workout' | 'finance' | 'personal' | 'work' | 'health'; priority?: 'high' | 'medium' | 'low'; } interface GoalCardProps { item: GoalItem; onPress?: (item: GoalItem) => void; } const { width: screenWidth } = Dimensions.get('window'); const CARD_WIDTH = (screenWidth - 60) * 0.65; // 显示1.5张卡片 const getCategoryIcon = (category: GoalItem['category']) => { switch (category) { case 'workout': return 'fitness-outline'; case 'finance': return 'card-outline'; case 'personal': return 'person-outline'; case 'work': return 'briefcase-outline'; case 'health': return 'heart-outline'; default: return 'checkmark-circle-outline'; } }; const getCategoryColor = (category: GoalItem['category']) => { switch (category) { case 'workout': return '#FF6B6B'; case 'finance': return '#4ECDC4'; case 'personal': return '#45B7D1'; case 'work': return '#96CEB4'; case 'health': return '#FFEAA7'; default: return '#DDA0DD'; } }; const getPriorityColor = (priority: GoalItem['priority']) => { switch (priority) { case 'high': return '#FF4757'; case 'medium': return '#FFA502'; case 'low': return '#2ED573'; default: return '#747D8C'; } }; export function GoalCard({ item, onPress }: GoalCardProps) { const theme = useColorScheme() ?? 'light'; const colorTokens = Colors[theme]; const categoryColor = getCategoryColor(item.category); const categoryIcon = getCategoryIcon(item.category); const priorityColor = getPriorityColor(item.priority); const timeFormatted = dayjs(item.time).format('HH:mm'); return ( onPress?.(item)} activeOpacity={0.8} > {/* 顶部标签和优先级 */} {item.category} {item.priority && ( )} {/* 主要内容 */} {item.title} {item.description && ( {item.description} )} {/* 底部时间 */} {timeFormatted} ); } const styles = StyleSheet.create({ container: { width: CARD_WIDTH, height: 140, marginHorizontal: 8, borderRadius: 20, padding: 16, elevation: 6, position: 'relative', }, header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12, }, categoryBadge: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 8, paddingVertical: 4, borderRadius: 12, backgroundColor: '#4ECDC4', }, categoryText: { fontSize: 10, fontWeight: '600', color: '#fff', marginLeft: 4, textTransform: 'capitalize', }, priorityDot: { width: 8, height: 8, borderRadius: 4, backgroundColor: '#FF4757', }, content: { flex: 1, justifyContent: 'center', }, title: { fontSize: 16, fontWeight: '700', lineHeight: 20, marginBottom: 4, }, description: { fontSize: 12, lineHeight: 16, opacity: 0.7, }, footer: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginTop: 12, }, timeContainer: { flexDirection: 'row', alignItems: 'center', }, timeText: { fontSize: 12, fontWeight: '500', marginLeft: 4, }, });