Task list

Today's tasks under a progress ring that sweeps and counts up as you tick items off. Checking a task pops the round checkbox, draws a strike through the title and slides the row into Done with a layout animation; filter chips with counts, an empty state and a pinned composer that adds tasks at the top all work.

taskstodochecklistprogressfilterscomposeranimationreanimated
Paste into Claude Code Cursor Codex Lovable RapidNative
Live preview · follows the site themeOpen full screen

Details

File
components/patterns/task-list.tsx
Lines
730
Stack
React Native, StyleSheet
Packages
expo-linear-gradient, lucide-react-native, react-native-reanimated, react-native-safe-area-context, react-native-svg, react-native-worklets
Platforms
iOS, Android, Web

Using gluestack-ui?

Optional. The screen is plain React Native; these components can stand in for its primitives.

components/patterns/task-list.tsx
1import { useEffect, useRef, useState, type ComponentRef, type ReactNode } from 'react';
2import {
3 Image,
4 KeyboardAvoidingView,
5 Platform,
6 Pressable,
7 ScrollView,
8 StyleSheet,
9 Text,
10 TextInput,
11 View,
12 useColorScheme,
13} from 'react-native';
14import Animated, {
15 Easing,
16 FadeIn,
17 FadeInDown,
18 FadeOut,
19 interpolate,
20 interpolateColor,
21 LinearTransition,
22 useAnimatedScrollHandler,
23 useAnimatedStyle,
24 useSharedValue,
25 withSequence,
26 withSpring,
27 withTiming,
28 ZoomIn,
29} from 'react-native-reanimated';
30import { LinearGradient } from 'expo-linear-gradient';
31import { useSafeAreaInsets } from 'react-native-safe-area-context';
32import Svg, { Circle } from 'react-native-svg';
33import { Check, ChevronDown, Clock, Flag, ListTodo, Plus, Sparkles } from 'lucide-react-native';
34
35// ─── Brand ──────────────────────────────────────────────────────────────────
36// The screen's accent. Every accent colour below derives from these, so changing them rebrands the screen.
37
38const ACCENT = '#1064FF';
39const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill
40
41/** `hex` at `alpha` opacity, as rgba(). */
42function tint(hex: string, alpha: number) {
43 const n = parseInt(hex.slice(1), 16);
44 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;
45}
46
47/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */
48function shade(hex: string, amount: number) {
49 const n = parseInt(hex.slice(1), 16);
50 const target = amount < 0 ? 255 : 0;
51 const p = Math.abs(amount);
52 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');
53 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();
54}
55
56// ─── Sample data ────────────────────────────────────────────────────────────
57
58const DATE = 'Tuesday, November 17';
59const AVATAR = 'https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=200&q=80';
60
61const LISTS = ['Work', 'Personal', 'Errands'] as const;
62const FILTERS = ['All', ...LISTS] as const;
63type List = (typeof LISTS)[number];
64type Filter = (typeof FILTERS)[number];
65type Priority = 'high' | 'medium' | 'low';
66
67type Task = {
68 id: string;
69 title: string;
70 time: string;
71 list: List;
72 priority: Priority;
73 done: boolean;
74};
75
76const TASKS: Task[] = [
77 { id: '1', title: 'Review Q4 roadmap with design', time: '9:30 AM', list: 'Work', priority: 'high', done: true },
78 { id: '2', title: 'Reply to Marcus on the API spec', time: '10:15 AM', list: 'Work', priority: 'high', done: false },
79 { id: '3', title: 'Ship onboarding copy updates', time: '11:00 AM', list: 'Work', priority: 'medium', done: false },
80 { id: '4', title: 'Call the landlord about the lease', time: '1:00 PM', list: 'Personal', priority: 'low', done: true },
81 { id: '5', title: 'Book dentist appointment', time: '2:30 PM', list: 'Personal', priority: 'medium', done: true },
82 { id: '6', title: 'Prep slides for Thursday standup', time: '4:00 PM', list: 'Work', priority: 'medium', done: true },
83 { id: '7', title: '30 min run along the river', time: '6:00 PM', list: 'Personal', priority: 'low', done: false },
84];
85
86const LIST_COLOR: Record<List, string> = { Work: '#1064FF', Personal: '#8B5CF6', Errands: '#F97316' };
87const PRIORITY_LABEL: Record<Priority, string | null> = { high: 'High', medium: 'Medium', low: null };
88
89/** The line under the count: it follows the day, and changes once everything is done. */
90function cheer(done: number, total: number) {
91 const left = total - done;
92 if (total === 0) return 'Add your first task below.';
93 if (left === 0) return 'All done. Enjoy your evening.';
94 if (done === 0) return 'A fresh day. Start with one.';
95 if (left === 1) return 'Just one more to go.';
96 if (done * 2 > total) return `Past halfway, only ${left} to go.`;
97 if (done * 2 === total) return `Halfway there. ${left} to go.`;
98 return `Nice start. ${left} more to go.`;
99}
100
101// ─── Palette ────────────────────────────────────────────────────────────────
102
103const DONE = '#10B981';
104const POP = { damping: 11, stiffness: 260, mass: 0.6 };
105const SPRING = { damping: 16, stiffness: 220, mass: 0.7 };
106const MOVE = LinearTransition.duration(300);
107// A checked task stays put for a beat, so the tick is seen before the row travels.
108const SETTLE_MS = 420;
109
110function usePalette() {
111 const dark = useColorScheme() === 'dark';
112 return {
113 dark,
114 bg: dark ? '#000000' : '#F5F5F7',
115 bgClear: dark ? 'rgba(0,0,0,0)' : 'rgba(245,245,247,0)',
116 fg: dark ? '#FAFAFA' : '#0A0A0A',
117 muted: dark ? '#8E8E93' : '#6E6E76',
118 faint: dark ? '#55555B' : '#A1A1AA',
119 card: dark ? '#111113' : '#FFFFFF',
120 line: dark ? '#232327' : '#E8E8EB',
121 chip: dark ? '#1C1C1F' : '#ECECEF',
122 chipCountOn: dark ? '#6E6E76' : '#A1A1AA',
123 hero: (dark ? [shade(ACCENT, -0.12), shade(ACCENT, 0.06), shade(ACCENT, 0.29)] : [shade(ACCENT, -0.2), ACCENT, shade(ACCENT, 0.19)]) as [string, string, string],
124 heroDone: (dark ? ['#19C48C', '#0EA371', '#08744F'] : ['#34D399', '#10B981', '#059669']) as [string, string, string],
125 high: dark ? { fg: '#FF7B7B', bg: 'rgba(239,68,68,0.16)' } : { fg: '#DC2626', bg: 'rgba(239,68,68,0.10)' },
126 medium: dark ? { fg: '#FBBF24', bg: 'rgba(245,158,11,0.15)' } : { fg: '#B45309', bg: 'rgba(245,158,11,0.14)' },
127 };
128}
129
130// ─── Small pieces ───────────────────────────────────────────────────────────
131
132function Tap({ children, label, onPress, to = 0.92 }: { children: ReactNode; label: string; onPress?: () => void; to?: number }) {
133 const scale = useSharedValue(1);
134 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
135 return (
136 <Pressable
137 role="button"
138 aria-label={label}
139 onPress={onPress}
140 hitSlop={6}
141 onPressIn={() => (scale.value = withSpring(to, SPRING))}
142 onPressOut={() => (scale.value = withSpring(1, SPRING))}
143 >
144 <Animated.View style={style}>{children}</Animated.View>
145 </Pressable>
146 );
147}
148
149/** Eases a number toward its target on the JS thread, so SVG props can follow it on web and native alike. */
150function useTween(target: number, duration = 800) {
151 const [value, setValue] = useState(0);
152 const latest = useRef(0);
153 useEffect(() => {
154 const from = latest.current;
155 const started = Date.now();
156 let frame = 0;
157 const tick = () => {
158 const t = Math.min(1, (Date.now() - started) / duration);
159 latest.current = from + (target - from) * (1 - Math.pow(1 - t, 3));
160 setValue(latest.current);
161 if (t < 1) frame = requestAnimationFrame(tick);
162 };
163 frame = requestAnimationFrame(tick);
164 return () => cancelAnimationFrame(frame);
165 }, [target, duration]);
166 return value;
167}
168
169// ─── Progress card ──────────────────────────────────────────────────────────
170
171const RING = 80;
172const STROKE = 8;
173const RADIUS = (RING - STROKE) / 2;
174const LENGTH = 2 * Math.PI * RADIUS;
175
176/** The arc and the number inside it share one tweened value, so they always agree. */
177function ProgressRing({ share, complete }: { share: number; complete: boolean }) {
178 const value = useTween(share);
179 const percent = Math.round(value * 100);
180 return (
181 <View role="progressbar" aria-label="Tasks done today" aria-valuemin={0} aria-valuemax={100} aria-valuenow={percent} style={styles.ring}>
182 {/* Turned a quarter back so the arc starts at twelve o'clock. */}
183 <View style={styles.ringArc}>
184 <Svg width={RING} height={RING}>
185 <Circle cx={RING / 2} cy={RING / 2} r={RADIUS} stroke={tint(ON_ACCENT, 0.24)} strokeWidth={STROKE} fill="none" />
186 {value > 0.004 && (
187 <Circle
188 cx={RING / 2}
189 cy={RING / 2}
190 r={RADIUS}
191 stroke={ON_ACCENT}
192 strokeWidth={STROKE}
193 strokeLinecap="round"
194 strokeDasharray={`${LENGTH} ${LENGTH}`}
195 strokeDashoffset={LENGTH * (1 - value)}
196 fill="none"
197 />
198 )}
199 </Svg>
200 </View>
201 {complete && percent === 100 ? (
202 <Animated.View key="check" entering={ZoomIn.duration(260)}>
203 <Check size={30} color={ON_ACCENT} strokeWidth={3} />
204 </Animated.View>
205 ) : (
206 <Text style={styles.ringPercent}>
207 {percent}
208 <Text style={styles.ringPercentSign}>%</Text>
209 </Text>
210 )}
211 </View>
212 );
213}
214
215function ProgressCard({ done, total }: { done: number; total: number }) {
216 const c = usePalette();
217 const complete = total > 0 && done === total;
218 const finish = useSharedValue(complete ? 1 : 0);
219 useEffect(() => {
220 finish.value = withTiming(complete ? 1 : 0, { duration: 450 });
221 }, [complete, finish]);
222 const finished = useAnimatedStyle(() => ({ opacity: finish.value }));
223
224 return (
225 <View style={complete ? (c.dark ? styles.heroGlowDoneDark : styles.heroGlowDone) : c.dark ? styles.heroGlowDark : styles.heroGlow}>
226 <View style={styles.hero}>
227 <LinearGradient colors={c.hero} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={StyleSheet.absoluteFill} />
228 {/* The emerald finish fades in over the blue when the last task is checked. */}
229 <Animated.View style={[StyleSheet.absoluteFill, finished]}>
230 <LinearGradient colors={c.heroDone} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={styles.heroDoneFill} />
231 </Animated.View>
232 <View style={styles.heroOrbLarge} />
233 <View style={styles.heroOrbSmall} />
234 <View style={[StyleSheet.absoluteFill, styles.heroEdge]} />
235
236 <ProgressRing share={total ? done / total : 0} complete={complete} />
237 <View style={styles.heroText}>
238 <Text style={styles.heroEyebrow}>DAILY PROGRESS</Text>
239 <Animated.Text key={`${done}/${total}`} entering={FadeInDown.duration(220)} style={styles.heroCount}>
240 {done} of {total} done
241 </Animated.Text>
242 <Text style={styles.heroCheer}>{cheer(done, total)}</Text>
243 </View>
244 </View>
245 </View>
246 );
247}
248
249// ─── Filter chips ───────────────────────────────────────────────────────────
250
251function Chip({ label, count, selected, onPress }: { label: string; count: number; selected: boolean; onPress: () => void }) {
252 const c = usePalette();
253 const on = useSharedValue(selected ? 1 : 0);
254 const scale = useSharedValue(1);
255 useEffect(() => {
256 on.value = withTiming(selected ? 1 : 0, { duration: 200 });
257 }, [selected, on]);
258 const box = useAnimatedStyle(() => ({
259 backgroundColor: interpolateColor(on.value, [0, 1], [c.card, c.fg]),
260 borderColor: interpolateColor(on.value, [0, 1], [c.line, c.fg]),
261 transform: [{ scale: scale.value }],
262 }));
263 const name = useAnimatedStyle(() => ({ color: interpolateColor(on.value, [0, 1], [c.fg, c.bg]) }));
264 const tally = useAnimatedStyle(() => ({ color: interpolateColor(on.value, [0, 1], [c.muted, c.chipCountOn]) }));
265 return (
266 <Pressable
267 role="tab"
268 aria-label={`${label}, ${count} ${count === 1 ? 'task' : 'tasks'}`}
269 aria-selected={selected}
270 onPress={onPress}
271 onPressIn={() => (scale.value = withSpring(0.94, SPRING))}
272 onPressOut={() => (scale.value = withSpring(1, SPRING))}
273 >
274 <Animated.View style={[styles.chip, box]}>
275 <Animated.Text style={[styles.chipLabel, name]}>{label}</Animated.Text>
276 <Animated.Text style={[styles.chipCount, tally]}>{count}</Animated.Text>
277 </Animated.View>
278 </Pressable>
279 );
280}
281
282// ─── A task ─────────────────────────────────────────────────────────────────
283
284function TaskRow({ task, onToggle }: { task: Task; onToggle: () => void }) {
285 const c = usePalette();
286 const fill = useSharedValue(task.done ? 1 : 0);
287 const strike = useSharedValue(task.done ? 1 : 0);
288 const halo = useSharedValue(1);
289 const press = useSharedValue(1);
290 const was = useRef(task.done);
291
292 useEffect(() => {
293 if (was.current === task.done) return;
294 was.current = task.done;
295 // The fill overshoots on the way in: that is the pop.
296 fill.value = task.done ? withSpring(1, POP) : withTiming(0, { duration: 160 });
297 strike.value = withTiming(task.done ? 1 : 0, { duration: 280, easing: Easing.out(Easing.cubic) });
298 if (task.done) {
299 halo.value = 0;
300 halo.value = withTiming(1, { duration: 520, easing: Easing.out(Easing.cubic) });
301 }
302 }, [task.done, fill, strike, halo]);
303
304 const cardStyle = useAnimatedStyle(() => ({ transform: [{ scale: press.value }] }));
305 const fillStyle = useAnimatedStyle(() => ({ opacity: Math.min(1, fill.value * 3), transform: [{ scale: fill.value }] }));
306 const markStyle = useAnimatedStyle(() => ({ transform: [{ scale: interpolate(fill.value, [0, 0.5, 1], [0, 0.3, 1]) }] }));
307 const haloStyle = useAnimatedStyle(() => ({ opacity: (1 - halo.value) * 0.55, transform: [{ scale: 1 + halo.value * 0.9 }] }));
308 const titleStyle = useAnimatedStyle(() => ({ color: interpolateColor(strike.value, [0, 1], [c.fg, c.muted]) }));
309 const strikeStyle = useAnimatedStyle(() => ({ opacity: strike.value > 0.01 ? 1 : 0, transform: [{ scaleX: strike.value }] }));
310 const fadeStyle = useAnimatedStyle(() => ({ opacity: 1 - strike.value }));
311
312 const label = PRIORITY_LABEL[task.priority];
313 const tone = task.priority === 'high' ? c.high : c.medium;
314
315 return (
316 <Pressable
317 role="checkbox"
318 aria-checked={task.done}
319 aria-label={task.title}
320 onPress={onToggle}
321 onPressIn={() => (press.value = withSpring(0.975, SPRING))}
322 onPressOut={() => (press.value = withSpring(1, SPRING))}
323 >
324 <Animated.View
325 style={[
326 styles.task,
327 { backgroundColor: c.card, borderColor: c.line },
328 cardStyle,
329 ]}
330 >
331 {/* Checkbox: an empty ring, an emerald fill that pops in, a halo that rings out. */}
332 <View style={styles.check}>
333 <Animated.View style={[styles.checkRing, styles.checkHalo, haloStyle]} />
334 <View style={[styles.checkRing, { borderColor: c.faint }]} />
335 <Animated.View style={[styles.checkFill, fillStyle]}>
336 <Animated.View style={markStyle}>
337 <Check size={15} color="#FFFFFF" strokeWidth={3.4} />
338 </Animated.View>
339 </Animated.View>
340 </View>
341
342 <View style={styles.taskBody}>
343 <View style={styles.taskTitleWrap}>
344 <Animated.Text numberOfLines={1} style={[styles.taskTitle, titleStyle]}>
345 {task.title}
346 </Animated.Text>
347 {/* The strike is drawn left to right across the title. */}
348 <Animated.View style={[styles.strike, { backgroundColor: c.muted }, strikeStyle]} />
349 </View>
350 <View style={styles.taskMeta}>
351 <View style={styles.taskTime}>
352 <Clock size={12.5} color={c.muted} />
353 <Text style={[styles.taskMetaText, { color: c.muted }]}>{task.time}</Text>
354 </View>
355 <View style={styles.taskList}>
356 <View style={[styles.taskListDot, { backgroundColor: LIST_COLOR[task.list] }]} />
357 <Text style={[styles.taskMetaText, { color: c.muted }]}>{task.list}</Text>
358 </View>
359 <View style={styles.taskMetaGap} />
360 {label && (
361 <Animated.View style={[styles.priority, { backgroundColor: tone.bg }, fadeStyle]}>
362 <Flag size={11} color={tone.fg} fill={tone.fg} />
363 <Text style={[styles.priorityText, { color: tone.fg }]}>{label}</Text>
364 </Animated.View>
365 )}
366 </View>
367 </View>
368 </Animated.View>
369 </Pressable>
370 );
371}
372
373function SectionTitle({ title, count }: { title: string; count: number }) {
374 const c = usePalette();
375 return (
376 <View style={styles.sectionTitle}>
377 <Text style={[styles.sectionTitleText, { color: c.fg }]}>{title}</Text>
378 <View style={[styles.sectionCount, { backgroundColor: c.chip }]}>
379 <Text style={[styles.sectionCountText, { color: c.muted }]}>{count}</Text>
380 </View>
381 </View>
382 );
383}
384
385// ─── Composer ───────────────────────────────────────────────────────────────
386
387function Composer({ placeholder, onAdd }: { placeholder: string; onAdd: (title: string) => void }) {
388 const c = usePalette();
389 const insets = useSafeAreaInsets();
390 const [text, setText] = useState('');
391 const [focused, setFocused] = useState(false);
392 const input = useRef<ComponentRef<typeof TextInput>>(null);
393 const ready = text.trim().length > 0;
394 const on = useSharedValue(0);
395 const ring = useSharedValue(0);
396 const scale = useSharedValue(1);
397
398 useEffect(() => {
399 on.value = withTiming(ready ? 1 : 0, { duration: 200, easing: Easing.out(Easing.cubic) });
400 }, [ready, on]);
401 useEffect(() => {
402 ring.value = withTiming(focused ? 1 : 0, { duration: 180 });
403 }, [focused, ring]);
404
405 const fieldStyle = useAnimatedStyle(() => ({ borderColor: interpolateColor(ring.value, [0, 1], [c.line, ACCENT]) }));
406 const buttonStyle = useAnimatedStyle(() => ({
407 backgroundColor: interpolateColor(on.value, [0, 1], [c.chip, ACCENT]),
408 transform: [{ scale: scale.value * interpolate(on.value, [0, 1], [0.9, 1]) }],
409 }));
410 const plusStyle = useAnimatedStyle(() => ({ transform: [{ rotate: `${interpolate(on.value, [0, 1], [0, 90])}deg` }] }));
411
412 const submit = () => {
413 const title = text.trim();
414 if (!title) return;
415 onAdd(title);
416 setText('');
417 // Stay in the field, so several tasks can be added in a row.
418 input.current?.focus();
419 scale.value = withSequence(withSpring(0.82, POP), withSpring(1, POP));
420 };
421
422 return (
423 <View style={[styles.composer, { paddingBottom: insets.bottom + 10, backgroundColor: c.bg }]}>
424 {/* The list fades out as it slides under the composer. */}
425 <LinearGradient colors={[c.bgClear, c.bg]} style={styles.composerFade} />
426 <Animated.View
427 style={[
428 styles.field,
429 c.dark ? styles.fieldDark : styles.fieldLight,
430 { backgroundColor: c.card },
431 fieldStyle,
432 ]}
433 >
434 {/* A ghost checkbox: the field reads as the next row of the list. */}
435 <View style={[styles.ghostCheck, { borderColor: focused ? ACCENT : c.faint }]} />
436 <TextInput
437 ref={input}
438 value={text}
439 onChangeText={setText}
440 placeholder={placeholder}
441 placeholderTextColor={c.faint}
442 aria-label="New task"
443 selectionColor={ACCENT}
444 returnKeyType="done"
445 submitBehavior="submit"
446 blurOnSubmit={false}
447 onSubmitEditing={submit}
448 onFocus={() => setFocused(true)}
449 onBlur={() => setFocused(false)}
450 style={[styles.input, { color: c.fg }, Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null]}
451 />
452 <Pressable role="button" aria-label="Add task" aria-disabled={!ready} disabled={!ready} onPress={submit} hitSlop={6}>
453 <Animated.View style={[styles.add, buttonStyle]}>
454 <Animated.View style={plusStyle}>
455 <Plus size={21} color={ready ? ON_ACCENT : c.muted} strokeWidth={2.6} />
456 </Animated.View>
457 </Animated.View>
458 </Pressable>
459 </Animated.View>
460 </View>
461 );
462}
463
464// ─── Screen ─────────────────────────────────────────────────────────────────
465
466// `filed` is the section a row sits in; it trails `done` by a beat.
467type Row = Task & { filed: boolean };
468
469export default function TaskListScreen() {
470 const c = usePalette();
471 const insets = useSafeAreaInsets();
472 const scroll = useRef<ComponentRef<typeof ScrollView>>(null);
473 const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
474 const [tasks, setTasks] = useState<Row[]>(() => TASKS.map((t) => ({ ...t, filed: t.done })));
475 const [filter, setFilter] = useState<Filter>('All');
476 const [showDone, setShowDone] = useState(true);
477 const [intro, setIntro] = useState(true);
478 const [fresh, setFresh] = useState<string | null>(null);
479
480 useEffect(() => {
481 const pending = timers.current;
482 pending.push(setTimeout(() => setIntro(false), 1200));
483 return () => pending.forEach(clearTimeout);
484 }, []);
485
486 const scrollY = useSharedValue(0);
487 const onScroll = useAnimatedScrollHandler((e) => {
488 scrollY.value = e.contentOffset.y;
489 });
490 // A compact title fades in once the large one has scrolled away.
491 const compact = useAnimatedStyle(() => ({ opacity: interpolate(scrollY.value, [34, 62], [0, 1], 'clamp') }));
492 const chevron = useSharedValue(0);
493 const chevronStyle = useAnimatedStyle(() => ({ transform: [{ rotate: `${chevron.value}deg` }] }));
494
495 const toggle = (id: string) => {
496 setTasks((prev) => prev.map((t) => (t.id === id ? { ...t, done: !t.done } : t)));
497 timers.current.push(setTimeout(() => setTasks((prev) => prev.map((t) => (t.id === id ? { ...t, filed: t.done } : t))), SETTLE_MS));
498 };
499
500 const add = (title: string) => {
501 const id = `new-${Date.now()}`;
502 // Replace with a write to your task store.
503 setTasks((prev) => [{ id, title, time: 'Anytime', list: filter === 'All' ? 'Personal' : filter, priority: 'low', done: false, filed: false }, ...prev]);
504 setFresh(id);
505 scroll.current?.scrollTo({ y: 0, animated: true });
506 };
507
508 const toggleDone = () => {
509 chevron.value = withTiming(showDone ? -90 : 0, { duration: 220 });
510 setShowDone((s) => !s);
511 };
512
513 const inFilter = (t: Task, f: Filter) => f === 'All' || t.list === f;
514 const visible = tasks.filter((t) => inFilter(t, filter));
515 const todo = visible.filter((t) => !t.filed);
516 const done = visible.filter((t) => t.filed);
517 const doneCount = tasks.filter((t) => t.done).length;
518
519 const rise = (i: number) => FadeInDown.delay(60 + i * 70).duration(440);
520 const rowEntering = (id: string, i: number) => (intro ? FadeInDown.delay(260 + i * 45).duration(420) : id === fresh ? FadeInDown.duration(340) : FadeIn.duration(240));
521
522 return (
523 <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={[styles.screen, { backgroundColor: c.bg }]}>
524 <Animated.ScrollView
525 ref={scroll}
526 onScroll={onScroll}
527 scrollEventThrottle={16}
528 keyboardShouldPersistTaps="handled"
529 showsVerticalScrollIndicator={false}
530 contentContainerStyle={[styles.content, { paddingTop: insets.top + 10 }]}
531 >
532 {/* Header */}
533 <Animated.View entering={rise(0)} style={styles.header}>
534 <View>
535 <Text style={[styles.date, { color: c.muted }]}>{DATE}</Text>
536 <Text role="heading" style={[styles.title, { color: c.fg }]}>
537 Today
538 </Text>
539 </View>
540 <Tap label="Your profile">
541 <View style={[styles.avatar, c.dark ? styles.avatarDark : styles.avatarLight, { borderColor: c.card, backgroundColor: c.chip }]}>
542 <Image source={{ uri: AVATAR }} alt="Your profile photo" style={styles.avatarImage} />
543 </View>
544 </Tap>
545 </Animated.View>
546
547 <Animated.View entering={rise(1)} style={styles.heroSlot}>
548 <ProgressCard done={doneCount} total={tasks.length} />
549 </Animated.View>
550
551 {/* Filters: the row bleeds to both edges of the screen */}
552 <Animated.View entering={rise(2)} style={styles.filters}>
553 <ScrollView horizontal role="tablist" showsHorizontalScrollIndicator={false} keyboardShouldPersistTaps="handled" contentContainerStyle={styles.filtersContent}>
554 {FILTERS.map((f) => (
555 <Chip key={f} label={f} count={tasks.filter((t) => inFilter(t, f)).length} selected={f === filter} onPress={() => setFilter(f)} />
556 ))}
557 </ScrollView>
558 </Animated.View>
559
560 {/* One flat run of keyed rows, so a task can travel between sections instead of remounting. */}
561 <View style={styles.list}>
562 {visible.length === 0 ? (
563 <Animated.View key="empty" entering={FadeIn.delay(140).duration(280)} exiting={FadeOut.duration(120)} style={styles.empty}>
564 <View style={[styles.emptyIcon, { backgroundColor: c.card, borderColor: c.line }]}>
565 <ListTodo size={32} color={filter === 'All' ? ACCENT : LIST_COLOR[filter]} strokeWidth={1.9} />
566 </View>
567 <Text style={[styles.emptyTitle, { color: c.fg }]}>{filter === 'All' ? 'No tasks yet' : `Nothing in ${filter} yet`}</Text>
568 <Text style={[styles.emptyBody, { color: c.muted }]}>Add a task below and it will show up here.</Text>
569 </Animated.View>
570 ) : (
571 <Animated.View key="todo-title" layout={MOVE} entering={intro ? rise(3) : FadeIn.duration(240)} exiting={FadeOut.duration(120)} style={styles.todoTitle}>
572 <SectionTitle title="To do" count={todo.length} />
573 </Animated.View>
574 )}
575
576 {visible.length > 0 && todo.length === 0 && (
577 <Animated.View
578 key="clear"
579 layout={MOVE}
580 entering={FadeIn.duration(260)}
581 exiting={FadeOut.duration(120)}
582 style={[styles.clear, { borderColor: c.line }]}
583 >
584 <Sparkles size={18} color={DONE} />
585 <Text style={[styles.clearText, { color: c.muted }]}>All clear. Nothing left to do here.</Text>
586 </Animated.View>
587 )}
588
589 {todo.map((task, i) => (
590 <Animated.View key={task.id} layout={MOVE} entering={rowEntering(task.id, i)} exiting={FadeOut.duration(140)} style={styles.row}>
591 <TaskRow task={task} onToggle={() => toggle(task.id)} />
592 </Animated.View>
593 ))}
594
595 {done.length > 0 && (
596 <Animated.View key="done-title" layout={MOVE} entering={intro ? rise(5) : FadeIn.duration(240)} exiting={FadeOut.duration(120)} style={styles.doneTitle}>
597 <Pressable role="button" aria-label={showDone ? 'Hide done tasks' : 'Show done tasks'} aria-expanded={showDone} onPress={toggleDone} hitSlop={8} style={styles.doneToggle}>
598 <SectionTitle title="Done" count={done.length} />
599 <Animated.View style={chevronStyle}>
600 <ChevronDown size={20} color={c.muted} />
601 </Animated.View>
602 </Pressable>
603 </Animated.View>
604 )}
605
606 {showDone &&
607 done.map((task, i) => (
608 <Animated.View key={task.id} layout={MOVE} entering={rowEntering(task.id, todo.length + i)} exiting={FadeOut.duration(140)} style={styles.row}>
609 <TaskRow task={task} onToggle={() => toggle(task.id)} />
610 </Animated.View>
611 ))}
612 </View>
613 </Animated.ScrollView>
614
615 <Composer placeholder={filter === 'All' ? 'Add a task' : `Add a task to ${filter}`} onAdd={add} />
616
617 {/* Status bar backdrop, and the compact title that joins it on scroll */}
618 <View style={styles.top}>
619 <View style={{ height: insets.top, backgroundColor: c.bg }} />
620 <Animated.View style={[styles.compact, { backgroundColor: c.bg, borderBottomColor: c.line }, compact]}>
621 <Text style={[styles.compactTitle, { color: c.fg }]}>Today</Text>
622 </Animated.View>
623 </View>
624 </KeyboardAvoidingView>
625 );
626}
627
628// ─── Styles ─────────────────────────────────────────────────────────────────
629
630const styles = StyleSheet.create({
631 screen: { flex: 1 },
632 content: { paddingHorizontal: 20, paddingBottom: 36 },
633
634 // Header
635 header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
636 date: { fontSize: 12.5, fontWeight: '700', letterSpacing: 1, textTransform: 'uppercase' },
637 title: { fontSize: 38, lineHeight: 44, fontWeight: '800', letterSpacing: -1.2, marginTop: 2 },
638 avatar: { width: 50, height: 50, borderRadius: 25, borderWidth: 2 },
639 // A shadow's props stay together in one style object: React Native Web builds the shadow per object.
640 avatarLight: { shadowColor: '#000', shadowOpacity: 0.12, shadowRadius: 10, shadowOffset: { width: 0, height: 4 } },
641 avatarDark: { shadowColor: '#000', shadowOpacity: 0, shadowRadius: 10, shadowOffset: { width: 0, height: 4 } },
642 avatarImage: { width: '100%', height: '100%', borderRadius: 25 },
643 top: { position: 'absolute', top: 0, left: 0, right: 0, pointerEvents: 'none' },
644 compact: { height: 44, alignItems: 'center', justifyContent: 'center', borderBottomWidth: 1 },
645 compactTitle: { fontSize: 16.5, fontWeight: '700', letterSpacing: -0.2 },
646
647 // Progress card
648 heroSlot: { marginTop: 20 },
649 heroGlow: { borderRadius: 28, shadowColor: ACCENT, shadowOpacity: 0.32, shadowRadius: 22, shadowOffset: { width: 0, height: 12 } },
650 heroGlowDark: { borderRadius: 28, shadowColor: ACCENT, shadowOpacity: 0.5, shadowRadius: 22, shadowOffset: { width: 0, height: 12 } },
651 heroGlowDone: { borderRadius: 28, shadowColor: DONE, shadowOpacity: 0.32, shadowRadius: 22, shadowOffset: { width: 0, height: 12 } },
652 heroGlowDoneDark: { borderRadius: 28, shadowColor: DONE, shadowOpacity: 0.5, shadowRadius: 22, shadowOffset: { width: 0, height: 12 } },
653 hero: { borderRadius: 28, overflow: 'hidden', padding: 20, flexDirection: 'row', alignItems: 'center', gap: 18 },
654 heroDoneFill: { flex: 1 },
655 heroOrbLarge: { position: 'absolute', right: -46, top: -70, width: 190, height: 190, borderRadius: 95, backgroundColor: tint(ON_ACCENT, 0.09) },
656 heroOrbSmall: { position: 'absolute', right: 44, bottom: -86, width: 150, height: 150, borderRadius: 75, backgroundColor: tint(ON_ACCENT, 0.06) },
657 heroEdge: { borderRadius: 28, borderTopWidth: 1, borderTopColor: tint(ON_ACCENT, 0.28) },
658 heroText: { flex: 1 },
659 heroEyebrow: { color: tint(ON_ACCENT, 0.78), fontSize: 11.5, fontWeight: '700', letterSpacing: 0.9 },
660 heroCount: { color: ON_ACCENT, fontSize: 25, fontWeight: '800', letterSpacing: -0.6, marginTop: 4 },
661 heroCheer: { color: tint(ON_ACCENT, 0.86), fontSize: 14.5, lineHeight: 20, marginTop: 3 },
662 ring: { width: RING, height: RING, alignItems: 'center', justifyContent: 'center' },
663 ringArc: { position: 'absolute', transform: [{ rotate: '-90deg' }] },
664 ringPercent: { color: ON_ACCENT, fontSize: 19, fontWeight: '800', letterSpacing: -0.4 },
665 ringPercentSign: { fontSize: 12, fontWeight: '700' },
666
667 // Filter chips
668 filters: { marginTop: 24, marginHorizontal: -20 },
669 filtersContent: { paddingHorizontal: 20, gap: 7 },
670 chip: { height: 40, borderRadius: 20, borderWidth: 1, paddingHorizontal: 13, flexDirection: 'row', alignItems: 'center', gap: 6 },
671 chipLabel: { fontSize: 14.5, fontWeight: '600' },
672 chipCount: { fontSize: 13.5, fontWeight: '600', fontVariant: ['tabular-nums'] },
673
674 // List and sections
675 list: { marginTop: 24 },
676 todoTitle: { marginBottom: 12 },
677 doneTitle: { marginTop: 16, marginBottom: 12 },
678 doneToggle: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
679 sectionTitle: { flexDirection: 'row', alignItems: 'center', gap: 8 },
680 sectionTitleText: { fontSize: 18, fontWeight: '700', letterSpacing: -0.3 },
681 sectionCount: { minWidth: 22, height: 22, borderRadius: 11, paddingHorizontal: 7, alignItems: 'center', justifyContent: 'center' },
682 sectionCountText: { fontSize: 12.5, fontWeight: '700', fontVariant: ['tabular-nums'] },
683 row: { marginBottom: 8 },
684 clear: {
685 flexDirection: 'row',
686 alignItems: 'center',
687 gap: 10,
688 borderRadius: 20,
689 borderWidth: 1.5,
690 borderStyle: 'dashed',
691 paddingHorizontal: 16,
692 paddingVertical: 16,
693 marginBottom: 8,
694 },
695 clearText: { fontSize: 15, fontWeight: '500' },
696 empty: { alignItems: 'center', paddingTop: 44, paddingHorizontal: 24 },
697 emptyIcon: { width: 76, height: 76, borderRadius: 26, borderWidth: 1, alignItems: 'center', justifyContent: 'center' },
698 emptyTitle: { fontSize: 19, fontWeight: '700', letterSpacing: -0.3, marginTop: 18 },
699 emptyBody: { fontSize: 15, lineHeight: 21, textAlign: 'center', marginTop: 6 },
700
701 // A task
702 task: { flexDirection: 'row', alignItems: 'center', gap: 13, borderRadius: 20, borderWidth: 1, paddingHorizontal: 14, paddingVertical: 12 },
703 check: { width: 26, height: 26, alignItems: 'center', justifyContent: 'center' },
704 checkRing: { position: 'absolute', width: 26, height: 26, borderRadius: 13, borderWidth: 2 },
705 checkHalo: { borderColor: DONE },
706 checkFill: { width: 26, height: 26, borderRadius: 13, backgroundColor: DONE, alignItems: 'center', justifyContent: 'center' },
707 taskBody: { flex: 1, gap: 5 },
708 taskTitleWrap: { alignSelf: 'flex-start', maxWidth: '100%' },
709 taskTitle: { fontSize: 16, lineHeight: 22, fontWeight: '600', letterSpacing: -0.2 },
710 strike: { position: 'absolute', left: 0, right: 0, top: 11, height: 1.5, borderRadius: 1, transformOrigin: 'left center' },
711 taskMeta: { flexDirection: 'row', alignItems: 'center', gap: 10, height: 22 },
712 taskTime: { flexDirection: 'row', alignItems: 'center', gap: 4 },
713 taskList: { flexDirection: 'row', alignItems: 'center', gap: 5 },
714 taskListDot: { width: 7, height: 7, borderRadius: 4 },
715 taskMetaText: { fontSize: 13 },
716 taskMetaGap: { flex: 1 },
717 priority: { flexDirection: 'row', alignItems: 'center', gap: 4, height: 22, paddingHorizontal: 8, borderRadius: 11 },
718 priorityText: { fontSize: 12, fontWeight: '700' },
719
720 // Composer
721 composer: { paddingHorizontal: 16, paddingTop: 6 },
722 composerFade: { position: 'absolute', left: 0, right: 0, top: -28, height: 28, pointerEvents: 'none' },
723 field: { height: 56, borderRadius: 28, borderWidth: 1.5, flexDirection: 'row', alignItems: 'center', gap: 12, paddingLeft: 16, paddingRight: 8 },
724 fieldLight: { shadowColor: '#000', shadowOpacity: 0.07, shadowRadius: 14, shadowOffset: { width: 0, height: 6 } },
725 fieldDark: { shadowColor: '#000', shadowOpacity: 0, shadowRadius: 14, shadowOffset: { width: 0, height: 6 } },
726 ghostCheck: { width: 24, height: 24, borderRadius: 12, borderWidth: 1.5, borderStyle: 'dashed' },
727 input: { flex: 1, height: '100%', fontSize: 16 },
728 add: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },
729});

More screens like this.

All Productivity