"use client" import { useState } from "react" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { X, ChevronLeft, ChevronRight, Download, ZoomIn, ZoomOut, RotateCw, Maximize2 } from "lucide-react" import { formatFileSize, type ImageFile } from "@/lib/image-utils" interface ImageGalleryProps { images: ImageFile[] className?: string } interface ImageModalProps { images: ImageFile[] currentIndex: number onClose: () => void onNavigate: (index: number) => void } function ImageModal({ images, currentIndex, onClose, onNavigate }: ImageModalProps) { const [zoom, setZoom] = useState(1) const [rotation, setRotation] = useState(0) const currentImage = images[currentIndex] const handlePrevious = () => { const newIndex = currentIndex > 0 ? currentIndex - 1 : images.length - 1 onNavigate(newIndex) setZoom(1) setRotation(0) } const handleNext = () => { const newIndex = currentIndex < images.length - 1 ? currentIndex + 1 : 0 onNavigate(newIndex) setZoom(1) setRotation(0) } const handleZoomIn = () => setZoom((prev) => Math.min(prev + 0.25, 3)) const handleZoomOut = () => setZoom((prev) => Math.max(prev - 0.25, 0.25)) const handleRotate = () => setRotation((prev) => (prev + 90) % 360) const handleDownload = () => { // 創建下載連結 const link = document.createElement("a") link.href = currentImage.url link.download = currentImage.name document.body.appendChild(link) link.click() document.body.removeChild(link) } return (