import React, { useState, useEffect, useRef } from 'react'; import { ChevronLeft, ChevronRight, Download, Maximize2, Play, Pause } from 'lucide-react'; import { useTheme } from '../../../contexts/ThemeContext'; import { AuthenticatedImage, Button } from '../../common'; import type { BaseGalleryLayoutProps } from './BaseGalleryLayout'; export const CarouselGalleryLayout: React.FC = ({ photos, onPhotoClick, onDownload, allowDownloads = true, // selectedPhotos = new Set(), // isSelectionMode = false }) => { const { theme } = useTheme(); const [currentIndex, setCurrentIndex] = useState(0); const [isPlaying, setIsPlaying] = useState(false); const intervalRef = useRef | null>(null); const gallerySettings = theme.gallerySettings || {}; const autoplay = gallerySettings.carouselAutoplay || false; const interval = gallerySettings.carouselInterval || 5000; const showThumbnails = gallerySettings.carouselShowThumbnails !== false; // Auto-play functionality useEffect(() => { if (isPlaying && photos.length > 1) { intervalRef.current = setInterval(() => { setCurrentIndex((prev) => (prev + 1) % photos.length); }, interval); } else if (intervalRef.current) { clearInterval(intervalRef.current); } return () => { if (intervalRef.current) clearInterval(intervalRef.current); }; }, [isPlaying, photos.length, interval]); // Start autoplay if enabled useEffect(() => { if (autoplay) { setIsPlaying(true); } }, [autoplay]); const goToPrevious = () => { setCurrentIndex((prev) => (prev - 1 + photos.length) % photos.length); }; const goToNext = () => { setCurrentIndex((prev) => (prev + 1) % photos.length); }; const togglePlayPause = () => { setIsPlaying(!isPlaying); }; if (photos.length === 0) return null; const currentPhoto = photos[currentIndex]; return (
{/* Main Carousel */}
{/* Navigation Controls */}
{/* Top Controls */}
{currentIndex + 1} / {photos.length} {currentPhoto.category_name && ( {currentPhoto.category_name} )}
{allowDownloads && ( )}
{/* Progress Bar */} {isPlaying && (
)}
{/* Thumbnails */} {showThumbnails && photos.length > 1 && (
{photos.map((photo, index) => ( ))}
)}
); };