import React, { useRef } from 'react'; import { View, Text, StyleSheet, Dimensions, ScrollView, TouchableOpacity, Animated } from 'react-native'; import { LinearGradient } from 'expo-linear-gradient'; import { Ionicons } from '@expo/vector-icons'; import { theme } from '../styles/theme'; import { CircularProgress } from './CircularProgress'; import type { FitnessGoal } from '../services/fitnessGoals'; const { width } = Dimensions.get('window'); const CARD_WIDTH = width * 0.8; const SPACING = 20; interface GoalCarouselProps { goals: FitnessGoal[]; onGoalPress: (goal: FitnessGoal) => void; } export function GoalCarousel({ goals, onGoalPress }: GoalCarouselProps) { const scrollX = useRef(new Animated.Value(0)).current; if (goals.length === 0) { return ( No active goals ); } return ( {goals.map((goal, index) => { const inputRange = [ (index - 1) * (CARD_WIDTH + SPACING), index * (CARD_WIDTH + SPACING), (index + 1) * (CARD_WIDTH + SPACING), ]; const scale = scrollX.interpolate({ inputRange, outputRange: [0.9, 1, 0.9], extrapolate: 'clamp', }); const opacity = scrollX.interpolate({ inputRange, outputRange: [0.7, 1, 0.7], extrapolate: 'clamp', }); return ( onGoalPress(goal)} > {goal.priority.toUpperCase()} {goal.title} {goal.description} {goal.currentValue} / {goal.targetValue} {goal.unit} Target: {goal.targetDate ? new Date(goal.targetDate).toLocaleDateString() : 'No date'} ); })} ); } const styles = StyleSheet.create({ scrollContent: { paddingHorizontal: (width - CARD_WIDTH) / 2, paddingVertical: 20, }, emptyContainer: { height: 200, justifyContent: 'center', alignItems: 'center', }, emptyText: { color: theme.colors.gray500, fontSize: 16, }, cardContainer: { width: CARD_WIDTH, marginRight: SPACING, }, card: { borderRadius: 24, padding: 24, height: 320, justifyContent: 'space-between', borderWidth: 1, borderColor: 'rgba(0,0,0,0.05)', }, cardHeader: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 16, }, iconContainer: { shadowColor: theme.colors.primary, shadowOffset: { width: 0, height: 4 }, shadowOpacity: 0.3, shadowRadius: 8, elevation: 4, }, iconGradient: { width: 48, height: 48, borderRadius: 16, justifyContent: 'center', alignItems: 'center', }, priorityBadge: { backgroundColor: 'rgba(59, 130, 246, 0.1)', paddingHorizontal: 12, paddingVertical: 6, borderRadius: 12, }, priorityText: { color: theme.colors.primary, fontSize: 12, fontWeight: '700', }, title: { fontSize: 24, fontWeight: '800', color: theme.colors.gray900, marginBottom: 8, }, description: { fontSize: 14, color: theme.colors.gray500, marginBottom: 24, lineHeight: 20, }, progressContainer: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 24, }, progressDetails: { alignItems: 'flex-end', }, progressValue: { fontSize: 24, fontWeight: '700', color: theme.colors.gray900, }, progressUnit: { fontSize: 14, color: theme.colors.gray500, fontWeight: '500', }, footer: { borderTopWidth: 1, borderTopColor: theme.colors.gray100, paddingTop: 16, }, date: { fontSize: 12, color: theme.colors.gray400, fontWeight: '500', }, });