import React, { useState, useEffect, useRef } from 'react'; import { motion } from 'framer-motion'; import _ from 'lodash'; const VisionOSCarousel = () => { // State for carousel and navigation const [activeChat, setActiveChat] = useState(0); const [showModelDropdown, setShowModelDropdown] = useState(false); const [showHistoryDropdown, setShowHistoryDropdown] = useState(false); const [activeModel, setActiveModel] = useState('Vision GPT-4'); const carouselRef = useRef(null); const [isDragging, setIsDragging] = useState(false); const [startX, setStartX] = useState(0); // Sample chat data const chats = [ { id: 1, title: "Project Atlas", preview: "Latest updates on the Atlas project integration..." }, { id: 2, title: "Meeting Notes", preview: "AI summary of yesterday's team meeting..." }, { id: 3, title: "Travel Planning", preview: "Vision's suggestions for your upcoming trip..." }, { id: 4, title: "Code Review", preview: "Analysis of the new codebase structure..." } ]; // AI models available in the system const aiModels = [ { id: 1, name: 'Vision GPT-4', icon: '🧠' }, { id: 2, name: 'Vision Assistant', icon: '👁️' }, { id: 3, name: 'Vision Coder', icon: '💻' }, { id: 4, name: 'Vision Creative', icon: '🎨' } ]; // Chat history entries const chatHistory = [ { id: 101, title: "Previous Projects", date: "Mar 15" }, { id: 102, title: "System Setup", date: "Mar 10" }, { id: 103, title: "Design Feedback", date: "Mar 5" }, { id: 104, title: "Initial Consultation", date: "Feb 28" } ]; // Handle swipe gesture for carousel const handleTouchStart = (e) => { setIsDragging(true); setStartX(e.touches[0].clientX); }; const handleTouchMove = (e) => { if (!isDragging) return; const currentX = e.touches[0].clientX; const diff = startX - currentX; if (Math.abs(diff) > 50) { if (diff > 0 && activeChat < chats.length - 1) { setActiveChat(activeChat + 1); setIsDragging(false); } else if (diff < 0 && activeChat > 0) { setActiveChat(activeChat - 1); setIsDragging(false); } } }; const handleTouchEnd = () => { setIsDragging(false); }; // Handle mouse swipe for desktop const handleMouseDown = (e) => { setIsDragging(true); setStartX(e.clientX); }; const handleMouseMove = (e) => { if (!isDragging) return; const currentX = e.clientX; const diff = startX - currentX; if (Math.abs(diff) > 50) { if (diff > 0 && activeChat < chats.length - 1) { setActiveChat(activeChat + 1); setIsDragging(false); } else if (diff < 0 && activeChat > 0) { setActiveChat(activeChat - 1); setIsDragging(false); } } }; const handleMouseUp = () => { setIsDragging(false); }; // Navigation functions const nextChat = () => { if (activeChat < chats.length - 1) { setActiveChat(activeChat + 1); } }; const prevChat = () => { if (activeChat > 0) { setActiveChat(activeChat - 1); } }; const selectModel = (model) => { setActiveModel(model.name); setShowModelDropdown(false); }; const selectHistoryChat = (chat) => { // In a real app, this would load the historical chat setShowHistoryDropdown(false); }; return (
{chat.preview}
{/* Mock chat bubbles */}