import { useEffect, useState } from 'react'; import { Button, Group, Text, Flex } from '@mantine/core'; import { IconShieldLock, IconBolt, IconDeviceMobile } from '@tabler/icons-react'; import classes from './Introduction.module.css'; import { useNavigate } from 'react-router-dom'; import useWindow, { ElectronTheme } from '@/app/hooks/useWindow'; import { AnimatedButton } from '@/app/components/AnimatedButton/AnimatedButton'; const slides = [ { title: 'Security', description: 'Your data is protected by modern encryption and stays only on your device', icon: IconShieldLock, color: '#4CAF50', }, { title: 'Speed', description: 'Instant synchronization and fast performance without delays', icon: IconBolt, color: '#FF9800', }, { title: 'Simple Interface', description: 'Intuitive design that is clear at first glance', icon: IconDeviceMobile, color: '#2196F3', }, ]; export function Introduction() { const navigate = useNavigate(); const {setSize, setResizeble, setTheme} = useWindow(); const [activeSlide, setActiveSlide] = useState(0); const [touchStart, setTouchStart] = useState(null); const [touchEnd, setTouchEnd] = useState(null); // Минимальное расстояние свайпа (в px) const minSwipeDistance = 50; useEffect(() => { setSize(385, 555); setResizeble(false); setTheme(ElectronTheme.SYSTEM); }, []); const handleGetStarted = () => { navigate('/create-seed'); }; const goToSlide = (index: number) => { setActiveSlide(index); }; const nextSlide = () => { setActiveSlide((prev) => (prev + 1) % slides.length); }; const prevSlide = () => { setActiveSlide((prev) => (prev - 1 + slides.length) % slides.length); }; const onTouchStart = (e: React.TouchEvent) => { setTouchEnd(null); setTouchStart(e.targetTouches[0].clientX); }; const onTouchMove = (e: React.TouchEvent) => { setTouchEnd(e.targetTouches[0].clientX); }; const onTouchEnd = () => { if (!touchStart || !touchEnd) return; const distance = touchStart - touchEnd; const isLeftSwipe = distance > minSwipeDistance; const isRightSwipe = distance < -minSwipeDistance; if (isLeftSwipe) { nextSlide(); } else if (isRightSwipe) { prevSlide(); } }; const handleCarouselClick = () => { nextSlide(); }; const CurrentIcon = slides[activeSlide].icon; return (
{slides[activeSlide].title} {slides[activeSlide].description}
{slides.map((_, index) => (
Get Started
); }