import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Card } from './Card'; import { Card as CardType } from '../types/card'; import { atprotoOAuthService } from '../services/atproto-oauth'; import '../styles/GachaAnimation.css'; interface GachaAnimationProps { card: CardType; animationType: string; onComplete: () => void; } export const GachaAnimation: React.FC = ({ card, animationType, onComplete }) => { const [phase, setPhase] = useState<'opening' | 'revealing' | 'complete'>('opening'); const [showCard, setShowCard] = useState(false); const [isSharing, setIsSharing] = useState(false); useEffect(() => { const timer1 = setTimeout(() => setPhase('revealing'), 1500); const timer2 = setTimeout(() => { setPhase('complete'); setShowCard(true); }, 3000); return () => { clearTimeout(timer1); clearTimeout(timer2); }; }, [onComplete]); const handleCardClick = () => { if (showCard) { onComplete(); } }; const handleSaveToCollection = async (e: React.MouseEvent) => { e.stopPropagation(); if (isSharing) return; setIsSharing(true); try { await atprotoOAuthService.saveCardToCollection(card); alert('カードデータをatprotoコレクションに保存しました!'); } catch (error) { // Failed to save card alert('保存に失敗しました。認証が必要かもしれません。'); } finally { setIsSharing(false); } }; const getEffectClass = () => { switch (animationType) { case 'unique': return 'effect-unique'; case 'kira': return 'effect-kira'; case 'rare': return 'effect-rare'; default: return 'effect-normal'; } }; return (
{phase === 'opening' && (
)} {phase === 'revealing' && ( )} {phase === 'complete' && showCard && (
クリックして閉じる
)} {animationType === 'unique' && (
)}
); };