// components/exercises/ModalExerciseDetails.tsx import React from 'react'; import { View, ScrollView, Modal, TouchableOpacity } from 'react-native'; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import { NavigationContainer } from '@react-navigation/native'; import { Text } from '@/components/ui/text'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Separator } from '@/components/ui/separator'; import { Dumbbell, Target, Calendar, Hash, AlertCircle, LineChart, Settings, X } from 'lucide-react-native'; import { ExerciseDisplay } from '@/types/exercise'; import { useTheme } from '@react-navigation/native'; import { useColorScheme } from '@/lib/useColorScheme'; import type { CustomTheme } from '@/lib/theme'; const Tab = createMaterialTopTabNavigator(); interface ModalExerciseDetailsProps { exercise: ExerciseDisplay | null; open: boolean; onClose: () => void; onEdit?: () => void; } // Info Tab Component function InfoTab({ exercise, onEdit }: { exercise: ExerciseDisplay; onEdit?: () => void }) { const { title, type, category, equipment, description, instructions = [], tags = [], source = 'local', usageCount, lastUsed } = exercise; return ( {/* Basic Info Section */} {source} {type} {/* Category & Equipment Section */} Category {category} {equipment && ( Equipment {equipment} )} {/* Description Section */} {description && ( Description {description} )} {/* Tags Section */} {tags.length > 0 && ( Tags {tags.map((tag: string) => ( {tag} ))} )} {/* Usage Stats Section */} {(usageCount || lastUsed) && ( Usage {usageCount && ( Used {usageCount} times )} {lastUsed && ( Last used: {lastUsed.toLocaleDateString()} )} )} {/* Edit Button */} {onEdit && ( )} ); } // Progress Tab Component function ProgressTab({ exercise }: { exercise: ExerciseDisplay }) { // Mock data for the progress chart const weightData = [ { date: 'Jan 10', weight: 135 }, { date: 'Jan 17', weight: 140 }, { date: 'Jan 24', weight: 145 }, { date: 'Jan 31', weight: 150 }, { date: 'Feb 7', weight: 155 }, { date: 'Feb 14', weight: 155 }, { date: 'Feb 21', weight: 160 }, { date: 'Feb 28', weight: 165 }, ]; const volumeData = [ { date: 'Jan 10', volume: 1350 }, { date: 'Jan 17', volume: 1400 }, { date: 'Jan 24', volume: 1450 }, { date: 'Jan 31', volume: 1500 }, { date: 'Feb 7', volume: 1550 }, { date: 'Feb 14', volume: 1550 }, { date: 'Feb 21', volume: 1600 }, { date: 'Feb 28', volume: 1650 }, ]; return ( {/* Progress Chart */} Weight Progress Max: 165 kg Last 8 weeks {/* Chart Container */} {/* Y-axis labels */} 165kg 150kg 135kg {/* Chart visualization */} {weightData.map((item, index) => ( {item.date.split(' ')[1]} ))} {/* Grid lines */} {/* Volume Chart */} Volume Progress {/* Chart Content */} Total: 10,500 kg Last 8 weeks {/* Line chart for volume */} {/* Y-axis labels */} 1650 1500 1350 {/* Line chart */} {/* Draw the line */} {/* Data points */} {volumeData.map((item, index) => ( ))} {/* X-axis labels */} {volumeData.map((item, index) => ( {item.date.split(' ')[1]} ))} {/* Grid lines */} {/* Personal Records Section */} Personal Records Max Weight 165 kg Achieved on Feb 28, 2025 Max Reps 12 reps at 135 kg Achieved on Jan 10, 2025 Best Volume 1650 kg Achieved on Feb 28, 2025 ); } // Form Tab Component function FormTab({ exercise }: { exercise: ExerciseDisplay }) { const { instructions = [] } = exercise; return ( {/* Instructions Section */} {instructions.length > 0 ? ( Instructions {instructions.map((instruction: string, index: number) => ( {index + 1}. {instruction} ))} ) : ( No form instructions available )} {/* Placeholder for Media */} Video demos coming soon ); } // Settings Tab Component function SettingsTab({ exercise }: { exercise: ExerciseDisplay }) { return ( {/* Format Settings */} Exercise Settings Format {exercise.format && Object.entries(exercise.format).map(([key, enabled]) => ( enabled && ( {key} ) ))} Units {exercise.format_units && Object.entries(exercise.format_units).map(([key, unit]) => ( {key}: {String(unit)} ))} ); } export function ModalExerciseDetails({ exercise, open, onClose, onEdit }: ModalExerciseDetailsProps) { const theme = useTheme() as CustomTheme; const { isDarkColorScheme } = useColorScheme(); // Return null if not open or if exercise is null if (!open || !exercise) return null; return ( {/* Header */} {exercise.title} {/* Tab Navigator */} {/* Using NavigationContainer without the independent prop */} {/* Let's use a more compatible approach without NavigationContainer */} {() => } {() => } {() => } {() => } ); }