import { invoke } from '@tauri-apps/api/core'; import { useTimerStore, TimerPhase } from '../store/timerStore'; import { useTaskStore } from '../store/taskStore'; const RING_SIZE = 280; const STROKE = 8; const RADIUS = (RING_SIZE - STROKE) / 2; const CIRCUMFERENCE = 2 * Math.PI * RADIUS; function phaseLabel(phase: TimerPhase): string { switch (phase) { case 'work': return 'Focus'; case 'short_break': return 'Short Break'; case 'long_break': return 'Long Break'; } } function phaseColor(phase: TimerPhase): string { switch (phase) { case 'work': return 'var(--brass)'; case 'short_break': return 'var(--positive)'; case 'long_break': return 'var(--info)'; } } function eyebrowText(phase: TimerPhase, sessionCount: number): string { if (phase === 'work') { return `WORK ยท SESSION ${sessionCount + 1}`; } if (phase === 'short_break') return 'SHORT BREAK'; return 'LONG BREAK'; } function formatTime(secs: number): string { const m = Math.floor(secs / 60); const s = secs % 60; return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`; } export function TimerView() { const { phase, remainingSecs, totalSecs, running, sessionCount, currentTaskId } = useTimerStore(); const tasks = useTaskStore((s) => s.tasks); const currentTask = tasks.find((t) => t.id === currentTaskId) ?? null; const progress = totalSecs > 0 ? remainingSecs / totalSecs : 1; const dashOffset = CIRCUMFERENCE * (1 - progress); const arcColor = phaseColor(phase); const handleStart = () => invoke('start_timer'); const handlePause = () => invoke('pause_timer'); const handleSkip = () => invoke('skip_phase'); const handleReset = () => invoke('reset_timer'); return (