import type { FastingPlan } from '@/constants/Fasting'; import { Colors } from '@/constants/Colors'; import { IconSymbol } from '@/components/ui/IconSymbol'; import { useColorScheme } from '@/hooks/useColorScheme'; import React, { useMemo } from 'react'; import { ScrollView, StyleSheet, Text, TouchableOpacity, View, } from 'react-native'; type FastingPlanListProps = { plans: FastingPlan[]; activePlanId?: string | null; onSelectPlan: (plan: FastingPlan) => void; }; const difficultyLabel: Record = { 新手: '适合入门', 进阶: '脂代提升', 强化: '平台突破', }; export function FastingPlanList({ plans, activePlanId, onSelectPlan }: FastingPlanListProps) { const theme = useColorScheme() ?? 'light'; const colors = Colors[theme]; const sortedPlans = useMemo( () => plans.slice().sort((a, b) => a.fastingHours - b.fastingHours), [plans] ); return ( 单日计划 精选 {sortedPlans.map((plan) => { const isActive = plan.id === activePlanId; return ( onSelectPlan(plan)} > {plan.difficulty} {plan.badge && ( {plan.badge} )} {plan.title} {plan.subtitle} {plan.fastingHours} 小时断食 {difficultyLabel[plan.difficulty]} ); })} ); } const styles = StyleSheet.create({ wrapper: { marginTop: 32, }, headerRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12, paddingHorizontal: 4, }, headerTitle: { fontSize: 18, fontWeight: '700', color: '#2E3142', }, headerBadge: { paddingHorizontal: 12, paddingVertical: 6, borderRadius: 14, backgroundColor: 'rgba(53, 52, 69, 0.08)', }, headerBadgeText: { fontSize: 12, fontWeight: '600', color: '#353445', }, scrollContent: { paddingRight: 20, }, card: { width: 220, borderRadius: 24, paddingVertical: 18, paddingHorizontal: 18, marginRight: 16, borderWidth: 2, }, cardTopRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12, }, difficultyPill: { paddingHorizontal: 12, paddingVertical: 6, borderRadius: 16, }, difficultyText: { fontSize: 12, fontWeight: '600', }, badgePill: { paddingHorizontal: 10, paddingVertical: 6, borderRadius: 14, }, badgeText: { fontSize: 11, fontWeight: '600', }, cardTitle: { fontSize: 16, fontWeight: '700', color: '#2E3142', marginBottom: 6, }, cardSubtitle: { fontSize: 13, fontWeight: '500', color: '#5B6572', marginBottom: 12, }, metaRow: { marginTop: 'auto', }, metaItem: { flexDirection: 'row', alignItems: 'center', marginBottom: 6, }, metaText: { marginLeft: 6, fontSize: 12, color: '#5B6572', fontWeight: '500', }, });