// app/(workout)/complete.tsx import React, { useEffect } from 'react'; import { View, Modal, TouchableOpacity } from 'react-native'; import { router } from 'expo-router'; import { Text } from '@/components/ui/text'; import { X } from 'lucide-react-native'; import { useWorkoutStore } from '@/stores/workoutStore'; import { WorkoutCompletionFlow } from '@/components/workout/WorkoutCompletionFlow'; import { WorkoutCompletionOptions } from '@/types/workout'; import { useColorScheme } from '@/lib/theme/useColorScheme'; /** * Workout Completion Screen * * This modal screen is presented when a user chooses to complete their workout. * It serves as a container for the multi-step completion flow, handling: * - Modal presentation and dismissal * - Delegating completion logic to the WorkoutCompletionFlow component * * The screen acts primarily as a UI wrapper, with the core completion logic * handled by the WorkoutStore and the step-by-step flow managed by the * WorkoutCompletionFlow component. * * Note: Workout timing is already stopped at this point, as the end time * was set when the user confirmed finishing in the create screen. */ export default function CompleteWorkoutScreen() { const { resumeWorkout, activeWorkout } = useWorkoutStore(); const { isDarkColorScheme } = useColorScheme(); // Check if we have a workout to complete if (!activeWorkout) { // If there's no active workout, redirect back to the home screen router.replace('/(tabs)'); return null; } // Get the completeWorkout function from the store const { completeWorkout } = useWorkoutStore(); // Handle complete with options const handleComplete = async (options: WorkoutCompletionOptions) => { // Complete the workout with the provided options await completeWorkout(options); }; // Handle cancellation (go back to workout) const handleCancel = () => { // Go back to the workout screen router.back(); }; return ( {/* Header */} Complete Workout {/* Content */} ); }