A focus session timer on a one-hour SVG dial: the remaining time is a tomato band that drains back to twelve o'clock, minute ticks light up with it, and before a block starts you drag the knob around the dial to set 5 to 60 minutes in 5-minute steps. Start, Pause and Resume morph in one button, a finished block springs its session dot and eases the whole screen into a calm break with a stretch to try, Skip break and +5 min, and an ambient sound chip shows a live level meter.
Or let your agent fetch it: connect the gluestack MCP server, then ask for focus-timer.

Details
Using gluestack-ui?
Optional. The screen is plain React Native; these components can stand in for its primitives.
1import { memo, useEffect, useRef, useState, type ComponentRef, type ReactNode } from 'react';2import { PanResponder, Platform, Pressable, ScrollView, StyleSheet, Text, TextInput, View, useColorScheme, useWindowDimensions } from 'react-native';3import Animated, {4 Easing,5 FadeIn,6 FadeInDown,7 cancelAnimation,8 interpolate,9 interpolateColor,10 useAnimatedProps,11 useAnimatedStyle,12 useSharedValue,13 withDelay,14 withRepeat,15 withSequence,16 withSpring,17 withTiming,18 type SharedValue,19} from 'react-native-reanimated';20import { useSafeAreaInsets } from 'react-native-safe-area-context';21import Svg, { Circle, Line, Path } from 'react-native-svg';22import { Check, ChevronDown, ChevronUp, CloudRain, Coffee, Flame, Moon, Pause, PersonStanding, Play, Plus, RotateCcw, SkipForward, VolumeX, Waves } from 'lucide-react-native';2324// ─── Brand ──────────────────────────────────────────────────────────────────25// The screen's accent and name. Every accent colour below derives from these, so changing them rebrands the screen.2627const ACCENT = '#E4572E';28const ACCENT_DARK = '#F4825F'; // the accent as text and ticks on dark backgrounds29const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill30const APP_NAME = 'Simmer';3132/** `hex` at `alpha` opacity, as rgba(). */33function tint(hex: string, alpha: number) {34 const n = parseInt(hex.slice(1), 16);35 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;36}3738/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */39function shade(hex: string, amount: number) {40 const n = parseInt(hex.slice(1), 16);41 const target = amount < 0 ? 255 : 0;42 const p = Math.abs(amount);43 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');44 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();45}4647// ─── Sample data ────────────────────────────────────────────────────────────4849type Task = { id: string; title: string; project: string; blocks: number };5051const TASKS: Task[] = [52 { id: 'q1', title: 'Draft the Q1 report', project: 'Finance', blocks: 4 },53 { id: 'onboarding', title: 'Review the onboarding flow', project: 'Design', blocks: 2 },54 { id: 'planning', title: 'Slides for Monday planning', project: 'Team', blocks: 3 },55 { id: 'inbox', title: 'Clear the support inbox', project: 'Support', blocks: 1 },56];5758const CYCLE = 4; // focus blocks before the long break59const SHORT_BREAK = 5; // minutes60const LONG_BREAK = 15;61const FACE_SECONDS = 3600; // the dial face is one hour, like a kitchen timer6263// The session opens mid-cycle and paused: block 3 of 4, 39:12 left of a 45 minute block.64const START = { planned: 45, left: 39 * 60 + 12, done: 2, banked: 90, blocks: 2 };65const STREAK_DAYS = 12;66const HELD = 3; // notifications Do not disturb is holding back6768// Minutes focused on each of the last six days; today is added live as the last bar.69const WEEK = [70 { day: 'S', name: 'Saturday', min: 60 },71 { day: 'S', name: 'Sunday', min: 45 },72 { day: 'M', name: 'Monday', min: 180 },73 { day: 'T', name: 'Tuesday', min: 135 },74 { day: 'W', name: 'Wednesday', min: 200 },75 { day: 'T', name: 'Thursday', min: 150 },76];7778const STRETCHES = [79 'Stand up, roll your shoulders back ten times and unclench your jaw.',80 'Look at something far away for 20 seconds, then refill your water.',81 'Lace your fingers, press your palms to the ceiling and hold for three breaths.',82];83const LONG_STRETCH = 'Four blocks done. Step outside for a short walk and leave the phone behind.';8485type SoundId = 'rain' | 'cafe' | 'brown' | 'off';86const SOUNDS: { id: SoundId; label: string; tempo: number }[] = [87 { id: 'rain', label: 'Rain', tempo: 0.7 },88 { id: 'cafe', label: 'Cafe', tempo: 1 },89 { id: 'brown', label: 'Brown noise', tempo: 1.7 },90 { id: 'off', label: 'Off', tempo: 1 },91];92const SOUND_ICON = { rain: CloudRain, cafe: Coffee, brown: Waves, off: VolumeX };9394// Demo only: every focus block and break plays out in about this many real seconds, so the switch to break mode95// can be seen without waiting. Set it to 0 to run in real time.96const DEMO_BLOCK_SECONDS = 20;9798// ─── Palette ────────────────────────────────────────────────────────────────99100// Breaks shift to a calm sage. It is not the brand, so it stays literal when the accent changes.101const CALM = '#3F9478';102const CALM_LIGHT = '#6BBF9F';103const TABULAR = { fontVariant: ['tabular-nums' as const] };104const SPRING = { damping: 16, stiffness: 240, mass: 0.7 };105const NO_OUTLINE = Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null;106107function usePalette() {108 const dark = useColorScheme() === 'dark';109 return {110 dark,111 bg: dark ? '#1D1B1A' : '#FBF8F6',112 calmBg: dark ? '#1A1E1C' : '#F1F6F3',113 surface: dark ? '#272423' : '#FFFFFF',114 border: dark ? 'rgba(255,255,255,0.06)' : 'rgba(70,44,32,0.07)',115 face: dark ? '#292625' : '#FFFFFF',116 chip: dark ? '#312D2B' : '#F4EEEA',117 fg: dark ? '#F4EFEB' : '#221C19',118 muted: dark ? '#A59C96' : '#857A73',119 faint: dark ? '#5A5350' : '#D3CAC4',120 track: dark ? '#35312F' : '#F3EDE8',121 tickOn: dark ? '#E7DFDA' : '#3A312C',122 bar: dark ? '#423C39' : '#EAE1DB',123 accentText: dark ? ACCENT_DARK : shade(ACCENT, 0.16),124 accentSoft: dark ? tint(ACCENT, 0.22) : tint(ACCENT, 0.11),125 accentGhost: dark ? tint(ACCENT_DARK, 0.3) : tint(ACCENT, 0.22),126 calmArc: dark ? CALM_LIGHT : CALM,127 calmText: dark ? '#8AD3B5' : '#2C7460',128 calmSoft: dark ? 'rgba(107,191,159,0.18)' : 'rgba(63,148,120,0.12)',129 calmGhost: dark ? 'rgba(107,191,159,0.3)' : 'rgba(63,148,120,0.22)',130 pill: dark ? '#3B3634' : '#2A2421',131 pillText: '#F7F1EE',132 switchOff: dark ? '#3A3634' : '#E9E2DD',133 scrim: dark ? 'rgba(0,0,0,0.55)' : 'rgba(34,28,25,0.32)',134 sheet: dark ? '#282524' : '#FFFFFF',135 };136}137type Palette = ReturnType<typeof usePalette>;138139type Mode = 'focus' | 'break';140type Run = 'idle' | 'running' | 'paused';141142const mmss = (s: number) => `${String(Math.floor(s / 60)).padStart(2, '0')}:${String(Math.floor(s % 60)).padStart(2, '0')}`;143const clock = (s: number) => `${Math.floor(s / 60)}:${String(Math.floor(s % 60)).padStart(2, '0')}`;144const hm = (min: number) => (min >= 60 ? `${Math.floor(min / 60)}h ${min % 60}m` : `${min}m`);145146// ─── Small pieces ───────────────────────────────────────────────────────────147148function Tap({ children, label, onPress, disabled, to = 0.94 }: { children: ReactNode; label: string; onPress?: () => void; disabled?: boolean; to?: number }) {149 const scale = useSharedValue(1);150 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));151 return (152 <Pressable153 role="button"154 aria-label={label}155 aria-disabled={disabled}156 disabled={disabled}157 onPress={onPress}158 onPressIn={() => (scale.value = withSpring(to, SPRING))}159 onPressOut={() => (scale.value = withSpring(1, SPRING))}160 >161 <Animated.View style={style}>{children}</Animated.View>162 </Pressable>163 );164}165166/** A tiny dial with a wedge taken out: the app mark. */167function AppMark() {168 return (169 <Svg width={24} height={24} viewBox="0 0 24 24">170 <Circle cx={12} cy={12} r={11} fill={ACCENT} />171 <Path d="M12 12 L12 4 A8 8 0 0 1 17.66 17.66 Z" fill={ON_ACCENT} opacity={0.92} />172 </Svg>173 );174}175176function DndToggle({ on, onToggle, pal }: { on: boolean; onToggle: () => void; pal: Palette }) {177 const t = useSharedValue(on ? 1 : 0);178 useEffect(() => {179 t.value = withSpring(on ? 1 : 0, SPRING);180 }, [on, t]);181 const off = pal.switchOff;182 const track = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(t.value, [0, 1], [off, ACCENT]) }));183 const knob = useAnimatedStyle(() => ({ transform: [{ translateX: t.value * 20 }] }));184 return (185 <Pressable role="switch" aria-checked={on} aria-label="Do not disturb" hitSlop={8} onPress={onToggle}>186 <Animated.View style={[styles.switchTrack, track]}>187 <Animated.View style={[styles.switchKnob, knob]}>188 <Moon size={13} color={on ? ACCENT : pal.muted} fill={on ? ACCENT : 'transparent'} strokeWidth={2.4} />189 </Animated.View>190 </Animated.View>191 </Pressable>192 );193}194195/** Drops in at the top while a session runs with Do not disturb on. */196function QuietPill({ shown, pal }: { shown: boolean; pal: Palette }) {197 const t = useSharedValue(0);198 const booted = useRef(false);199 useEffect(() => {200 t.value = withDelay(booted.current ? 0 : 520, withSpring(shown ? 1 : 0, { damping: 14, stiffness: 190, mass: 0.7 }));201 booted.current = true;202 }, [shown, t]);203 const style = useAnimatedStyle(() => ({204 opacity: Math.min(1, Math.max(0, t.value * 1.4)),205 transform: [{ translateX: (1 - t.value) * 28 }, { scale: 0.84 + t.value * 0.16 }],206 }));207 return (208 <View style={styles.pillSlot}>209 <Animated.View aria-hidden={!shown} aria-label={`Do not disturb is on, ${HELD} notifications held`} style={[styles.pill, { backgroundColor: pal.pill }, style]}>210 <Moon size={12} color={pal.pillText} fill={pal.pillText} />211 <Text style={[styles.pillText, { color: pal.pillText }]}>Do not disturb</Text>212 <View style={styles.pillCount}>213 <Text style={[styles.pillCountText, TABULAR]}>{HELD}</Text>214 </View>215 </Animated.View>216 </View>217 );218}219220// ─── Session dots: done blocks fill, the current one stretches and fills ─────221222function Dot({ state, left, total, pal }: { state: 'done' | 'now' | 'next'; left: SharedValue<number>; total: SharedValue<number>; pal: Palette }) {223 const w = useSharedValue(state === 'now' ? 26 : 9);224 const pop = useSharedValue(1);225 const was = useRef(state);226 useEffect(() => {227 w.value = withSpring(state === 'now' ? 26 : 9, SPRING);228 if (state === 'done' && was.current !== 'done') {229 pop.value = withSequence(withTiming(1.5, { duration: 160, easing: Easing.out(Easing.quad) }), withTiming(1, { duration: 260, easing: Easing.out(Easing.back(2)) }));230 }231 was.current = state;232 }, [state, w, pop]);233 const box = useAnimatedStyle(() => ({ width: w.value, transform: [{ scale: pop.value }] }));234 const fill = useAnimatedStyle(() => {235 const frac = state === 'done' ? 1 : state === 'now' ? Math.min(1, Math.max(0, 1 - left.value / Math.max(1, total.value))) : 0;236 return { width: w.value * frac };237 });238 return (239 <Animated.View style={[styles.dot, { backgroundColor: pal.track }, box]}>240 <Animated.View style={[styles.dotFill, fill]} />241 </Animated.View>242 );243}244245function SessionDots({ done, mode, left, total, pal }: { done: number; mode: Mode; left: SharedValue<number>; total: SharedValue<number>; pal: Palette }) {246 return (247 <View role="progressbar" aria-label={`${done} of ${CYCLE} focus blocks done`} style={styles.dots}>248 {Array.from({ length: CYCLE }, (_, i) => (249 <Dot key={i} state={i < done ? 'done' : i === done && mode === 'focus' ? 'now' : 'next'} left={left} total={total} pal={pal} />250 ))}251 <Coffee size={13} color={pal.muted} strokeWidth={2.2} style={styles.dotsCoffee} />252 <Text style={[styles.dotsNote, { color: pal.muted }]}>{LONG_BREAK} min after {CYCLE}</Text>253 </View>254 );255}256257// ─── The dial: one hour of ticks, the remaining time as a band that drains ───258259const AnimatedCircle = Animated.createAnimatedComponent(Circle);260const KNOB = 30;261const BAND = 24;262263const Ticks = memo(function Ticks({ size, lit, ghost, on, ghostColor, off }: { size: number; lit: number; ghost: number; on: string; ghostColor: string; off: string }) {264 const c = size / 2;265 const outer = c - 4;266 return (267 <Svg width={size} height={size}>268 {Array.from({ length: 60 }, (_, i) => {269 const a = (i / 60) * Math.PI * 2;270 const major = i % 5 === 0;271 const inner = outer - (major ? 10 : 5);272 const sin = Math.sin(a);273 const cos = Math.cos(a);274 return (275 <Line276 key={i}277 x1={c + outer * sin}278 y1={c - outer * cos}279 x2={c + inner * sin}280 y2={c - inner * cos}281 stroke={i < lit ? on : i < ghost ? ghostColor : off}282 strokeWidth={major ? 2.2 : 1.3}283 strokeLinecap="round"284 />285 );286 })}287 </Svg>288 );289});290291function Band({ size, radius, seconds, color }: { size: number; radius: number; seconds: SharedValue<number>; color: string }) {292 const len = 2 * Math.PI * radius;293 const props = useAnimatedProps(() => ({ strokeDashoffset: len * (1 - Math.min(1, Math.max(0, seconds.value / FACE_SECONDS))) }));294 return <AnimatedCircle cx={size / 2} cy={size / 2} r={radius} stroke={color} strokeWidth={BAND} strokeDasharray={`${len} ${len}`} animatedProps={props} fill="none" />;295}296297type DialProps = {298 size: number;299 left: SharedValue<number>;300 total: SharedValue<number>;301 modeSV: SharedValue<number>;302 mode: Mode;303 litMin: number;304 ghostMin: number;305 editable: boolean;306 value: number;307 onSet: (min: number) => void;308 onDrag: (on: boolean) => void;309 pal: Palette;310 children: ReactNode;311};312313function Dial({ size, left, total, modeSV, mode, litMin, ghostMin, editable, value, onSet, onDrag, pal, children }: DialProps) {314 const c = size / 2;315 const rb = c - 34; // the band's centre line316 const host = useRef<ComponentRef<typeof View>>(null);317 const box = useRef({ x: 0, y: 0 });318 const cur = useRef(value);319 cur.current = value;320 const latest = useRef({ editable, onSet, onDrag, size });321 latest.current = { editable, onSet, onDrag, size };322323 const big = useSharedValue(editable ? 1 : 0);324 const grab = useSharedValue(0);325 const pulse = useSharedValue(0);326 useEffect(() => {327 big.value = withSpring(editable ? 1 : 0, SPRING);328 if (!editable) {329 cancelAnimation(pulse);330 pulse.value = 0;331 return;332 }333 pulse.value = withRepeat(withTiming(1, { duration: 1600, easing: Easing.out(Easing.quad) }), -1, false);334 return () => cancelAnimation(pulse);335 }, [editable, big, pulse]);336337 // Angle from 12 o'clock to minutes, snapped to 5. It stops at 60 and at 5 instead of wrapping round.338 const apply = (px: number, py: number) => {339 const half = latest.current.size / 2;340 const dx = px - (box.current.x + half);341 const dy = py - (box.current.y + half);342 let a = Math.atan2(dx, -dy);343 if (a < 0) a += Math.PI * 2;344 let m = Math.round(((a / (Math.PI * 2)) * 60) / 5) * 5;345 const prev = cur.current;346 if (m === 0 || m === 60) m = prev >= 30 ? 60 : 5;347 else if (prev >= 45 && m <= 15) m = 60;348 else if (prev <= 15 && m >= 45) m = 5;349 m = Math.max(5, Math.min(60, m));350 if (m !== prev) {351 cur.current = m;352 latest.current.onSet(m);353 }354 };355 const applyRef = useRef(apply);356 applyRef.current = apply;357358 const pan = useRef(359 PanResponder.create({360 onStartShouldSetPanResponder: () => latest.current.editable,361 onMoveShouldSetPanResponder: () => latest.current.editable,362 onPanResponderTerminationRequest: () => false,363 onPanResponderGrant: (e) => {364 const { pageX, pageY } = e.nativeEvent;365 grab.value = withSpring(1, SPRING);366 latest.current.onDrag(true);367 applyRef.current(pageX, pageY);368 host.current?.measureInWindow((x: number, y: number) => {369 box.current = { x, y };370 applyRef.current(pageX, pageY);371 });372 },373 onPanResponderMove: (e) => applyRef.current(e.nativeEvent.pageX, e.nativeEvent.pageY),374 onPanResponderRelease: () => {375 grab.value = withSpring(0, SPRING);376 latest.current.onDrag(false);377 },378 onPanResponderTerminate: () => {379 grab.value = withSpring(0, SPRING);380 latest.current.onDrag(false);381 },382 })383 ).current;384385 const focusLayer = useAnimatedStyle(() => ({ opacity: 1 - modeSV.value }));386 const calmLayer = useAnimatedStyle(() => ({ opacity: modeSV.value }));387 const knobStyle = useAnimatedStyle(() => {388 const a = (Math.min(left.value, FACE_SECONDS) / FACE_SECONDS) * Math.PI * 2;389 const s = interpolate(big.value, [0, 1], [0.38, 1]) * (1 + grab.value * 0.16);390 return { transform: [{ translateX: c + rb * Math.sin(a) - KNOB / 2 }, { translateY: c - rb * Math.cos(a) - KNOB / 2 }, { scale: s }] };391 });392 const ringStyle = useAnimatedStyle(() => ({ opacity: big.value * (1 - pulse.value) * 0.7, transform: [{ scale: 1 + pulse.value * 0.9 }] }));393 const knobColor = mode === 'break' ? pal.calmArc : ACCENT;394395 return (396 <View397 ref={host}398 role={editable ? 'slider' : undefined}399 aria-label={editable ? 'Focus length, drag around the dial' : undefined}400 aria-valuenow={editable ? value : undefined}401 aria-valuemin={editable ? 5 : undefined}402 aria-valuemax={editable ? 60 : undefined}403 onLayout={() => host.current?.measureInWindow((x: number, y: number) => (box.current = { x, y }))}404 style={{ width: size, height: size }}405 {...pan.panHandlers}406 >407 <Animated.View entering={FadeIn.duration(500)} style={[StyleSheet.absoluteFill, styles.face, { borderRadius: c, backgroundColor: pal.face, borderColor: pal.border }, pal.dark ? styles.faceDark : styles.faceLight]} />408 <Animated.View entering={FadeIn.delay(380).duration(600)} style={[StyleSheet.absoluteFill, styles.passThrough]}>409 <Ticks size={size} lit={litMin} ghost={ghostMin} on={pal.tickOn} ghostColor={mode === 'break' ? pal.calmGhost : pal.accentGhost} off={pal.faint} />410 </Animated.View>411 <View style={[StyleSheet.absoluteFill, styles.passThrough]}>412 <Svg width={size} height={size}>413 <Circle cx={c} cy={c} r={rb} stroke={pal.track} strokeWidth={BAND} fill="none" />414 </Svg>415 </View>416 <Animated.View style={[StyleSheet.absoluteFill, styles.turn, styles.passThrough, focusLayer]}>417 <Svg width={size} height={size}>418 <Band size={size} radius={rb} seconds={total} color={pal.accentGhost} />419 <Band size={size} radius={rb} seconds={left} color={ACCENT} />420 </Svg>421 </Animated.View>422 <Animated.View style={[StyleSheet.absoluteFill, styles.turn, styles.passThrough, calmLayer]}>423 <Svg width={size} height={size}>424 <Band size={size} radius={rb} seconds={total} color={pal.calmGhost} />425 <Band size={size} radius={rb} seconds={left} color={pal.calmArc} />426 </Svg>427 </Animated.View>428 <Animated.View style={[styles.knobBox, knobStyle]}>429 <Animated.View style={[styles.knobRing, { borderColor: knobColor }, ringStyle]} />430 <View style={[styles.knob, { borderColor: knobColor }]} />431 </Animated.View>432 <View style={[StyleSheet.absoluteFill, styles.dialCenter]}>{children}</View>433 </View>434 );435}436437// ─── Start, Pause, Resume: one button that morphs between them ──────────────438439const LABELS: Record<Run, string> = { idle: 'Start', running: 'Pause', paused: 'Resume' };440const BTN_PAD = 26;441const BTN_ICON = 22;442const BTN_GAP = 9;443444function MainButton({ run, mode, modeSV, onPress, pal }: { run: Run; mode: Mode; modeSV: SharedValue<number>; onPress: () => void; pal: Palette }) {445 const [widths, setWidths] = useState<Record<Run, number>>({ idle: 44, running: 50, paused: 68 });446 const solid = useSharedValue(run === 'running' ? 0 : 1);447 const slot = useSharedValue(widths[run]);448 const play = useSharedValue(run === 'running' ? 0 : 1);449 const press = useSharedValue(1);450 const oIdle = useSharedValue(run === 'idle' ? 1 : 0);451 const oRun = useSharedValue(run === 'running' ? 1 : 0);452 const oPause = useSharedValue(run === 'paused' ? 1 : 0);453 useEffect(() => {454 solid.value = withTiming(run === 'running' ? 0 : 1, { duration: 300, easing: Easing.out(Easing.cubic) });455 play.value = withSpring(run === 'running' ? 0 : 1, { damping: 13, stiffness: 220, mass: 0.6 });456 slot.value = withSpring(widths[run], SPRING);457 oIdle.value = withTiming(run === 'idle' ? 1 : 0, { duration: 200 });458 oRun.value = withTiming(run === 'running' ? 1 : 0, { duration: 200 });459 oPause.value = withTiming(run === 'paused' ? 1 : 0, { duration: 200 });460 }, [run, widths, solid, play, slot, oIdle, oRun, oPause]);461462 const accentSoft = pal.accentSoft;463 const calmSoft = pal.calmSoft;464 const accentText = pal.accentText;465 const calmText = pal.calmText;466 const body = useAnimatedStyle(() => {467 const filled = interpolateColor(modeSV.value, [0, 1], [ACCENT, CALM]);468 const soft = interpolateColor(modeSV.value, [0, 1], [accentSoft, calmSoft]);469 return { width: slot.value + BTN_PAD * 2 + BTN_ICON + BTN_GAP, backgroundColor: interpolateColor(solid.value, [0, 1], [soft, filled]), transform: [{ scale: press.value }] };470 });471 const label = useAnimatedStyle(() => {472 const softInk = interpolateColor(modeSV.value, [0, 1], [accentText, calmText]);473 return { color: interpolateColor(solid.value, [0, 1], [softInk, ON_ACCENT]) };474 });475 const glowFocus = useAnimatedStyle(() => ({ opacity: solid.value * (1 - modeSV.value) }));476 const glowCalm = useAnimatedStyle(() => ({ opacity: solid.value * modeSV.value }));477 const playIcon = useAnimatedStyle(() => ({ opacity: play.value, transform: [{ scale: 0.5 + play.value * 0.5 }, { rotate: `${(1 - play.value) * -90}deg` }] }));478 const pauseIcon = useAnimatedStyle(() => ({ opacity: 1 - play.value, transform: [{ scale: 1 - play.value * 0.5 }, { rotate: `${play.value * 90}deg` }] }));479 const sIdle = useAnimatedStyle(() => ({ opacity: oIdle.value, transform: [{ translateY: (1 - oIdle.value) * 6 }] }));480 const sRun = useAnimatedStyle(() => ({ opacity: oRun.value, transform: [{ translateY: (1 - oRun.value) * 6 }] }));481 const sPause = useAnimatedStyle(() => ({ opacity: oPause.value, transform: [{ translateY: (1 - oPause.value) * 6 }] }));482 const slotStyle = useAnimatedStyle(() => ({ width: slot.value }));483 const measure = (k: Run) => (w: number) => setWidths((prev) => (Math.abs(prev[k] - w) < 0.5 ? prev : { ...prev, [k]: w }));484 const pauseInk = mode === 'break' ? pal.calmText : pal.accentText;485486 return (487 <Pressable488 role="button"489 aria-label={run === 'running' ? 'Pause' : run === 'paused' ? 'Resume' : 'Start'}490 onPress={onPress}491 onPressIn={() => (press.value = withSpring(0.95, SPRING))}492 onPressOut={() => (press.value = withSpring(1, SPRING))}493 >494 <Animated.View style={[styles.mainButton, body]}>495 <Animated.View style={[StyleSheet.absoluteFill, styles.mainGlowFocus, glowFocus]} />496 <Animated.View style={[StyleSheet.absoluteFill, styles.mainGlowCalm, glowCalm]} />497 <View style={styles.mainIcon}>498 <Animated.View style={[styles.iconLayer, playIcon]}>499 <Play size={BTN_ICON} color={ON_ACCENT} fill={ON_ACCENT} style={styles.playNudge} />500 </Animated.View>501 <Animated.View style={[styles.iconLayer, pauseIcon]}>502 <Pause size={BTN_ICON} color={pauseInk} fill={pauseInk} />503 </Animated.View>504 </View>505 <Animated.View style={[styles.labelSlot, slotStyle]}>506 <View style={styles.labelRack}>507 <Animated.Text onLayout={(e) => measure('idle')(e.nativeEvent.layout.width)} style={[styles.mainLabel, label, sIdle]}>508 {LABELS.idle}509 </Animated.Text>510 <Animated.Text onLayout={(e) => measure('running')(e.nativeEvent.layout.width)} style={[styles.mainLabel, label, sRun]}>511 {LABELS.running}512 </Animated.Text>513 <Animated.Text onLayout={(e) => measure('paused')(e.nativeEvent.layout.width)} style={[styles.mainLabel, label, sPause]}>514 {LABELS.paused}515 </Animated.Text>516 </View>517 </Animated.View>518 </Animated.View>519 </Pressable>520 );521}522523/** A round side action with a caption; the two layers cross-fade when the screen moves into break mode. */524function SideAction({ modeSV, resting, focus, rest, disabled, onPress, pal }: { modeSV: SharedValue<number>; resting: boolean; focus: { label: string; icon: ReactNode }; rest: { label: string; icon: ReactNode }; disabled: boolean; onPress: () => void; pal: Palette }) {525 const a = useAnimatedStyle(() => ({ opacity: 1 - modeSV.value, transform: [{ scale: 1 - modeSV.value * 0.3 }] }));526 const b = useAnimatedStyle(() => ({ opacity: modeSV.value, transform: [{ scale: 0.7 + modeSV.value * 0.3 }] }));527 const ta = useAnimatedStyle(() => ({ opacity: 1 - modeSV.value }));528 const tb = useAnimatedStyle(() => ({ opacity: modeSV.value }));529 return (530 <View style={[styles.side, { opacity: disabled ? 0.38 : 1 }]}>531 <Tap label={resting ? rest.label : focus.label} onPress={onPress} disabled={disabled}>532 <View style={[styles.sideButton, { backgroundColor: pal.chip }]}>533 <Animated.View style={[styles.iconLayer, a]}>{focus.icon}</Animated.View>534 <Animated.View style={[styles.iconLayer, b]}>{rest.icon}</Animated.View>535 </View>536 </Tap>537 <View style={styles.sideCaptionSlot}>538 <Animated.Text numberOfLines={1} style={[styles.sideCaption, { color: pal.muted }, ta]}>539 {focus.label}540 </Animated.Text>541 <Animated.Text numberOfLines={1} style={[styles.sideCaption, { color: pal.muted }, tb]}>542 {rest.label}543 </Animated.Text>544 </View>545 </View>546 );547}548549// ─── Ambient sound: a chip with a live level meter and a small menu ─────────550551function LevelBar({ index, active, tempo, color }: { index: number; active: boolean; tempo: number; color: string }) {552 const h = useSharedValue(0.2);553 useEffect(() => {554 if (!active) {555 cancelAnimation(h);556 h.value = withTiming(0.12, { duration: 260 });557 return;558 }559 const d = [420, 300, 520, 360][index] * tempo;560 const peaks = [[0.95, 0.4], [0.55, 1], [1, 0.45], [0.4, 0.85]][index];561 h.value = withRepeat(562 withSequence(563 withTiming(peaks[0], { duration: d, easing: Easing.inOut(Easing.quad) }),564 withTiming(peaks[1], { duration: d * 0.8, easing: Easing.inOut(Easing.quad) }),565 withTiming(0.28, { duration: d * 0.7, easing: Easing.inOut(Easing.quad) })566 ),567 -1,568 false569 );570 return () => cancelAnimation(h);571 }, [active, tempo, index, h]);572 const style = useAnimatedStyle(() => ({ height: 3 + h.value * 13 }));573 return <Animated.View style={[styles.levelBar, { backgroundColor: color }, style]} />;574}575576function SoundMenu({ open, sound, onPick, pal }: { open: boolean; sound: SoundId; onPick: (s: SoundId) => void; pal: Palette }) {577 const t = useSharedValue(0);578 useEffect(() => {579 t.value = open ? withSpring(1, { damping: 17, stiffness: 260, mass: 0.6 }) : withTiming(0, { duration: 150 });580 }, [open, t]);581 const style = useAnimatedStyle(() => ({ opacity: Math.min(1, t.value * 1.5), transform: [{ translateY: (1 - t.value) * 12 }, { scale: 0.94 + t.value * 0.06 }] }));582 return (583 <Animated.View role="radiogroup" aria-label="Ambient sound" aria-hidden={!open} style={[styles.menu, { backgroundColor: pal.sheet, borderColor: pal.border, pointerEvents: open ? 'auto' : 'none' }, pal.dark ? styles.menuDark : styles.menuLight, style]}>584 {SOUNDS.map((s) => {585 const Icon = SOUND_ICON[s.id];586 const on = s.id === sound;587 return (588 <Pressable key={s.id} role="radio" aria-checked={on} aria-label={s.label} onPress={() => onPick(s.id)} style={({ pressed }) => [styles.menuRow, { backgroundColor: pressed ? pal.chip : 'transparent' }]}>589 <Icon size={17} color={on ? pal.accentText : pal.muted} strokeWidth={2.2} />590 <Text style={[styles.menuLabel, { color: pal.fg, fontWeight: on ? '700' : '500' }]}>{s.label}</Text>591 {on && <Check size={16} color={pal.accentText} strokeWidth={2.8} />}592 </Pressable>593 );594 })}595 </Animated.View>596 );597}598599// ─── Today: focus minutes, blocks, streak and the week in bars ──────────────600601function DayBar({ value, max, today, index, pal }: { value: number; max: number; today: boolean; index: number; pal: Palette }) {602 const h = useSharedValue(0);603 const booted = useRef(false);604 useEffect(() => {605 const to = withTiming(value / max, { duration: 520, easing: Easing.out(Easing.cubic) });606 h.value = booted.current ? to : withDelay(560 + index * 50, to);607 booted.current = true;608 }, [value, max, index, h]);609 const style = useAnimatedStyle(() => ({ height: Math.max(3, h.value * 34) }));610 return (611 <View style={styles.dayCol}>612 <View style={styles.dayTrack}>613 <Animated.View style={[styles.dayFill, { backgroundColor: today ? ACCENT : pal.bar }, style]} />614 </View>615 </View>616 );617}618619function TodayStrip({ minutes, blocks, pal }: { minutes: number; blocks: number; pal: Palette }) {620 const days = [...WEEK, { day: 'F', name: 'Today', min: minutes }];621 const max = Math.max(...days.map((d) => d.min), 1);622 const stats = [623 { label: 'Focused', value: hm(minutes) },624 { label: 'Blocks', value: String(blocks) },625 { label: 'Streak', value: `${STREAK_DAYS} days` },626 ];627 return (628 <Animated.View entering={FadeInDown.delay(300).duration(420)} style={[styles.today, { backgroundColor: pal.surface, borderColor: pal.border }]}>629 <View style={styles.todayHead}>630 <Text style={[styles.todayTitle, { color: pal.fg }]}>Today</Text>631 <View style={styles.streakTag}>632 <Flame size={13} color={pal.accentText} fill={pal.accentText} />633 <Text style={[styles.streakText, { color: pal.accentText }]}>On a roll</Text>634 </View>635 </View>636 <View style={styles.todayRow}>637 {stats.map((s) => (638 <View key={s.label} style={styles.stat}>639 <Text numberOfLines={1} style={[styles.statValue, { color: pal.fg }, TABULAR]}>640 {s.value}641 </Text>642 <Text style={[styles.statLabel, { color: pal.muted }]}>{s.label}</Text>643 </View>644 ))}645 <View role="img" aria-label={`Focus minutes this week: ${days.map((d) => `${d.name} ${d.min}`).join(', ')}`} style={styles.week}>646 <View style={styles.weekBars}>647 {days.map((d, i) => (648 <DayBar key={i} value={d.min} max={max} today={i === days.length - 1} index={i} pal={pal} />649 ))}650 </View>651 <View style={styles.weekBars}>652 {days.map((d, i) => (653 <Text key={i} style={[styles.dayLetter, { color: i === days.length - 1 ? pal.accentText : pal.muted, fontWeight: i === days.length - 1 ? '800' : '600' }]}>654 {d.day}655 </Text>656 ))}657 </View>658 </View>659 </View>660 </Animated.View>661 );662}663664// ─── Bottom sheet, shared by the task picker and the reset confirm ──────────665666function Sheet({ open, label, width, bottom, onClose, pal, children }: { open: boolean; label: string; width: number; bottom: number; onClose: () => void; pal: Palette; children: ReactNode }) {667 const t = useSharedValue(0);668 useEffect(() => {669 t.value = withTiming(open ? 1 : 0, { duration: open ? 320 : 220, easing: Easing.out(Easing.cubic) });670 }, [open, t]);671 const scrim = useAnimatedStyle(() => ({ opacity: t.value }));672 const sheet = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - t.value) * 520 }] }));673 return (674 <View aria-hidden={!open} style={[StyleSheet.absoluteFill, styles.sheetHost, { pointerEvents: open ? 'auto' : 'none' }]}>675 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: pal.scrim }, scrim]}>676 <Pressable role="button" aria-label="Close" onPress={onClose} style={styles.fill} />677 </Animated.View>678 <Animated.View role="dialog" aria-label={label} style={[styles.sheet, { width, backgroundColor: pal.sheet, paddingBottom: bottom + 18 }, sheet]}>679 <View style={[styles.grabber, { backgroundColor: pal.faint }]} />680 {children}681 </Animated.View>682 </View>683 );684}685686function TaskPicker({ tasks, selected, onPick, onAdd, pal }: { tasks: Task[]; selected: string; onPick: (id: string) => void; onAdd: (title: string) => void; pal: Palette }) {687 const [draft, setDraft] = useState('');688 const ready = draft.trim().length > 0;689 const add = () => {690 if (!ready) return;691 onAdd(draft.trim());692 setDraft('');693 };694 return (695 <View>696 <Text style={[styles.sheetTitle, { color: pal.fg }]}>What are you focusing on?</Text>697 <Text style={[styles.sheetBody, { color: pal.muted }]}>Blocks you finish are logged against this task.</Text>698 <View role="radiogroup" aria-label="Task" style={styles.taskList}>699 {tasks.map((t) => {700 const on = t.id === selected;701 return (702 <Pressable key={t.id} role="radio" aria-checked={on} aria-label={t.title} onPress={() => onPick(t.id)} style={({ pressed }) => [styles.taskRow, { backgroundColor: on ? pal.accentSoft : pressed ? pal.chip : 'transparent' }]}>703 <View style={[styles.radio, { borderColor: on ? ACCENT : pal.faint, backgroundColor: on ? ACCENT : 'transparent' }]}>{on && <Check size={13} color={ON_ACCENT} strokeWidth={3.4} />}</View>704 <View style={styles.fill}>705 <Text numberOfLines={1} style={[styles.taskTitle, { color: pal.fg }]}>706 {t.title}707 </Text>708 <Text style={[styles.taskMeta, { color: pal.muted }]}>709 {t.project} · {t.blocks} {t.blocks === 1 ? 'block' : 'blocks'} planned710 </Text>711 </View>712 </Pressable>713 );714 })}715 </View>716 <View style={[styles.addRow, { backgroundColor: pal.chip }]}>717 <TextInput718 value={draft}719 onChangeText={setDraft}720 onSubmitEditing={add}721 returnKeyType="done"722 maxLength={48}723 placeholder="Or type a new task"724 placeholderTextColor={pal.muted}725 selectionColor={ACCENT}726 aria-label="New task"727 style={[styles.addInput, { color: pal.fg }, NO_OUTLINE]}728 />729 <Tap label="Add task" onPress={add} disabled={!ready}>730 <View style={[styles.addButton, { backgroundColor: ready ? ACCENT : pal.faint }]}>731 <Plus size={18} color={ON_ACCENT} strokeWidth={2.8} />732 </View>733 </Tap>734 </View>735 </View>736 );737}738739function ResetConfirm({ elapsed, block, onKeep, onReset, pal }: { elapsed: number; block: number; onKeep: () => void; onReset: () => void; pal: Palette }) {740 return (741 <View>742 <Text style={[styles.sheetTitle, { color: pal.fg }]}>Reset this block?</Text>743 <Text style={[styles.sheetBody, { color: pal.muted }]}>744 You are <Text style={[styles.sheetStrong, { color: pal.fg }, TABULAR]}>{clock(elapsed)}</Text> into focus block {block}. Resetting starts it over, and that time will not count toward today.745 </Text>746 <View style={styles.sheetActions}>747 <Tap label="Keep focusing" onPress={onKeep} to={0.97}>748 <View style={[styles.sheetButton, styles.sheetPrimary]}>749 <Text style={styles.sheetPrimaryLabel}>Keep focusing</Text>750 </View>751 </Tap>752 <Tap label="Reset block" onPress={onReset} to={0.97}>753 <View style={[styles.sheetButton, { backgroundColor: pal.chip }]}>754 <Text style={[styles.sheetSecondaryLabel, { color: pal.fg }]}>Reset block</Text>755 </View>756 </Tap>757 </View>758 </View>759 );760}761762// ─── Screen ─────────────────────────────────────────────────────────────────763764export default function FocusTimerScreen() {765 const pal = usePalette();766 const insets = useSafeAreaInsets();767 const { width, height } = useWindowDimensions();768 const colW = Math.min(width, 520);769 const dial = Math.round(Math.max(236, Math.min(colW - 70, 312, height - insets.top - insets.bottom - 504)));770771 const [mode, setMode] = useState<Mode>('focus');772 const [run, setRun] = useState<Run>('paused');773 const [done, setDone] = useState(START.done);774 const [planned, setPlanned] = useState(START.planned);775 const [breakLen, setBreakLen] = useState(SHORT_BREAK);776 const [total, setTotal] = useState(START.planned * 60);777 const [left, setLeft] = useState(START.left);778 const [banked, setBanked] = useState(START.banked);779 const [blocks, setBlocks] = useState(START.blocks);780 const [dnd, setDnd] = useState(true);781 const [sound, setSound] = useState<SoundId>('rain');782 const [menu, setMenu] = useState(false);783 const [sheet, setSheet] = useState<'task' | 'reset' | null>(null);784 const [lastSheet, setLastSheet] = useState<'task' | 'reset'>('task');785 const [tasks, setTasks] = useState(TASKS);786 const [taskId, setTaskId] = useState(TASKS[0].id);787 const [dragging, setDragging] = useState(false);788 const [sync, setSync] = useState(0);789790 // The clock lives in a ref; state only holds what is printed.791 const leftMs = useRef(START.left * 1000);792 const lead = useRef(0);793 const touched = useRef(false);794 const shownTotal = useRef(START.planned * 60);795 const timers = useRef<ReturnType<typeof setTimeout>[]>([]);796797 const leftSV = useSharedValue(0);798 const totalSV = useSharedValue(0);799 const modeSV = useSharedValue(0);800801 const ticking = run === 'running' && sheet !== 'reset';802 const baseLen = mode === 'focus' ? planned * 60 : (done >= CYCLE ? LONG_BREAK : SHORT_BREAK) * 60;803 const speed = DEMO_BLOCK_SECONDS > 0 ? baseLen / DEMO_BLOCK_SECONDS : 1;804 const task = tasks.find((t) => t.id === taskId) ?? tasks[0];805 const nextBlock = done >= CYCLE ? 1 : done + 1;806 const isLong = mode === 'break' && done >= CYCLE;807808 // Entrance: the band sweeps out to where the paused block stands.809 useEffect(() => {810 leftSV.value = withDelay(250, withTiming(START.left, { duration: 1100, easing: Easing.out(Easing.cubic) }));811 totalSV.value = withDelay(250, withTiming(START.planned * 60, { duration: 1100, easing: Easing.out(Easing.cubic) }));812 }, [leftSV, totalSV]);813 useEffect(() => () => timers.current.forEach(clearTimeout), []);814815 const finish = () => {816 if (mode === 'focus') {817 const nextDone = done + 1;818 const len = nextDone >= CYCLE ? LONG_BREAK : SHORT_BREAK;819 setBanked((b) => b + Math.round(total / 60));820 setBlocks((n) => n + 1);821 setDone(nextDone);822 setMode('break');823 setBreakLen(len);824 setTotal(len * 60);825 leftMs.current = len * 60000;826 setLeft(len * 60);827 lead.current = 700;828 setRun('running');829 } else {830 // The break is over: the next block is loaded and waits for Start.831 setDone(done >= CYCLE ? 0 : done);832 setMode('focus');833 setTotal(planned * 60);834 leftMs.current = planned * 60000;835 setLeft(planned * 60);836 lead.current = 800;837 setRun('idle');838 }839 setSync((n) => n + 1);840 };841 const finishRef = useRef(finish);842 finishRef.current = finish;843844 // The tick: real time since the last one, sped up by the demo factor, comes off the clock.845 useEffect(() => {846 if (!ticking) return;847 let last = Date.now();848 const id = setInterval(() => {849 const now = Date.now();850 leftMs.current -= (now - last) * speed;851 last = now;852 if (leftMs.current <= 0) {853 leftMs.current = 0;854 setLeft(0);855 finishRef.current();856 return;857 }858 setLeft(Math.ceil(leftMs.current / 1000));859 }, 100);860 return () => clearInterval(id);861 }, [ticking, speed, mode]);862863 // The band: ease to where the clock is, then drain in a straight line until the interval ends.864 useEffect(() => {865 if (!touched.current && sync === 0 && !ticking) return;866 touched.current = true;867 const now = Math.max(0, leftMs.current / 1000);868 const ease = lead.current;869 lead.current = 0;870 cancelAnimation(leftSV);871 if (!ticking) {872 leftSV.value = ease ? withTiming(now, { duration: ease, easing: Easing.out(Easing.cubic) }) : now;873 return;874 }875 const real = (now * 1000) / speed;876 const easeMs = Math.min(ease, real);877 const drain = withTiming(0, { duration: Math.max(0, real - easeMs), easing: Easing.linear });878 leftSV.value = easeMs > 0 ? withSequence(withTiming(now - (easeMs * speed) / 1000, { duration: easeMs, easing: Easing.out(Easing.cubic) }), drain) : drain;879 }, [ticking, sync, speed, leftSV]);880881 useEffect(() => {882 if (total === shownTotal.current) return;883 shownTotal.current = total;884 totalSV.value = withTiming(total, { duration: 420, easing: Easing.out(Easing.cubic) });885 }, [total, totalSV]);886887 // Focus to break: the whole screen eases into the calm tone.888 useEffect(() => {889 modeSV.value = withTiming(mode === 'break' ? 1 : 0, { duration: 900, easing: Easing.inOut(Easing.quad) });890 }, [mode, modeSV]);891892 const toggle = () => {893 setMenu(false);894 setRun((r) => (r === 'running' ? 'paused' : 'running'));895 };896 const resetNow = () => {897 setSheet(null);898 setRun('idle');899 setTotal(planned * 60);900 leftMs.current = planned * 60000;901 setLeft(planned * 60);902 lead.current = 600;903 setSync((n) => n + 1);904 };905 const openSheet = (k: 'task' | 'reset') => {906 setMenu(false);907 setLastSheet(k);908 setSheet(k);909 };910 const reset = () => {911 if (total - left > 60) openSheet('reset');912 else resetNow();913 };914 const canReset = mode === 'focus' && run !== 'idle';915 const canAdd = (run !== 'idle' || mode === 'break') && left + 300 <= FACE_SECONDS;916 const addFive = () => {917 if (!canAdd) return;918 leftMs.current += 300000;919 setLeft(Math.ceil(leftMs.current / 1000));920 setTotal((t) => t + 300);921 if (mode === 'break') setBreakLen((b) => b + 5);922 lead.current = 450;923 setSync((n) => n + 1);924 };925 const setLength = (min: number) => {926 setPlanned(min);927 setTotal(min * 60);928 leftMs.current = min * 60000;929 setLeft(min * 60);930 lead.current = 180;931 setSync((n) => n + 1);932 };933 const later = (fn: () => void, ms: number) => timers.current.push(setTimeout(fn, ms));934 const pickTask = (id: string) => {935 setTaskId(id);936 later(() => setSheet(null), 220);937 };938 const addTask = (title: string) => {939 const t: Task = { id: `t${Date.now()}`, title, project: 'Inbox', blocks: 1 };940 setTasks((all) => [t, ...all]);941 setTaskId(t.id);942 later(() => setSheet(null), 260);943 };944945 const elapsedFocus = mode === 'focus' && run !== 'idle' ? Math.max(0, total - left) : 0;946 const todayMin = banked + Math.floor(elapsedFocus / 60);947 const quiet = dnd && (mode === 'break' || run !== 'idle');948 const editable = mode === 'focus' && run === 'idle';949 const toneText = mode === 'break' ? pal.calmText : pal.accentText;950 const dialLabel =951 mode === 'break' ? (run === 'paused' ? 'BREAK PAUSED' : isLong ? 'LONG BREAK' : 'BREAK') : run === 'idle' ? 'READY' : run === 'paused' ? 'PAUSED' : `FOCUS ${done + 1} OF ${CYCLE}`;952 const dialSub = mode === 'break' ? `Focus ${nextBlock} up next` : editable ? 'Drag the dial to set' : `of ${Math.round(total / 60)} min`;953954 const bg = pal.bg;955 const calmBg = pal.calmBg;956 const screenStyle = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(modeSV.value, [0, 1], [bg, calmBg]) }));957 const focusCard = useAnimatedStyle(() => ({ opacity: 1 - modeSV.value, transform: [{ translateY: modeSV.value * -10 }] }));958 const breakCard = useAnimatedStyle(() => ({ opacity: modeSV.value, transform: [{ translateY: (1 - modeSV.value) * 10 }] }));959960 const SoundIcon = SOUND_ICON[sound];961 const soundLabel = SOUNDS.find((s) => s.id === sound)?.label ?? 'Off';962 const tempo = SOUNDS.find((s) => s.id === sound)?.tempo ?? 1;963964 return (965 <Animated.View style={[styles.screen, screenStyle]}>966 <ScrollView967 style={styles.fill}968 scrollEnabled={!dragging}969 showsVerticalScrollIndicator={false}970 contentContainerStyle={[styles.scroll, { paddingTop: insets.top + 4, paddingBottom: insets.bottom + 18 }]}971 >972 <View style={[styles.column, { width: colW }]}>973 {/* Header, with the quiet pill centred on it */}974 <Animated.View entering={FadeIn.duration(320)} style={styles.header}>975 <View style={styles.brand}>976 <AppMark />977 <Text style={[styles.brandName, { color: pal.fg }]}>{APP_NAME}</Text>978 </View>979 <View style={styles.headerEnd}>980 <QuietPill shown={quiet} pal={pal} />981 <DndToggle on={dnd} onToggle={() => setDnd((d) => !d)} pal={pal} />982 </View>983 </Animated.View>984985 {/* The task in focus, or the break and its stretch */}986 <Animated.View entering={FadeInDown.delay(80).duration(420)} style={styles.cardSlot}>987 <Animated.View style={[StyleSheet.absoluteFill, { pointerEvents: mode === 'focus' ? 'auto' : 'none' }, focusCard]}>988 <Pressable989 role="button"990 aria-label={`Focusing on ${task.title}. Change task`}991 onPress={() => openSheet('task')}992 style={({ pressed }) => [styles.card, { backgroundColor: pal.surface, borderColor: pal.border, opacity: pressed ? 0.85 : 1 }]}993 >994 <View style={styles.cardTop}>995 <Text style={[styles.cardEyebrow, { color: pal.muted }]}>FOCUSING ON</Text>996 <Text style={[styles.cardMeta, { color: pal.muted }, TABULAR]}>997 Block {Math.min(done + 1, CYCLE)} of {CYCLE}998 </Text>999 </View>1000 <View style={styles.taskLine}>1001 <Animated.Text key={task.id} entering={FadeInDown.duration(260)} numberOfLines={1} style={[styles.taskName, { color: pal.fg }]}>1002 {task.title}1003 </Animated.Text>1004 <View style={[styles.chevron, { backgroundColor: pal.chip }]}>1005 <ChevronDown size={16} color={pal.fg} strokeWidth={2.4} />1006 </View>1007 </View>1008 <SessionDots done={done} mode={mode} left={leftSV} total={totalSV} pal={pal} />1009 </Pressable>1010 </Animated.View>1011 <Animated.View aria-hidden={mode !== 'break'} style={[StyleSheet.absoluteFill, { pointerEvents: mode === 'break' ? 'auto' : 'none' }, breakCard]}>1012 <View style={[styles.card, { backgroundColor: pal.surface, borderColor: pal.border }]}>1013 <View style={styles.cardTop}>1014 <Text style={[styles.cardEyebrow, { color: pal.muted }]}>TIME TO RESET</Text>1015 <Text numberOfLines={1} style={[styles.cardMeta, { color: pal.muted }]}>1016 Next: focus {nextBlock} of {CYCLE}1017 </Text>1018 </View>1019 <Text style={[styles.taskName, styles.breakTitle, { color: pal.calmText }]}>1020 {isLong ? 'Long break' : 'Break'}, {breakLen} min1021 </Text>1022 <View style={styles.stretch}>1023 <View style={[styles.stretchIcon, { backgroundColor: pal.calmSoft }]}>1024 <PersonStanding size={15} color={pal.calmText} strokeWidth={2.4} />1025 </View>1026 <Text numberOfLines={2} style={[styles.stretchText, { color: pal.muted }]}>1027 {isLong ? LONG_STRETCH : STRETCHES[(done + CYCLE - 1) % STRETCHES.length]}1028 </Text>1029 </View>1030 </View>1031 </Animated.View>1032 </Animated.View>10331034 {/* Dial */}1035 <View style={styles.dialArea}>1036 <Dial1037 size={dial}1038 left={leftSV}1039 total={totalSV}1040 modeSV={modeSV}1041 mode={mode}1042 litMin={Math.min(60, Math.ceil(left / 60))}1043 ghostMin={Math.min(60, Math.ceil(total / 60))}1044 editable={editable}1045 value={planned}1046 onSet={setLength}1047 onDrag={setDragging}1048 pal={pal}1049 >1050 <Animated.Text key={dialLabel} entering={FadeIn.duration(220)} style={[styles.dialLabel, { color: run === 'paused' ? pal.muted : toneText }]}>1051 {dialLabel}1052 </Animated.Text>1053 <Animated.Text1054 entering={FadeIn.delay(200).duration(420)}1055 role="timer"1056 aria-label={`${Math.floor(left / 60)} minutes ${left % 60} seconds left`}1057 style={[styles.digits, { color: pal.fg, fontSize: Math.round(dial * 0.205), lineHeight: Math.round(dial * 0.24) }, TABULAR]}1058 >1059 {mmss(left)}1060 </Animated.Text>1061 <Text style={[styles.dialSub, { color: pal.muted }]}>{dialSub}</Text>1062 </Dial>1063 </View>10641065 {/* Controls */}1066 <Animated.View entering={FadeInDown.delay(200).duration(420)} style={styles.controls}>1067 <SideAction1068 modeSV={modeSV}1069 resting={mode === 'break'}1070 focus={{ label: 'Reset', icon: <RotateCcw size={20} color={pal.fg} strokeWidth={2.3} /> }}1071 rest={{ label: 'Skip break', icon: <SkipForward size={20} color={pal.fg} fill={pal.fg} /> }}1072 disabled={mode === 'focus' && !canReset}1073 onPress={mode === 'break' ? () => finish() : reset}1074 pal={pal}1075 />1076 <MainButton run={run} mode={mode} modeSV={modeSV} onPress={toggle} pal={pal} />1077 <SideAction1078 modeSV={modeSV}1079 resting={mode === 'break'}1080 focus={{ label: '+5 min', icon: <Text style={[styles.plusFive, { color: pal.fg }]}>+5</Text> }}1081 rest={{ label: '+5 min', icon: <Text style={[styles.plusFive, { color: pal.fg }]}>+5</Text> }}1082 disabled={!canAdd}1083 onPress={addFive}1084 pal={pal}1085 />1086 </Animated.View>10871088 {/* Ambient sound */}1089 <Animated.View entering={FadeInDown.delay(250).duration(420)} style={styles.soundRow}>1090 {menu && <Pressable aria-label="Close sound menu" onPress={() => setMenu(false)} style={styles.menuBackdrop} />}1091 <View style={styles.soundAnchor}>1092 <SoundMenu1093 open={menu}1094 sound={sound}1095 onPick={(s) => {1096 setSound(s);1097 later(() => setMenu(false), 160);1098 }}1099 pal={pal}1100 />1101 <Pressable1102 role="button"1103 aria-label={`Ambient sound: ${soundLabel}`}1104 aria-expanded={menu}1105 onPress={() => setMenu((m) => !m)}1106 style={({ pressed }) => [styles.soundChip, { backgroundColor: pal.surface, borderColor: pal.border, opacity: pressed ? 0.8 : 1 }]}1107 >1108 <SoundIcon size={16} color={sound === 'off' ? pal.muted : toneText} strokeWidth={2.3} />1109 <Text style={[styles.soundLabel, { color: pal.fg }]}>{soundLabel}</Text>1110 <View style={styles.levels}>1111 {[0, 1, 2, 3].map((i) => (1112 <LevelBar key={i} index={i} active={sound !== 'off'} tempo={tempo} color={sound === 'off' ? pal.faint : toneText} />1113 ))}1114 </View>1115 {menu ? <ChevronUp size={14} color={pal.muted} strokeWidth={2.6} /> : <ChevronDown size={14} color={pal.muted} strokeWidth={2.6} />}1116 </Pressable>1117 </View>1118 </Animated.View>11191120 <TodayStrip minutes={todayMin} blocks={blocks} pal={pal} />1121 </View>1122 </ScrollView>11231124 <Sheet open={sheet !== null} label={lastSheet === 'task' ? 'Choose a task' : 'Reset this block?'} width={colW} bottom={insets.bottom} onClose={() => setSheet(null)} pal={pal}>1125 {lastSheet === 'task' ? (1126 <TaskPicker tasks={tasks} selected={taskId} onPick={pickTask} onAdd={addTask} pal={pal} />1127 ) : (1128 <ResetConfirm elapsed={Math.max(0, total - left)} block={done + 1} onKeep={() => setSheet(null)} onReset={resetNow} pal={pal} />1129 )}1130 </Sheet>1131 </Animated.View>1132 );1133}11341135// ─── Styles ─────────────────────────────────────────────────────────────────11361137const styles = StyleSheet.create({1138 screen: { flex: 1 },1139 fill: { flex: 1 },1140 passThrough: { pointerEvents: 'none' },1141 scroll: { flexGrow: 1, alignItems: 'center' },1142 column: { flex: 1, paddingHorizontal: 20 },11431144 // Header1145 header: { height: 52, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', zIndex: 2 },1146 brand: { flexDirection: 'row', alignItems: 'center', gap: 8 },1147 brandName: { fontSize: 18, fontWeight: '800', letterSpacing: -0.5 },1148 headerEnd: { flexDirection: 'row', alignItems: 'center', gap: 8 },1149 pillSlot: { pointerEvents: 'none' },1150 pill: { height: 30, borderRadius: 15, paddingLeft: 11, paddingRight: 5, flexDirection: 'row', alignItems: 'center', gap: 6 },1151 pillText: { fontSize: 12.5, fontWeight: '600', letterSpacing: -0.1 },1152 pillCount: { minWidth: 20, height: 20, borderRadius: 10, paddingHorizontal: 5, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },1153 pillCountText: { fontSize: 11, fontWeight: '800', color: ON_ACCENT },1154 switchTrack: { width: 52, height: 32, borderRadius: 16, padding: 3 },1155 switchKnob: {1156 width: 26,1157 height: 26,1158 borderRadius: 13,1159 backgroundColor: '#FFFFFF',1160 alignItems: 'center',1161 justifyContent: 'center',1162 shadowColor: '#000000',1163 shadowOpacity: 0.16,1164 shadowRadius: 3,1165 shadowOffset: { width: 0, height: 1 },1166 },11671168 // Task and break cards1169 cardSlot: { height: 124, marginTop: 6 },1170 card: { flex: 1, borderRadius: 22, borderWidth: 1, paddingHorizontal: 16, paddingTop: 13, paddingBottom: 14, justifyContent: 'space-between' },1171 cardTop: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 10 },1172 cardEyebrow: { fontSize: 11, fontWeight: '700', letterSpacing: 1.3 },1173 cardMeta: { fontSize: 12.5, fontWeight: '600', flexShrink: 1 },1174 taskLine: { flexDirection: 'row', alignItems: 'center', gap: 10 },1175 taskName: { flex: 1, fontSize: 21, fontWeight: '700', letterSpacing: -0.6 },1176 breakTitle: { flex: 0, marginTop: 4 },1177 chevron: { width: 28, height: 28, borderRadius: 14, alignItems: 'center', justifyContent: 'center' },1178 dots: { flexDirection: 'row', alignItems: 'center', gap: 6 },1179 dot: { height: 9, borderRadius: 4.5, overflow: 'hidden' },1180 dotFill: { height: 9, borderRadius: 4.5, backgroundColor: ACCENT },1181 dotsCoffee: { marginLeft: 6 },1182 dotsNote: { fontSize: 12, fontWeight: '600' },1183 stretch: { flexDirection: 'row', alignItems: 'center', gap: 10 },1184 stretchIcon: { width: 28, height: 28, borderRadius: 14, alignItems: 'center', justifyContent: 'center' },1185 stretchText: { flex: 1, fontSize: 13, lineHeight: 17, fontWeight: '500' },11861187 // Dial1188 dialArea: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingVertical: 16 },1189 face: { borderWidth: 1 },1190 faceLight: { boxShadow: '0px 18px 40px rgba(92, 56, 40, 0.10), 0px 2px 6px rgba(92, 56, 40, 0.06)' },1191 faceDark: { boxShadow: '0px 18px 40px rgba(0, 0, 0, 0.32)' },1192 turn: { transform: [{ rotate: '-90deg' }] },1193 knobBox: { position: 'absolute', left: 0, top: 0, width: KNOB, height: KNOB, pointerEvents: 'none' },1194 knob: {1195 width: KNOB,1196 height: KNOB,1197 borderRadius: KNOB / 2,1198 borderWidth: 3.5,1199 backgroundColor: '#FFFFFF',1200 shadowColor: '#000000',1201 shadowOpacity: 0.18,1202 shadowRadius: 6,1203 shadowOffset: { width: 0, height: 2 },1204 },1205 knobRing: { position: 'absolute', left: 0, top: 0, width: KNOB, height: KNOB, borderRadius: KNOB / 2, borderWidth: 2 },1206 dialCenter: { alignItems: 'center', justifyContent: 'center', pointerEvents: 'none' },1207 dialLabel: { fontSize: 11.5, fontWeight: '800', letterSpacing: 1.8, marginLeft: 1.8 },1208 digits: { fontWeight: '300', letterSpacing: -2, marginTop: 2 },1209 dialSub: { fontSize: 13, fontWeight: '500', marginTop: 2 },12101211 // Controls1212 controls: { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'center', gap: 22 },1213 side: { width: 72, alignItems: 'center' },1214 sideButton: { width: 54, height: 54, borderRadius: 27, alignItems: 'center', justifyContent: 'center' },1215 sideCaptionSlot: { height: 18, marginTop: 6, alignSelf: 'stretch' },1216 sideCaption: { position: 'absolute', left: 0, right: 0, textAlign: 'center', fontSize: 12, fontWeight: '600' },1217 iconLayer: { position: 'absolute', alignItems: 'center', justifyContent: 'center' },1218 plusFive: { fontSize: 17, fontWeight: '800', letterSpacing: -0.5 },1219 mainButton: { height: 60, borderRadius: 30, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: BTN_GAP, marginTop: -3 },1220 mainGlowFocus: { borderRadius: 30, boxShadow: `0px 10px 24px ${tint(ACCENT, 0.34)}` },1221 mainGlowCalm: { borderRadius: 30, boxShadow: '0px 10px 24px rgba(63, 148, 120, 0.32)' },1222 mainIcon: { width: BTN_ICON, height: BTN_ICON, alignItems: 'center', justifyContent: 'center' },1223 playNudge: { marginLeft: 2 },1224 labelSlot: { height: 24 },1225 labelRack: { position: 'absolute', left: 0, top: 0, width: 160, height: 24, pointerEvents: 'none' },1226 mainLabel: { position: 'absolute', left: 0, top: 0, fontSize: 18, lineHeight: 24, fontWeight: '700', letterSpacing: -0.3 },12271228 // Ambient sound1229 soundRow: { alignItems: 'center', marginTop: 14, zIndex: 3 },1230 menuBackdrop: { position: 'absolute', left: -1000, right: -1000, top: -2000, bottom: -1000 },1231 soundAnchor: { alignItems: 'center' },1232 soundChip: { height: 40, borderRadius: 20, borderWidth: 1, paddingLeft: 14, paddingRight: 12, flexDirection: 'row', alignItems: 'center', gap: 8 },1233 soundLabel: { fontSize: 14, fontWeight: '600' },1234 levels: { flexDirection: 'row', alignItems: 'center', gap: 2.5, height: 16, marginLeft: 2 },1235 levelBar: { width: 3, borderRadius: 1.5 },1236 menu: { position: 'absolute', bottom: 48, width: 200, borderRadius: 18, borderWidth: 1, padding: 6 },1237 menuLight: { boxShadow: '0px 14px 34px rgba(60, 36, 24, 0.16)' },1238 menuDark: { boxShadow: '0px 14px 34px rgba(0, 0, 0, 0.45)' },1239 menuRow: { height: 42, borderRadius: 12, paddingHorizontal: 10, flexDirection: 'row', alignItems: 'center', gap: 10 },1240 menuLabel: { flex: 1, fontSize: 15 },12411242 // Today1243 today: { marginTop: 16, borderRadius: 22, borderWidth: 1, paddingHorizontal: 16, paddingTop: 12, paddingBottom: 14 },1244 todayHead: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 10 },1245 todayTitle: { fontSize: 15, fontWeight: '700', letterSpacing: -0.2 },1246 streakTag: { flexDirection: 'row', alignItems: 'center', gap: 4 },1247 streakText: { fontSize: 12, fontWeight: '700' },1248 todayRow: { flexDirection: 'row', alignItems: 'flex-end', gap: 18 },1249 stat: { gap: 2 },1250 statValue: { fontSize: 17, fontWeight: '700', letterSpacing: -0.4 },1251 statLabel: { fontSize: 11.5, fontWeight: '600' },1252 week: { width: 88, marginLeft: 'auto', gap: 4 },1253 weekBars: { flexDirection: 'row', justifyContent: 'space-between' },1254 dayCol: { width: 8, alignItems: 'center' },1255 dayTrack: { width: 8, height: 34, justifyContent: 'flex-end' },1256 dayFill: { width: 8, borderRadius: 3 },1257 dayLetter: { width: 8, textAlign: 'center', fontSize: 9.5 },12581259 // Sheets1260 sheetHost: { justifyContent: 'flex-end', alignItems: 'center', zIndex: 10 },1261 sheet: { borderTopLeftRadius: 28, borderTopRightRadius: 28, paddingHorizontal: 20, paddingTop: 10 },1262 grabber: { width: 36, height: 5, borderRadius: 3, alignSelf: 'center', marginBottom: 16, opacity: 0.7 },1263 sheetTitle: { fontSize: 22, fontWeight: '700', letterSpacing: -0.6 },1264 sheetBody: { fontSize: 14.5, lineHeight: 21, marginTop: 6 },1265 sheetStrong: { fontWeight: '700' },1266 taskList: { marginTop: 14, gap: 4 },1267 taskRow: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 12, paddingVertical: 11, borderRadius: 16 },1268 radio: { width: 22, height: 22, borderRadius: 11, borderWidth: 2, alignItems: 'center', justifyContent: 'center' },1269 taskTitle: { fontSize: 15.5, fontWeight: '600', letterSpacing: -0.2 },1270 taskMeta: { fontSize: 12.5, fontWeight: '500', marginTop: 2 },1271 addRow: { marginTop: 12, height: 50, borderRadius: 16, flexDirection: 'row', alignItems: 'center', paddingLeft: 14, paddingRight: 6, gap: 8 },1272 addInput: { flex: 1, height: '100%', fontSize: 15, minWidth: 0 },1273 addButton: { width: 38, height: 38, borderRadius: 12, alignItems: 'center', justifyContent: 'center' },1274 sheetActions: { marginTop: 18, gap: 10 },1275 sheetButton: { height: 54, borderRadius: 27, alignItems: 'center', justifyContent: 'center' },1276 sheetPrimary: { backgroundColor: ACCENT },1277 sheetPrimaryLabel: { fontSize: 16, fontWeight: '700', color: ON_ACCENT },1278 sheetSecondaryLabel: { fontSize: 16, fontWeight: '700' },1279});