import { useRef, useEffect } from 'react'; import { FONT_MONO } from '../../styles/fonts'; import { useGearReplayStore } from '../../stores/gearReplayStore'; interface HistoryReplayControllerProps { onClose: () => void; onFilterByScore: (minPct: number | null) => void; } const HistoryReplayController = ({ onClose, onFilterByScore }: HistoryReplayControllerProps) => { const isPlaying = useGearReplayStore(s => s.isPlaying); const snapshotRanges = useGearReplayStore(s => s.snapshotRanges); const frameCount = useGearReplayStore(s => s.historyFrames.length); const showTrails = useGearReplayStore(s => s.showTrails); const showLabels = useGearReplayStore(s => s.showLabels); const focusMode = useGearReplayStore(s => s.focusMode); const progressBarRef = useRef(null); const progressIndicatorRef = useRef(null); const timeDisplayRef = useRef(null); useEffect(() => { const unsub = useGearReplayStore.subscribe( s => s.currentTime, (currentTime) => { const { startTime, endTime } = useGearReplayStore.getState(); if (endTime <= startTime) return; const progress = (currentTime - startTime) / (endTime - startTime); if (progressBarRef.current) progressBarRef.current.value = String(Math.round(progress * 1000)); if (progressIndicatorRef.current) progressIndicatorRef.current.style.left = `${progress * 100}%`; if (timeDisplayRef.current) { timeDisplayRef.current.textContent = new Date(currentTime).toLocaleTimeString('ko-KR', { hour: '2-digit', minute: '2-digit' }); } }, ); return unsub; }, []); const store = useGearReplayStore; const btnStyle: React.CSSProperties = { background: 'none', border: '1px solid rgba(99,179,237,0.3)', borderRadius: 4, color: '#e2e8f0', cursor: 'pointer', padding: '2px 6px', fontSize: 10, fontFamily: FONT_MONO, }; const btnActiveStyle: React.CSSProperties = { ...btnStyle, background: 'rgba(99,179,237,0.15)', color: '#93c5fd', }; return (
{/* 프로그레스 바 */}
{snapshotRanges.map((pos, i) => (
))}
{/* 컨트롤 행 1: 재생 + 타임라인 */}
--:-- { const { startTime, endTime } = store.getState(); const progress = Number(e.target.value) / 1000; store.getState().pause(); store.getState().seek(startTime + progress * (endTime - startTime)); }} style={{ flex: 1, cursor: 'pointer', accentColor: '#fbbf24' }} title="히스토리 타임라인" aria-label="히스토리 타임라인" /> {frameCount}건
{/* 컨트롤 행 2: 표시 옵션 */}
| 일치율
); }; export default HistoryReplayController;