Mail inbox

An email inbox with motion: the large Inbox title folds into the bar and the search field shrinks to an icon as you scroll, rows swipe right to toggle read and left to archive (the action lights up and its icon pops past the threshold, the row collapses and an undo snackbar brings it back), tapping an avatar flips it to a check for multi-select with a contextual bar, stars pop with sparks, the tab indicator stretches between Primary, Updates and Promotions as the list slides, and the Compose button tucks to an icon on scroll and opens a sheet you can send or discard.

emailinboxmailswipe actionsmulti-selectcomposetabssnackbaranimationreanimated
Paste into Claude Code Cursor Codex Lovable RapidNative
Live preview · follows the site themeOpen full screen

Details

File
components/patterns/mail-inbox.tsx
Lines
1826
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/mail-inbox.tsx
1import { Fragment, useEffect, useMemo, useRef, useState, type ComponentProps, type ComponentRef, type ReactNode } from 'react';
2import {
3 Image,
4 KeyboardAvoidingView,
5 PanResponder,
6 Platform,
7 Pressable,
8 StyleSheet,
9 Text,
10 TextInput,
11 View,
12 useColorScheme,
13 useWindowDimensions,
14 type LayoutChangeEvent,
15} from 'react-native';
16import Animated, {
17 cancelAnimation,
18 Easing,
19 FadeIn,
20 FadeInDown,
21 FadeInLeft,
22 FadeInRight,
23 FadeInUp,
24 interpolate,
25 useAnimatedRef,
26 useAnimatedScrollHandler,
27 useAnimatedStyle,
28 useSharedValue,
29 withDelay,
30 withRepeat,
31 withSequence,
32 withSpring,
33 withTiming,
34 ZoomIn,
35 type SharedValue,
36} from 'react-native-reanimated';
37import { LinearGradient } from 'expo-linear-gradient';
38import { useSafeAreaInsets } from 'react-native-safe-area-context';
39import {
40 Archive,
41 BookOpen,
42 Check,
43 CheckCheck,
44 Croissant,
45 FileText,
46 Image as ImageIcon,
47 Inbox,
48 Landmark,
49 Mail,
50 MailOpen,
51 Mountain,
52 Package,
53 Paperclip,
54 Pencil,
55 Pin,
56 Plane,
57 Receipt,
58 Reply,
59 Scissors,
60 Search,
61 SearchX,
62 SendHorizontal,
63 ShieldCheck,
64 Shirt,
65 Star,
66 Trash2,
67 Truck,
68 Type,
69 X,
70 Zap,
71 type LucideIcon,
72} from 'lucide-react-native';
73
74// ─── Brand ──────────────────────────────────────────────────────────────────
75// The screen's accent and name. Every accent colour below derives from these, so changing them rebrands the screen.
76
77const ACCENT = '#1971C2';
78const ACCENT_DARK = '#4DABF7'; // the accent as text or a glyph on dark backgrounds
79const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill
80const APP_NAME = 'Cove';
81
82/** `hex` at `alpha` opacity, as rgba(). */
83function tint(hex: string, alpha: number) {
84 const n = parseInt(hex.slice(1), 16);
85 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;
86}
87
88/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */
89function shade(hex: string, amount: number) {
90 const n = parseInt(hex.slice(1), 16);
91 const target = amount < 0 ? 255 : 0;
92 const p = Math.abs(amount);
93 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');
94 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();
95}
96
97// ─── Sample data ────────────────────────────────────────────────────────────
98
99const photo = (id: string) => `https://images.unsplash.com/photo-${id}?w=160&q=80&fit=crop`;
100const DOMAIN = `${APP_NAME.toLowerCase()}.mail`;
101
102const ME = { name: 'Clara Holm', email: `clara@${DOMAIN}`, photo: photo('1438761681033-6461ffad8d80') };
103
104type Tab = 'primary' | 'updates' | 'promotions';
105type Day = 'today' | 'yesterday' | 'week';
106type LabelName = 'Work' | 'Travel' | 'Bills' | 'Home' | 'Offer';
107type Avatar = { photo: string } | { initials: string; colors: readonly [string, string] } | { icon: LucideIcon; colors: readonly [string, string] };
108
109type Thread = {
110 id: string;
111 tab: Tab;
112 day: Day;
113 from: string;
114 avatar: Avatar;
115 subject: string;
116 snippet: string;
117 time: string;
118 /** Messages in the conversation, shown as a bubble when there is more than one. */
119 count?: number;
120 file?: { name: string; kind: 'pdf' | 'image' };
121 labels?: LabelName[];
122 unread: boolean;
123 starred: boolean;
124 /** Feeds the summary card. */
125 needsReply?: boolean;
126 kind?: 'bill' | 'package';
127 /** Delivery progress, 0 (ordered) to 3 (delivered). */
128 track?: { step: number; text: string };
129 gone?: 'archived' | 'deleted';
130};
131
132const THREADS: Thread[] = [
133 // Primary
134 {
135 id: 'p1', tab: 'primary', day: 'today', from: 'Nadia Okafor', avatar: { photo: photo('1531123897727-8f129e1688ce') },
136 subject: 'Q1 roadmap: final deck for sign-off', snippet: 'I folded in your notes on the onboarding funnel. Can you approve before Thursday?',
137 time: '9:24', count: 4, file: { name: 'Roadmap-Q1.pdf', kind: 'pdf' }, labels: ['Work'], unread: true, starred: true, needsReply: true,
138 },
139 {
140 id: 'p2', tab: 'primary', day: 'today', from: 'Theo Marchetti', avatar: { photo: photo('1500648767791-00dcc994a43e') },
141 subject: 'Lisbon, Friday to Monday?', snippet: 'Found a flat in Alfama with a roof terrace. Flights are 64 each way if we book tonight.',
142 time: '8:51', count: 2, labels: ['Travel'], unread: true, starred: false, needsReply: true,
143 },
144 {
145 id: 'p3', tab: 'primary', day: 'today', from: 'Fernway Energy', avatar: { icon: Zap, colors: ['#FFB547', '#F07B16'] },
146 subject: 'Your December bill is ready', snippet: '$86.40 is due Friday, Dec 4. Autopay is off for this account, so pay by then to avoid a fee.',
147 time: '7:30', labels: ['Bills'], unread: true, starred: false, kind: 'bill',
148 },
149 {
150 id: 'p4', tab: 'primary', day: 'today', from: 'Yasmin Aziz', avatar: { photo: photo('1531746020798-e6953c6e8e04') },
151 subject: 'Re: Kitchen quotes', snippet: 'The second quote includes the tiling, so it is closer than it looks. Photos of both attached.',
152 time: '7:02', count: 6, file: { name: 'Kitchen-tiles.jpg', kind: 'image' }, labels: ['Home'], unread: false, starred: false, needsReply: true,
153 },
154 {
155 id: 'p5', tab: 'primary', day: 'today', from: 'Walter Brandt', avatar: { photo: photo('1472099645785-5658abf4ff4e') },
156 subject: 'Lease renewal for 4B', snippet: 'Good news: the rent stays the same next year. Sign by Dec 15 and you are all set.',
157 time: '6:48', unread: false, starred: true,
158 },
159 {
160 id: 'p6', tab: 'primary', day: 'yesterday', from: 'Marisol Vega', avatar: { photo: photo('1494790108377-be9c29b29330') },
161 subject: 'Dinner at ours on Saturday?', snippet: "Bring nothing but yourselves. The kids are at grandma's, so we can stay up late.",
162 time: '6:15 PM', count: 3, unread: false, starred: false,
163 },
164 {
165 id: 'p7', tab: 'primary', day: 'yesterday', from: 'Jonah Whitfield', avatar: { initials: 'JW', colors: ['#2DD4BF', '#0F766E'] },
166 subject: 'Offer letter, countersigned', snippet: 'Attaching the signed copy for your records. Welcome aboard, officially!',
167 time: '11:40 AM', file: { name: 'Offer-signed.pdf', kind: 'pdf' }, labels: ['Work'], unread: false, starred: true,
168 },
169 {
170 id: 'p8', tab: 'primary', day: 'week', from: 'Halden Air', avatar: { icon: Plane, colors: ['#7DD3FC', '#0369A1'] },
171 subject: 'Boarding pass: SFO to LIS', snippet: 'Seat 14A, gate opens at 6:10 PM. Check in online to skip the desk.',
172 time: 'Mon', file: { name: 'Boarding-pass.pdf', kind: 'pdf' }, labels: ['Travel'], unread: false, starred: true,
173 },
174 {
175 id: 'p9', tab: 'primary', day: 'week', from: 'Rafael Cruz', avatar: { photo: photo('1507003211169-0a1dd7228f2d') },
176 subject: 'Photos from the ridge hike', snippet: 'Uploaded 48 of them. The one at the summit is my new lock screen.',
177 time: 'Sun', count: 3, file: { name: 'Summit.jpg', kind: 'image' }, unread: false, starred: false,
178 },
179 {
180 id: 'p10', tab: 'primary', day: 'week', from: 'Studio Nine', avatar: { initials: 'S9', colors: ['#4B5563', '#111827'] },
181 subject: 'Receipt for invoice 0412', snippet: 'Thanks for the payment. Your receipt is attached. See you at the next session.',
182 time: 'Sat', file: { name: 'Receipt-0412.pdf', kind: 'pdf' }, unread: false, starred: false,
183 },
184 // Updates
185 {
186 id: 'u1', tab: 'updates', day: 'today', from: 'Parcelly', avatar: { icon: Package, colors: ['#FF8A4C', '#E8430C'] },
187 subject: 'Out for delivery, arriving by 8 PM', snippet: 'Two items from Thimble & Co are on the van. Track the driver live.',
188 time: '9:02', unread: true, starred: false, kind: 'package', track: { step: 2, text: 'Out for delivery' },
189 },
190 {
191 id: 'u2', tab: 'updates', day: 'today', from: `${APP_NAME} Accounts`, avatar: { icon: ShieldCheck, colors: [ACCENT, shade(ACCENT, 0.3)] },
192 subject: 'New sign-in on a Mac in Lisbon', snippet: 'If this was you, there is nothing to do. If not, secure your account now.',
193 time: '8:14', unread: true, starred: false,
194 },
195 {
196 id: 'u3', tab: 'updates', day: 'yesterday', from: 'Thimble & Co', avatar: { icon: Scissors, colors: ['#F472B6', '#DB2777'] },
197 subject: 'Shipped: order #48213', snippet: 'Your linen throw is on its way. Estimated arrival Thursday, Dec 3.',
198 time: '3:22 PM', unread: true, starred: false, kind: 'package', track: { step: 1, text: 'Shipped' },
199 },
200 {
201 id: 'u4', tab: 'updates', day: 'yesterday', from: 'Ledgerly Bank', avatar: { icon: Landmark, colors: ['#34D399', '#047857'] },
202 subject: 'Your November statement', snippet: 'The statement for the account ending 4471 is ready to view.',
203 time: '9:10 AM', file: { name: 'Statement-Nov.pdf', kind: 'pdf' }, labels: ['Bills'], unread: false, starred: false,
204 },
205 {
206 id: 'u5', tab: 'updates', day: 'week', from: 'Rowan Price', avatar: { initials: 'RP', colors: ['#A3E635', '#4D7C0F'] },
207 subject: 'Updated invitation: Design crit', snippet: 'Rowan moved this to Thursday at 2 PM. Six guests have accepted.',
208 time: 'Mon', labels: ['Work'], unread: false, starred: false,
209 },
210 // Promotions
211 {
212 id: 'm1', tab: 'promotions', day: 'today', from: 'Fieldnote Goods', avatar: { icon: Shirt, colors: ['#94A3B8', '#475569'] },
213 subject: '30% off winter layers ends tonight', snippet: 'Our warmest wool overshirts and parkas, while sizes last.',
214 time: '8:00', labels: ['Offer'], unread: true, starred: false,
215 },
216 {
217 id: 'm2', tab: 'promotions', day: 'yesterday', from: 'Brightloaf Bakery', avatar: { icon: Croissant, colors: ['#FCD34D', '#D97706'] },
218 subject: 'Your free pastry is waiting', snippet: 'You hit 10 visits. Show this email at the counter any day this week.',
219 time: '10:30 AM', unread: true, starred: false,
220 },
221 {
222 id: 'm3', tab: 'promotions', day: 'week', from: 'Kestrel Outdoors', avatar: { icon: Mountain, colors: ['#4ADE80', '#15803D'] },
223 subject: 'New trail shoes just dropped', snippet: 'Lighter, grippier and made with 40% recycled rubber.',
224 time: 'Tue', unread: false, starred: false,
225 },
226 {
227 id: 'm4', tab: 'promotions', day: 'week', from: 'Paperleaf Books', avatar: { icon: BookOpen, colors: ['#FB7185', '#BE123C'] },
228 subject: 'Picks for you this week', snippet: 'Based on your last order: three new novels and a cookbook.',
229 time: 'Sun', unread: false, starred: false,
230 },
231];
232
233const TABS: { id: Tab; title: string }[] = [
234 { id: 'primary', title: 'Primary' },
235 { id: 'updates', title: 'Updates' },
236 { id: 'promotions', title: 'Promotions' },
237];
238
239const DAYS: { id: Day; title: string }[] = [
240 { id: 'today', title: 'Today' },
241 { id: 'yesterday', title: 'Yesterday' },
242 { id: 'week', title: 'This week' },
243];
244
245const CONTACTS = [
246 { name: 'Theo Marchetti', email: 'theo@marchetti.studio', photo: photo('1500648767791-00dcc994a43e') },
247 { name: 'Nadia Okafor', email: 'nadia@northloop.io', photo: photo('1531123897727-8f129e1688ce') },
248 { name: 'Marisol Vega', email: 'marisol@vegahome.net', photo: photo('1494790108377-be9c29b29330') },
249];
250
251// ─── Palette ────────────────────────────────────────────────────────────────
252
253const ARCHIVE = '#12A150'; // the archive swipe: success green, whatever the brand
254const STAR = '#F5A524';
255const LABELS: Record<LabelName, string> = { Work: '#0C8599', Travel: '#E8590C', Bills: '#E03131', Home: '#2F9E44', Offer: '#D6336C' };
256
257const COLUMN = 520; // widest the screen gets on tablets and the web
258const GUTTER = 16;
259const NAV_H = 52;
260const LARGE_H = 52;
261const TABS_H = 46;
262const ME_SIZE = 36;
263const AVATAR = 44;
264const PILL_MIN = 40;
265const SWIPE_AT = 88; // how far a row travels before its action arms
266const GLYPH = 56; // width of a swipe action's icon and label
267const FAB_H = 56;
268const FAB_W = 146;
269const SNACK_H = 52;
270const TAB_INSET = 18;
271const POP = { damping: 14, stiffness: 280, mass: 0.6 };
272const SLIDE = { damping: 22, stiffness: 240, mass: 0.8 };
273const SHEET = { damping: 24, stiffness: 230, mass: 0.9 };
274// The tab indicator's two edges: the leading one darts ahead, the trailing one catches up.
275const LEAD = { damping: 20, stiffness: 340, mass: 0.6 };
276const TRAIL = { damping: 22, stiffness: 150, mass: 0.8 };
277const NO_OUTLINE = Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null;
278const NO_SELECT = Platform.OS === 'web' ? ({ userSelect: 'none' } as object) : null; // a mouse swipe should not select text
279
280function usePalette() {
281 const dark = useColorScheme() === 'dark';
282 return {
283 dark,
284 bg: dark ? '#0A0A0B' : '#FFFFFF',
285 surface: dark ? '#1A1B1E' : '#F1F3F5',
286 fg: dark ? '#F4F5F7' : '#0B0D12',
287 soft: dark ? '#C4C8CF' : '#3B414B',
288 muted: dark ? '#8D939C' : '#646B76',
289 faint: dark ? '#50555D' : '#A3A9B2',
290 line: dark ? '#1F2125' : '#ECEEF1',
291 press: dark ? '#131417' : '#F6F7F9',
292 chip: dark ? '#1F2024' : '#F1F3F5',
293 skeleton: dark ? '#17181B' : '#ECEEF1',
294 shine: dark ? '#27292D' : '#DEE1E5',
295 // Accent as text or a glyph; filled shapes use ACCENT itself under ON_ACCENT.
296 accent: dark ? ACCENT_DARK : ACCENT,
297 accentSoft: dark ? tint(ACCENT_DARK, 0.16) : tint(ACCENT, 0.1),
298 // Opaque accent washes, so a selected row still hides the swipe actions behind it.
299 selected: dark ? shade(ACCENT, 0.76) : shade(ACCENT, -0.9),
300 selBar: dark ? shade(ACCENT, 0.66) : shade(ACCENT, -0.84),
301 flash: dark ? tint(ACCENT_DARK, 0.24) : tint(ACCENT, 0.16),
302 summaryTop: dark ? shade(ACCENT, 0.7) : shade(ACCENT, -0.88),
303 summaryBottom: dark ? shade(ACCENT, 0.84) : shade(ACCENT, -0.96),
304 summaryEdge: dark ? tint(ACCENT_DARK, 0.2) : tint(ACCENT, 0.18),
305 statPress: dark ? tint(ACCENT_DARK, 0.12) : tint(ACCENT, 0.08),
306 swipeIdle: dark ? '#1C1D21' : '#E9ECEF',
307 swipeGlyph: dark ? '#8D939C' : '#5F6672',
308 sheet: dark ? '#141518' : '#FFFFFF',
309 scrim: dark ? 'rgba(0, 0, 0, 0.62)' : 'rgba(10, 14, 20, 0.36)',
310 snackBg: dark ? '#E9ECEF' : '#1D2128',
311 snackFg: dark ? '#0B0D12' : '#F4F5F7',
312 snackAction: dark ? ACCENT : ACCENT_DARK,
313 snackTrack: dark ? 'rgba(0, 0, 0, 0.10)' : 'rgba(255, 255, 255, 0.12)',
314 danger: dark ? '#FF6B6B' : '#E5484D',
315 success: dark ? '#22C55E' : '#16A34A',
316 // Label chips: the label colour lifted on dark, deepened on light.
317 labelInk: (hex: string) => (dark ? shade(hex, -0.38) : shade(hex, 0.12)),
318 labelFill: (hex: string) => tint(hex, dark ? 0.2 : 0.12),
319 };
320}
321type Palette = ReturnType<typeof usePalette>;
322
323// ─── Small pieces ───────────────────────────────────────────────────────────
324
325function Tap({ children, label, onPress, to = 0.88 }: { children: ReactNode; label: string; onPress?: () => void; to?: number }) {
326 const scale = useSharedValue(1);
327 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
328 return (
329 <Pressable
330 role="button"
331 aria-label={label}
332 onPress={onPress}
333 hitSlop={6}
334 onPressIn={() => (scale.value = withSpring(to, POP))}
335 onPressOut={() => (scale.value = withSpring(1, POP))}
336 >
337 <Animated.View style={style}>{children}</Animated.View>
338 </Pressable>
339 );
340}
341
342/** A round photo that pulses as a tinted placeholder, then fades in once loaded. */
343function Photo({ uri, size, alt = '', c }: { uri: string; size: number; alt?: string; c: Palette }) {
344 const shown = useSharedValue(0);
345 const pulse = useSharedValue(0.4);
346 useEffect(() => {
347 pulse.value = withRepeat(withSequence(withTiming(1, { duration: 700 }), withTiming(0.4, { duration: 700 })), -1);
348 return () => cancelAnimation(pulse);
349 }, [pulse]);
350 const image = useAnimatedStyle(() => ({ opacity: shown.value }));
351 const placeholder = useAnimatedStyle(() => ({ opacity: (1 - shown.value) * pulse.value }));
352 return (
353 <View style={[styles.photo, { width: size, height: size, borderRadius: size / 2, backgroundColor: c.skeleton }]}>
354 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: c.shine }, placeholder]} />
355 <Animated.View style={[styles.fill, image]}>
356 <Image
357 source={{ uri }}
358 alt={alt}
359 resizeMode="cover"
360 style={styles.photoImage}
361 onLoad={() => {
362 cancelAnimation(pulse);
363 shown.value = withTiming(1, { duration: 320 });
364 }}
365 />
366 </Animated.View>
367 </View>
368 );
369}
370
371/** People are round (a photo or initials); companies get a drawn square mark. */
372function SenderMark({ avatar, name, size, c }: { avatar: Avatar; name: string; size: number; c: Palette }) {
373 if ('photo' in avatar) return <Photo uri={avatar.photo} size={size} alt={name} c={c} />;
374 if ('icon' in avatar) {
375 const Icon = avatar.icon;
376 return (
377 <LinearGradient colors={avatar.colors} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={[styles.mark, { width: size, height: size, borderRadius: size * 0.3 }]}>
378 <View style={[styles.markShine, { borderRadius: size * 0.3 }]} />
379 <Icon size={size * 0.46} color="#FFFFFF" strokeWidth={2.2} />
380 </LinearGradient>
381 );
382 }
383 return (
384 <LinearGradient colors={avatar.colors} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={[styles.mark, { width: size, height: size, borderRadius: size / 2 }]}>
385 <Text style={[styles.initialsText, { fontSize: size * 0.36 }]}>{avatar.initials}</Text>
386 </LinearGradient>
387 );
388}
389
390function Spinner({ color }: { color: string }) {
391 const r = useSharedValue(0);
392 useEffect(() => {
393 r.value = withRepeat(withTiming(360, { duration: 750, easing: Easing.linear }), -1);
394 return () => cancelAnimation(r);
395 }, [r]);
396 const style = useAnimatedStyle(() => ({ transform: [{ rotate: `${r.value}deg` }] }));
397 return <Animated.View style={[styles.spinner, { borderColor: tint(color, 0.25), borderTopColor: color }, style]} />;
398}
399
400// ─── Row parts ──────────────────────────────────────────────────────────────
401
402/** The avatar flips over to a check when the row is selected. */
403function FlipAvatar({ avatar, name, selected, onPress, c }: { avatar: Avatar; name: string; selected: boolean; onPress: () => void; c: Palette }) {
404 const flip = useSharedValue(selected ? 1 : 0);
405 const press = useSharedValue(1);
406 useEffect(() => {
407 flip.value = withTiming(selected ? 1 : 0, { duration: 340, easing: Easing.inOut(Easing.cubic) });
408 }, [selected, flip]);
409 const front = useAnimatedStyle(() => ({
410 opacity: flip.value < 0.5 ? 1 : 0,
411 transform: [{ perspective: 500 }, { rotateY: `${flip.value * 180}deg` }],
412 }));
413 const back = useAnimatedStyle(() => ({
414 opacity: flip.value >= 0.5 ? 1 : 0,
415 transform: [{ perspective: 500 }, { rotateY: `${(flip.value - 1) * 180}deg` }],
416 }));
417 const scale = useAnimatedStyle(() => ({ transform: [{ scale: press.value }] }));
418 return (
419 <Pressable
420 role="checkbox"
421 aria-checked={selected}
422 aria-label={`Select conversation from ${name}`}
423 onPress={onPress}
424 hitSlop={6}
425 onPressIn={() => (press.value = withSpring(0.88, POP))}
426 onPressOut={() => (press.value = withSpring(1, POP))}
427 >
428 <Animated.View style={[styles.avatarBox, scale]}>
429 <Animated.View style={[StyleSheet.absoluteFill, front]}>
430 <SenderMark avatar={avatar} name={name} size={AVATAR} c={c} />
431 </Animated.View>
432 <Animated.View style={[styles.avatarBack, back]}>
433 <Check size={22} color={ON_ACCENT} strokeWidth={3} />
434 </Animated.View>
435 </Animated.View>
436 </Pressable>
437 );
438}
439
440const STAR_SPARKS = Array.from({ length: 6 }, (_, i) => {
441 const a = (i / 6) * Math.PI * 2 - Math.PI / 2;
442 return { x: Math.cos(a), y: Math.sin(a) };
443});
444
445function StarSpark({ dir, t }: { dir: { x: number; y: number }; t: SharedValue<number> }) {
446 const style = useAnimatedStyle(() => ({
447 opacity: interpolate(t.value, [0, 0.15, 1], [0, 1, 0]),
448 transform: [{ translateX: dir.x * (6 + t.value * 12) }, { translateY: dir.y * (6 + t.value * 12) }, { scale: 1 - t.value * 0.6 }],
449 }));
450 return <Animated.View style={[styles.starSpark, style]} />;
451}
452
453/** The star pops, turns and throws a few sparks when it switches on. */
454function StarButton({ on, name, onPress, c }: { on: boolean; name: string; onPress: () => void; c: Palette }) {
455 const pop = useSharedValue(1);
456 const burst = useSharedValue(0);
457 const booted = useRef(false);
458 useEffect(() => {
459 if (!booted.current) {
460 booted.current = true;
461 return;
462 }
463 pop.value = withSequence(withTiming(on ? 1.45 : 0.72, { duration: 130, easing: Easing.out(Easing.quad) }), withSpring(1, POP));
464 if (on) {
465 burst.value = 0;
466 burst.value = withTiming(1, { duration: 560, easing: Easing.out(Easing.cubic) });
467 }
468 }, [on, pop, burst]);
469 const icon = useAnimatedStyle(() => ({ transform: [{ scale: pop.value }, { rotate: `${(pop.value - 1) * 50}deg` }] }));
470 return (
471 <Pressable role="button" aria-label={on ? `Unstar conversation from ${name}` : `Star conversation from ${name}`} hitSlop={8} onPress={onPress} style={styles.star}>
472 {STAR_SPARKS.map((d, i) => (
473 <StarSpark key={i} dir={d} t={burst} />
474 ))}
475 <Animated.View style={icon}>
476 <Star size={19} color={on ? STAR : c.faint} fill={on ? STAR : 'transparent'} strokeWidth={on ? 2 : 1.9} />
477 </Animated.View>
478 </Pressable>
479 );
480}
481
482function FileChip({ file, c }: { file: NonNullable<Thread['file']>; c: Palette }) {
483 const pdf = file.kind === 'pdf';
484 return (
485 <View style={[styles.fileChip, { borderColor: c.line }]}>
486 {pdf ? <FileText size={14} color="#E03131" strokeWidth={2.2} /> : <ImageIcon size={14} color="#2F9E44" strokeWidth={2.2} />}
487 <Text numberOfLines={1} style={[styles.fileName, { color: c.soft }]}>
488 {file.name}
489 </Text>
490 </View>
491 );
492}
493
494function LabelChip({ name, c }: { name: LabelName; c: Palette }) {
495 return (
496 <View style={[styles.label, { backgroundColor: c.labelFill(LABELS[name]) }]}>
497 <Text style={[styles.labelText, { color: c.labelInk(LABELS[name]) }]}>{name}</Text>
498 </View>
499 );
500}
501
502const STEPS = 4;
503
504function TrackLine({ step, text, c }: { step: number; text: string; c: Palette }) {
505 return (
506 <View style={styles.track}>
507 <Truck size={14} color={c.accent} strokeWidth={2.3} />
508 <Text style={[styles.trackText, { color: c.fg }]}>{text}</Text>
509 <View style={styles.trackBar}>
510 {Array.from({ length: STEPS }, (_, i) => (
511 <View key={i} style={[styles.trackSeg, { backgroundColor: i <= step ? c.accent : c.chip }]} />
512 ))}
513 </View>
514 </View>
515 );
516}
517
518/** A swipe action behind the row: grey while dragging, its colour once the row passes the threshold. */
519function SwipeGlyph({ icon: Icon, label, color }: { icon: LucideIcon; label: string; color: string }) {
520 return (
521 <View style={styles.swipeGlyph}>
522 <Icon size={22} color={color} strokeWidth={2.2} />
523 <Text style={[styles.swipeLabel, { color }]}>{label}</Text>
524 </View>
525 );
526}
527
528/** Animates a row's height: collapses it when it leaves, grows it back when it returns. */
529type Entering = ComponentProps<typeof Animated.View>['entering'];
530
531function Collapse({ leaving, fresh, enter, children }: { leaving: boolean; fresh: boolean; enter?: Entering; children: ReactNode }) {
532 const h = useSharedValue(fresh ? 0 : -1); // -1: natural height
533 const full = useSharedValue(0);
534 const grow = useRef(fresh);
535 useEffect(() => {
536 if (full.value <= 0) return;
537 if (leaving) {
538 h.value = h.value < 0 ? full.value : h.value;
539 h.value = withTiming(0, { duration: 260, easing: Easing.inOut(Easing.cubic) });
540 } else if (h.value >= 0) {
541 // Undone mid-collapse: grow back.
542 h.value = withTiming(full.value, { duration: 240, easing: Easing.out(Easing.cubic) }, (done) => {
543 'worklet';
544 if (done) h.value = -1;
545 });
546 }
547 }, [leaving, h, full]);
548 const style = useAnimatedStyle(() =>
549 h.value < 0 ? { height: 'auto' as const, opacity: 1 } : { height: h.value, opacity: full.value > 0 ? Math.min(1, (h.value / full.value) * 1.5) : 1 }
550 );
551 const measure = (e: LayoutChangeEvent) => {
552 const H = e.nativeEvent.layout.height;
553 if (H <= 0) return;
554 full.value = H;
555 if (grow.current) {
556 grow.current = false;
557 h.value = withTiming(H, { duration: 300, easing: Easing.out(Easing.cubic) }, (done) => {
558 'worklet';
559 if (done) h.value = -1;
560 });
561 }
562 };
563 return (
564 <Animated.View style={[styles.collapse, style]}>
565 <Animated.View entering={enter} onLayout={measure}>
566 {children}
567 </Animated.View>
568 </Animated.View>
569 );
570}
571
572// ─── Thread row: swipe right to toggle read, left to archive ────────────────
573
574type RowProps = {
575 thread: Thread;
576 selected: boolean;
577 selecting: boolean;
578 flashToken: number;
579 divider: boolean;
580 width: number;
581 c: Palette;
582 onOpen: (id: string) => void;
583 onSelect: (id: string) => void;
584 onStar: (id: string) => void;
585 onToggleRead: (id: string) => void;
586 onArchive: (id: string) => void;
587};
588
589function ThreadRow(props: RowProps) {
590 const { thread: t, selected, selecting, flashToken, divider, c } = props;
591 const x = useSharedValue(0);
592 const armed = useSharedValue(0);
593 const flash = useSharedValue(0);
594 const dot = useSharedValue(t.unread ? 1 : 0);
595 const side = useRef(0);
596 const swipedAt = useRef(0);
597 const live = useRef(props);
598 live.current = props;
599
600 useEffect(() => {
601 dot.value = withSpring(t.unread ? 1 : 0, POP);
602 }, [t.unread, dot]);
603 useEffect(() => {
604 if (!flashToken) return;
605 flash.value = withSequence(
606 withTiming(1, { duration: 160 }),
607 withTiming(0.2, { duration: 300 }),
608 withTiming(1, { duration: 160 }),
609 withTiming(0, { duration: 700, easing: Easing.out(Easing.quad) })
610 );
611 }, [flashToken, flash]);
612
613 const pan = useMemo(
614 () =>
615 PanResponder.create({
616 onMoveShouldSetPanResponder: (_e, g) => !live.current.selecting && Math.abs(g.dx) > 10 && Math.abs(g.dx) > Math.abs(g.dy) * 1.6,
617 onPanResponderGrant: () => {
618 swipedAt.current = Date.now();
619 },
620 onPanResponderMove: (_e, g) => {
621 const w = live.current.width;
622 const d = Math.max(-w, Math.min(w * 0.9, g.dx));
623 x.value = d;
624 const s = d >= SWIPE_AT ? 1 : d <= -SWIPE_AT ? -1 : 0;
625 if (s !== side.current) {
626 side.current = s;
627 armed.value = withSpring(s === 0 ? 0 : 1, POP);
628 }
629 },
630 onPanResponderRelease: (_e, g) => {
631 const { width: w, thread, onArchive, onToggleRead } = live.current;
632 const s = side.current;
633 side.current = 0;
634 swipedAt.current = Date.now();
635 if (s === -1 || (g.vx < -1.2 && g.dx < -40)) {
636 armed.value = withSpring(1, POP);
637 x.value = withTiming(-w - 24, { duration: 200, easing: Easing.in(Easing.quad) });
638 setTimeout(() => onArchive(thread.id), 190);
639 return;
640 }
641 if (s === 1) onToggleRead(thread.id);
642 x.value = withSpring(0, SLIDE);
643 armed.value = withDelay(s === 1 ? 140 : 0, withTiming(0, { duration: 220 }));
644 },
645 onPanResponderTerminate: () => {
646 side.current = 0;
647 x.value = withSpring(0, SLIDE);
648 armed.value = withTiming(0, { duration: 180 });
649 },
650 // On the web a mouse drag would otherwise hand the gesture back mid-swipe.
651 onPanResponderTerminationRequest: () => false,
652 }),
653 [x, armed]
654 );
655 // On the web a click still lands after a drag; ignore it so a swipe never also opens or selects.
656 const guard = (fn: () => void) => () => {
657 if (Date.now() - swipedAt.current < 350) return;
658 fn();
659 };
660
661 const slide = useAnimatedStyle(() => ({ transform: [{ translateX: x.value }] }));
662 const readSide = useAnimatedStyle(() => ({ opacity: x.value > 0.5 ? 1 : 0 }));
663 const archiveSide = useAnimatedStyle(() => ({ opacity: x.value < -0.5 ? 1 : 0 }));
664 const lit = useAnimatedStyle(() => ({ opacity: armed.value }));
665 const unlit = useAnimatedStyle(() => ({ opacity: 1 - Math.min(1, armed.value) }));
666 // The glyph stays centred in the strip the row uncovers and grows toward the threshold, pops as it passes, then
667 // rides along with the row's edge.
668 const readGlyph = useAnimatedStyle(() => {
669 const d = Math.max(0, x.value);
670 const p = Math.min(1, d / SWIPE_AT);
671 const centre = d < SWIPE_AT ? d / 2 : d - SWIPE_AT / 2;
672 return { opacity: 0.35 + p * 0.65, transform: [{ translateX: centre - GLYPH / 2 }, { scale: 0.6 + p * 0.4 + armed.value * 0.18 }] };
673 });
674 const archiveGlyph = useAnimatedStyle(() => {
675 const d = Math.max(0, -x.value);
676 const p = Math.min(1, d / SWIPE_AT);
677 const centre = d < SWIPE_AT ? d / 2 : d - SWIPE_AT / 2;
678 return { opacity: 0.35 + p * 0.65, transform: [{ translateX: GLYPH / 2 - centre }, { scale: 0.6 + p * 0.4 + armed.value * 0.18 }] };
679 });
680 const flashStyle = useAnimatedStyle(() => ({ opacity: flash.value }));
681 const dotStyle = useAnimatedStyle(() => ({ opacity: Math.min(1, dot.value), transform: [{ scale: dot.value }] }));
682
683 const ReadIcon = t.unread ? MailOpen : Mail;
684 const readLabel = t.unread ? 'Read' : 'Unread';
685 const label = `${t.unread ? 'Unread. ' : ''}${t.from}: ${t.subject}. ${t.time}${t.starred ? '. Starred' : ''}`;
686
687 return (
688 <View style={NO_SELECT}>
689 {/* Swipe right: mark read or unread */}
690 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: c.swipeIdle }, readSide]}>
691 <Animated.View style={[StyleSheet.absoluteFill, styles.swipeRead, lit]} />
692 <View style={styles.swipeStart}>
693 <Animated.View style={readGlyph}>
694 <Animated.View style={unlit}>
695 <SwipeGlyph icon={ReadIcon} label={readLabel} color={c.swipeGlyph} />
696 </Animated.View>
697 <Animated.View style={[StyleSheet.absoluteFill, lit]}>
698 <SwipeGlyph icon={ReadIcon} label={readLabel} color={ON_ACCENT} />
699 </Animated.View>
700 </Animated.View>
701 </View>
702 </Animated.View>
703 {/* Swipe left: archive */}
704 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: c.swipeIdle }, archiveSide]}>
705 <Animated.View style={[StyleSheet.absoluteFill, styles.swipeArchive, lit]} />
706 <View style={styles.swipeEnd}>
707 <Animated.View style={archiveGlyph}>
708 <Animated.View style={unlit}>
709 <SwipeGlyph icon={Archive} label="Archive" color={c.swipeGlyph} />
710 </Animated.View>
711 <Animated.View style={[StyleSheet.absoluteFill, lit]}>
712 <SwipeGlyph icon={Archive} label="Archive" color="#FFFFFF" />
713 </Animated.View>
714 </Animated.View>
715 </View>
716 </Animated.View>
717
718 <Animated.View {...pan.panHandlers} style={[styles.rowFront, { backgroundColor: c.bg }, slide]}>
719 {/* The row's own press target sits behind the content, so the avatar and star stay separate buttons. */}
720 <Pressable
721 role="button"
722 aria-label={label}
723 delayLongPress={380}
724 onPress={guard(() => (selecting ? props.onSelect(t.id) : props.onOpen(t.id)))}
725 onLongPress={() => !selecting && props.onSelect(t.id)}
726 style={({ pressed }) => [StyleSheet.absoluteFill, { backgroundColor: selected ? c.selected : pressed ? c.press : c.bg }]}
727 />
728 <Animated.View style={[StyleSheet.absoluteFill, styles.noTouch, { backgroundColor: c.flash }, flashStyle]} />
729 <View style={[styles.row, styles.passThrough]}>
730 <Animated.View style={[styles.unreadDot, styles.noTouch, { backgroundColor: c.accent }, dotStyle]} />
731 <FlipAvatar avatar={t.avatar} name={t.from} selected={selected} onPress={guard(() => props.onSelect(t.id))} c={c} />
732 <View style={[styles.rowBody, styles.passThrough]}>
733 <View style={[styles.rowTop, styles.noTouch]}>
734 <Text numberOfLines={1} style={[styles.sender, { color: c.fg, fontWeight: t.unread ? '700' : '500' }]}>
735 {t.from}
736 </Text>
737 {t.count && t.count > 1 ? (
738 <View style={[styles.countBubble, { backgroundColor: c.chip }]}>
739 <Text style={[styles.countText, { color: c.muted }]}>{t.count}</Text>
740 </View>
741 ) : null}
742 <View style={styles.fill} />
743 <Text style={[styles.time, { color: t.unread ? c.accent : c.muted, fontWeight: t.unread ? '700' : '500' }]}>{t.time}</Text>
744 </View>
745 <View style={[styles.rowMid, styles.passThrough]}>
746 <View style={[styles.rowText, styles.noTouch]}>
747 <View style={styles.subjectRow}>
748 {t.labels?.map((l) => (
749 <LabelChip key={l} name={l} c={c} />
750 ))}
751 <Text numberOfLines={1} style={[styles.subject, { color: t.unread ? c.fg : c.soft, fontWeight: t.unread ? '600' : '400' }]}>
752 {t.subject}
753 </Text>
754 </View>
755 <Text numberOfLines={1} style={[styles.snippet, { color: c.muted }]}>
756 {t.snippet}
757 </Text>
758 </View>
759 <StarButton on={t.starred} name={t.from} onPress={guard(() => props.onStar(t.id))} c={c} />
760 </View>
761 {t.track ? (
762 <View style={styles.noTouch}>
763 <TrackLine step={t.track.step} text={t.track.text} c={c} />
764 </View>
765 ) : null}
766 {t.file ? (
767 <View style={[styles.chips, styles.noTouch]}>
768 <FileChip file={t.file} c={c} />
769 </View>
770 ) : null}
771 </View>
772 </View>
773 {divider ? <View style={[styles.divider, { backgroundColor: c.line }]} /> : null}
774 </Animated.View>
775 </View>
776 );
777}
778
779// ─── Tabs: the indicator stretches toward the new tab, then settles ─────────
780
781function Tabs({ value, counts, onChange, c }: { value: Tab; counts: Record<Tab, number>; onChange: (t: Tab) => void; c: Palette }) {
782 const [w, setW] = useState(0);
783 const index = TABS.findIndex((t) => t.id === value);
784 const left = useSharedValue(0);
785 const right = useSharedValue(0);
786 const placed = useRef(false);
787 useEffect(() => {
788 if (!w) return;
789 const tw = (w - 8) / TABS.length; // the row has 4pt of padding each side
790 const L = index * tw + TAB_INSET;
791 const R = (index + 1) * tw - TAB_INSET;
792 if (!placed.current) {
793 placed.current = true;
794 left.value = L;
795 right.value = R;
796 return;
797 }
798 const forward = L > left.value;
799 left.value = withSpring(L, forward ? TRAIL : LEAD);
800 right.value = withSpring(R, forward ? LEAD : TRAIL);
801 }, [index, w, left, right]);
802 const bar = useAnimatedStyle(() => ({ width: Math.max(6, right.value - left.value), transform: [{ translateX: left.value }] }));
803 return (
804 <View role="tablist" onLayout={(e: LayoutChangeEvent) => setW(e.nativeEvent.layout.width)} style={[styles.tabs, { borderBottomColor: c.line }]}>
805 {TABS.map((t) => {
806 const on = t.id === value;
807 const n = counts[t.id];
808 return (
809 <Pressable key={t.id} role="tab" aria-selected={on} aria-label={`${t.title}, ${n} unread`} onPress={() => onChange(t.id)} style={styles.tab}>
810 <Text style={[styles.tabLabel, { color: on ? c.fg : c.muted, fontWeight: on ? '700' : '600' }]}>{t.title}</Text>
811 {n > 0 ? (
812 <Animated.View key={`${t.id}-${n}`} entering={ZoomIn.duration(220)} style={[styles.tabCount, { backgroundColor: on ? ACCENT : c.chip }]}>
813 <Text style={[styles.tabCountText, { color: on ? ON_ACCENT : c.muted }]}>{n}</Text>
814 </Animated.View>
815 ) : null}
816 </Pressable>
817 );
818 })}
819 {w > 0 ? <Animated.View style={[styles.tabBar, { backgroundColor: c.accent }, bar]} /> : null}
820 </View>
821 );
822}
823
824// ─── Summary card: live counts; each one jumps to the mail behind it ────────
825
826type Pick = 'replies' | 'bill' | 'packages';
827
828function SummaryStat({ icon: Icon, n, noun, rest, onPress, c }: { icon: LucideIcon; n: number; noun: string; rest: string; onPress: () => void; c: Palette }) {
829 const scale = useSharedValue(1);
830 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
831 return (
832 <Pressable
833 role="button"
834 aria-label={`${n} ${noun} ${rest}. Show them`}
835 onPress={onPress}
836 onPressIn={() => (scale.value = withSpring(0.94, POP))}
837 onPressOut={() => (scale.value = withSpring(1, POP))}
838 style={({ pressed }) => [styles.stat, pressed && { backgroundColor: c.statPress }]}
839 >
840 <Animated.View style={style}>
841 <View style={styles.statTop}>
842 <Animated.Text key={n} entering={FadeInDown.duration(260)} style={[styles.statNum, { color: c.fg }]}>
843 {n}
844 </Animated.Text>
845 <Text numberOfLines={1} style={[styles.statNoun, { color: c.fg }]}>
846 {noun}
847 </Text>
848 </View>
849 <View style={styles.statBottom}>
850 <Icon size={13} color={c.accent} strokeWidth={2.4} />
851 <Text numberOfLines={1} style={[styles.statRest, { color: c.muted }]}>
852 {rest}
853 </Text>
854 </View>
855 </Animated.View>
856 </Pressable>
857 );
858}
859
860function SummaryCard({ replies, bills, packages, onPick, c }: { replies: number; bills: number; packages: number; onPick: (p: Pick) => void; c: Palette }) {
861 const items: { id: Pick; icon: LucideIcon; n: number; noun: string; rest: string }[] = [
862 { id: 'replies', icon: Reply, n: replies, noun: replies === 1 ? 'reply' : 'replies', rest: 'waiting' },
863 { id: 'bill', icon: Receipt, n: bills, noun: bills === 1 ? 'bill' : 'bills', rest: 'due Friday' },
864 { id: 'packages', icon: Package, n: packages, noun: packages === 1 ? 'package' : 'packages', rest: 'arriving' },
865 ];
866 return (
867 <LinearGradient colors={[c.summaryTop, c.summaryBottom]} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={[styles.summary, { borderColor: c.summaryEdge }]}>
868 <View style={styles.summaryHead}>
869 <View style={styles.summaryBadge}>
870 <Inbox size={12} color={ON_ACCENT} strokeWidth={2.6} />
871 </View>
872 <Text style={[styles.summaryTitle, { color: c.fg }]}>Summary</Text>
873 <Text style={[styles.summaryMeta, { color: c.muted }]}>· Today, 9:41</Text>
874 <View style={styles.fill} />
875 <Pin size={13} color={c.muted} strokeWidth={2.2} />
876 <Text style={[styles.summaryMeta, { color: c.muted }]}>Pinned</Text>
877 </View>
878 <View style={styles.summaryRow}>
879 {items.map((it, i) => (
880 <Fragment key={it.id}>
881 {i > 0 ? <View style={[styles.summarySep, { backgroundColor: c.summaryEdge }]} /> : null}
882 <SummaryStat icon={it.icon} n={it.n} noun={it.noun} rest={it.rest} onPress={() => onPick(it.id)} c={c} />
883 </Fragment>
884 ))}
885 </View>
886 </LinearGradient>
887 );
888}
889
890// ─── Snackbar: undo, sending progress, confirmations ────────────────────────
891
892type Snack = { id: number; kind: 'archive' | 'delete' | 'read' | 'sending' | 'sent' | 'draft' | 'discard'; text: string; undo?: string[] };
893
894const SNACK_ICONS: Record<Exclude<Snack['kind'], 'sending' | 'sent'>, LucideIcon> = { archive: Archive, delete: Trash2, read: MailOpen, draft: Pencil, discard: Trash2 };
895const UNDO_MS = 4200;
896const SEND_MS = 1500;
897
898function Snackbar({ snack, onUndo, bottom, c }: { snack: Snack | null; onUndo: (ids: string[]) => void; bottom: number; c: Palette }) {
899 const [shown, setShown] = useState<Snack | null>(snack);
900 if (snack && snack !== shown) setShown(snack);
901 const t = useSharedValue(0);
902 const bar = useSharedValue(0);
903 useEffect(() => {
904 t.value = snack ? withSpring(1, SLIDE) : withTiming(0, { duration: 200, easing: Easing.in(Easing.quad) });
905 if (!snack) {
906 // Unmount once it has slid away.
907 const id = setTimeout(() => setShown(null), 240);
908 return () => clearTimeout(id);
909 }
910 if (snack.kind === 'sending') {
911 bar.value = 0;
912 bar.value = withTiming(1, { duration: SEND_MS, easing: Easing.inOut(Easing.quad) });
913 } else if (snack.undo) {
914 bar.value = 1;
915 bar.value = withTiming(0, { duration: UNDO_MS, easing: Easing.linear });
916 } else {
917 bar.value = 0;
918 }
919 }, [snack, t, bar]);
920 const style = useAnimatedStyle(() => ({ opacity: Math.min(1, t.value * 1.4), transform: [{ translateY: (1 - t.value) * 90 }] }));
921 const barStyle = useAnimatedStyle(() => ({ transform: [{ scaleX: bar.value }] }));
922 if (!shown) return null;
923 const Icon = shown.kind === 'sending' || shown.kind === 'sent' ? null : SNACK_ICONS[shown.kind];
924 return (
925 <Animated.View role="alert" style={[styles.snack, { bottom, backgroundColor: c.snackBg }, style]}>
926 <Animated.View key={shown.id} entering={FadeIn.duration(180)} style={styles.snackInner}>
927 {shown.kind === 'sending' ? (
928 <Spinner color={c.snackFg} />
929 ) : shown.kind === 'sent' ? (
930 <Animated.View entering={ZoomIn.duration(260)} style={[styles.snackCheck, { backgroundColor: c.success }]}>
931 <Check size={13} color="#FFFFFF" strokeWidth={3.4} />
932 </Animated.View>
933 ) : Icon ? (
934 <Icon size={18} color={c.snackFg} strokeWidth={2.2} />
935 ) : null}
936 <Text numberOfLines={1} style={[styles.snackText, { color: c.snackFg }]}>
937 {shown.text}
938 </Text>
939 {shown.undo ? (
940 <Pressable role="button" aria-label="Undo" hitSlop={6} onPress={() => shown.undo && onUndo(shown.undo)} style={styles.snackAction}>
941 <Text style={[styles.snackActionText, { color: c.snackAction }]}>Undo</Text>
942 </Pressable>
943 ) : null}
944 </Animated.View>
945 <Animated.View style={[styles.snackBar, { backgroundColor: shown.kind === 'sending' ? c.snackAction : c.snackTrack }, barStyle]} />
946 </Animated.View>
947 );
948}
949
950// ─── Compose button: extended at the top, an icon while scrolling down ─────
951
952function ComposeFab({ open, hidden, lift, bottom, onPress }: { open: SharedValue<number>; hidden: boolean; lift: boolean; bottom: number; onPress: () => void }) {
953 const hide = useSharedValue(0);
954 const up = useSharedValue(0);
955 const press = useSharedValue(1);
956 useEffect(() => {
957 hide.value = withSpring(hidden ? 1 : 0, POP);
958 }, [hidden, hide]);
959 useEffect(() => {
960 up.value = withSpring(lift ? SNACK_H + 12 : 0, SLIDE);
961 }, [lift, up]);
962 const wrap = useAnimatedStyle(() => ({
963 opacity: 1 - Math.min(1, hide.value),
964 transform: [{ translateY: -up.value }, { scale: (1 - hide.value * 0.5) * press.value }],
965 }));
966 const body = useAnimatedStyle(() => ({ width: interpolate(open.value, [0, 1], [FAB_H, FAB_W]) }));
967 const label = useAnimatedStyle(() => ({
968 opacity: interpolate(open.value, [0.55, 1], [0, 1], 'clamp'),
969 transform: [{ translateX: interpolate(open.value, [0, 1], [-8, 0]) }],
970 }));
971 return (
972 <View style={[styles.fabSlot, { bottom }]}>
973 <Animated.View entering={FadeInDown.delay(520).duration(420)}>
974 <Animated.View style={wrap}>
975 <Pressable
976 role="button"
977 aria-label="Compose"
978 disabled={hidden}
979 onPress={onPress}
980 onPressIn={() => (press.value = withSpring(0.93, POP))}
981 onPressOut={() => (press.value = withSpring(1, POP))}
982 >
983 <Animated.View style={[styles.fab, body]}>
984 <View style={styles.fabIcon}>
985 <Pencil size={21} color={ON_ACCENT} strokeWidth={2.3} />
986 </View>
987 <Animated.Text numberOfLines={1} style={[styles.fabLabel, label]}>
988 Compose
989 </Animated.Text>
990 </Animated.View>
991 </Pressable>
992 </Animated.View>
993 </Animated.View>
994 </View>
995 );
996}
997
998// ─── Selection bar: replaces the top bar while rows are selected ────────────
999
1000function SelectionBar({
1001 count,
1002 anyUnread,
1003 progress,
1004 onClose,
1005 onArchive,
1006 onDelete,
1007 onRead,
1008 onAll,
1009 c,
1010}: {
1011 count: number;
1012 anyUnread: boolean;
1013 progress: SharedValue<number>;
1014 onClose: () => void;
1015 onArchive: () => void;
1016 onDelete: () => void;
1017 onRead: () => void;
1018 onAll: () => void;
1019 c: Palette;
1020}) {
1021 const style = useAnimatedStyle(() => ({
1022 opacity: progress.value,
1023 transform: [{ translateY: (1 - progress.value) * -14 }, { scale: 0.96 + progress.value * 0.04 }],
1024 }));
1025 return (
1026 <Animated.View role="toolbar" aria-label="Selection" style={[styles.selBar, { backgroundColor: c.selBar }, style]}>
1027 <Tap label="Clear selection" onPress={onClose}>
1028 <View style={styles.selButton}>
1029 <X size={20} color={c.fg} strokeWidth={2.3} />
1030 </View>
1031 </Tap>
1032 <View style={styles.selCount}>
1033 <Animated.Text key={count} entering={FadeInUp.duration(200)} style={[styles.selNum, { color: c.fg }]}>
1034 {count}
1035 </Animated.Text>
1036 <Text style={[styles.selWord, { color: c.fg }]}>selected</Text>
1037 </View>
1038 <View style={styles.fill} />
1039 <Tap label="Archive selected" onPress={onArchive}>
1040 <View style={styles.selButton}>
1041 <Archive size={20} color={c.fg} strokeWidth={2.1} />
1042 </View>
1043 </Tap>
1044 <Tap label={anyUnread ? 'Mark selected as read' : 'Mark selected as unread'} onPress={onRead}>
1045 <View style={styles.selButton}>{anyUnread ? <MailOpen size={20} color={c.fg} strokeWidth={2.1} /> : <Mail size={20} color={c.fg} strokeWidth={2.1} />}</View>
1046 </Tap>
1047 <Tap label="Delete selected" onPress={onDelete}>
1048 <View style={styles.selButton}>
1049 <Trash2 size={20} color={c.danger} strokeWidth={2.1} />
1050 </View>
1051 </Tap>
1052 <Tap label="Select all" onPress={onAll}>
1053 <View style={styles.selButton}>
1054 <CheckCheck size={20} color={c.fg} strokeWidth={2.1} />
1055 </View>
1056 </Tap>
1057 </Animated.View>
1058 );
1059}
1060
1061// ─── Compose sheet ──────────────────────────────────────────────────────────
1062
1063type Draft = { to: string; subject: string; body: string };
1064const EMPTY_DRAFT: Draft = { to: '', subject: '', body: '' };
1065const isEmail = (s: string) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s.trim());
1066const hasContent = (d: Draft) => !!(d.to.trim() || d.subject.trim() || d.body.trim());
1067
1068function ComposeSheet({
1069 open,
1070 draft,
1071 onChange,
1072 onClose,
1073 onDiscard,
1074 onSend,
1075 c,
1076}: {
1077 open: boolean;
1078 draft: Draft;
1079 onChange: (d: Draft) => void;
1080 onClose: () => void;
1081 onDiscard: () => void;
1082 onSend: () => void;
1083 c: Palette;
1084}) {
1085 const insets = useSafeAreaInsets();
1086 const { height } = useWindowDimensions();
1087 const [mounted, setMounted] = useState(open);
1088 const [error, setError] = useState(false);
1089 if (open && !mounted) setMounted(true);
1090 const t = useSharedValue(0);
1091 const drag = useSharedValue(0);
1092 const shake = useSharedValue(0);
1093 const subjectRef = useRef<ComponentRef<typeof TextInput>>(null);
1094 const close = useRef(onClose);
1095 close.current = onClose;
1096 const sheetH = Math.min(640, height - insets.top - 28);
1097
1098 useEffect(() => {
1099 if (open) {
1100 drag.value = 0;
1101 t.value = withSpring(1, SHEET);
1102 setError(false);
1103 return;
1104 }
1105 t.value = withTiming(0, { duration: 240, easing: Easing.in(Easing.cubic) });
1106 const id = setTimeout(() => setMounted(false), 260);
1107 return () => clearTimeout(id);
1108 }, [open, t, drag]);
1109
1110 // Drag the sheet's head down to put it away.
1111 const pan = useMemo(
1112 () =>
1113 PanResponder.create({
1114 onMoveShouldSetPanResponder: (_e, g) => g.dy > 6 && Math.abs(g.dy) > Math.abs(g.dx),
1115 onPanResponderMove: (_e, g) => {
1116 drag.value = Math.max(0, g.dy);
1117 },
1118 onPanResponderRelease: (_e, g) => {
1119 if (g.dy > 120 || g.vy > 0.9) close.current();
1120 else drag.value = withSpring(0, SLIDE);
1121 },
1122 onPanResponderTerminate: () => {
1123 drag.value = withSpring(0, SLIDE);
1124 },
1125 onPanResponderTerminationRequest: () => false,
1126 }),
1127 [drag]
1128 );
1129
1130 const sheetStyle = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - t.value) * (sheetH + 60) + drag.value }] }));
1131 const scrimStyle = useAnimatedStyle(() => ({ opacity: Math.min(1, t.value) * (1 - Math.min(1, drag.value / 500)) }));
1132 const shakeStyle = useAnimatedStyle(() => ({ transform: [{ translateX: shake.value }] }));
1133
1134 if (!mounted) return null;
1135
1136 const canSend = draft.to.trim().length > 0;
1137 const send = () => {
1138 if (!isEmail(draft.to)) {
1139 setError(true);
1140 shake.value = withSequence(
1141 withTiming(-8, { duration: 50 }),
1142 withTiming(8, { duration: 60 }),
1143 withTiming(-5, { duration: 60 }),
1144 withTiming(5, { duration: 60 }),
1145 withTiming(0, { duration: 50 })
1146 );
1147 return;
1148 }
1149 onSend();
1150 };
1151 const typed = draft.to.trim().toLowerCase();
1152 const suggestions = CONTACTS.filter((p) => p.email !== typed && (!typed || p.name.toLowerCase().includes(typed) || p.email.includes(typed)));
1153
1154 return (
1155 <View style={[StyleSheet.absoluteFill, styles.sheetLayer, { pointerEvents: open ? 'auto' : 'none' }]}>
1156 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: c.scrim }, scrimStyle]}>
1157 <Pressable aria-label="Close compose" onPress={onClose} style={styles.fill} />
1158 </Animated.View>
1159 <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={[styles.sheetAvoid, styles.passThrough]}>
1160 <Animated.View role="dialog" aria-modal aria-label="New message" style={[styles.sheet, { height: sheetH, paddingBottom: insets.bottom + 8, backgroundColor: c.sheet }, sheetStyle]}>
1161 <View {...pan.panHandlers} style={styles.sheetHead}>
1162 <View style={[styles.grabber, { backgroundColor: c.faint }]} />
1163 <View style={styles.sheetTitleRow}>
1164 <Tap label="Close and keep draft" onPress={onClose}>
1165 <View style={[styles.round, { backgroundColor: c.surface }]}>
1166 <X size={18} color={c.fg} strokeWidth={2.4} />
1167 </View>
1168 </Tap>
1169 <Text style={[styles.sheetTitle, { color: c.fg }]}>New message</Text>
1170 <Tap label="Send" onPress={send} to={0.94}>
1171 <View style={[styles.sendPill, { opacity: canSend ? 1 : 0.45 }]}>
1172 <SendHorizontal size={16} color={ON_ACCENT} strokeWidth={2.4} />
1173 <Text style={styles.sendText}>Send</Text>
1174 </View>
1175 </Tap>
1176 </View>
1177 </View>
1178
1179 <View style={[styles.field, { borderBottomColor: c.line }]}>
1180 <Text style={[styles.fieldLabel, { color: c.muted }]}>From</Text>
1181 <Text numberOfLines={1} style={[styles.fromText, { color: c.fg }]}>
1182 {ME.name} <Text style={{ color: c.muted }}>{ME.email}</Text>
1183 </Text>
1184 </View>
1185 <Animated.View style={[styles.field, { borderBottomColor: error ? c.danger : c.line }, shakeStyle]}>
1186 <Text style={[styles.fieldLabel, { color: error ? c.danger : c.muted }]}>To</Text>
1187 <TextInput
1188 value={draft.to}
1189 onChangeText={(to) => {
1190 onChange({ ...draft, to });
1191 if (error) setError(false);
1192 }}
1193 placeholder="Name or email"
1194 placeholderTextColor={c.faint}
1195 autoCapitalize="none"
1196 autoCorrect={false}
1197 keyboardType="email-address"
1198 returnKeyType="next"
1199 onSubmitEditing={() => subjectRef.current?.focus()}
1200 selectionColor={ACCENT}
1201 aria-label="To"
1202 style={[styles.fieldInput, { color: c.fg }, NO_OUTLINE]}
1203 />
1204 </Animated.View>
1205 {error ? (
1206 <Animated.Text key="err" entering={FadeInDown.duration(200)} role="alert" style={[styles.fieldError, { color: c.danger }]}>
1207 Enter a valid email address
1208 </Animated.Text>
1209 ) : suggestions.length > 0 ? (
1210 <Animated.View key="sug" entering={FadeIn.duration(200)} style={styles.suggest}>
1211 {suggestions.map((p) => (
1212 <Pressable
1213 key={p.email}
1214 role="button"
1215 aria-label={`Send to ${p.name}`}
1216 onPress={() => {
1217 onChange({ ...draft, to: p.email });
1218 subjectRef.current?.focus();
1219 }}
1220 style={({ pressed }) => [styles.suggestChip, { backgroundColor: pressed ? c.line : c.surface }]}
1221 >
1222 <Photo uri={p.photo} size={24} c={c} />
1223 <Text style={[styles.suggestName, { color: c.fg }]}>{p.name.split(' ')[0]}</Text>
1224 </Pressable>
1225 ))}
1226 </Animated.View>
1227 ) : null}
1228 <View style={[styles.field, { borderBottomColor: c.line }]}>
1229 <Text style={[styles.fieldLabel, { color: c.muted }]}>Subject</Text>
1230 <TextInput
1231 ref={subjectRef}
1232 value={draft.subject}
1233 onChangeText={(subject) => onChange({ ...draft, subject })}
1234 placeholder="What is it about?"
1235 placeholderTextColor={c.faint}
1236 selectionColor={ACCENT}
1237 aria-label="Subject"
1238 style={[styles.fieldInput, { color: c.fg }, NO_OUTLINE]}
1239 />
1240 </View>
1241 <TextInput
1242 value={draft.body}
1243 onChangeText={(body) => onChange({ ...draft, body })}
1244 placeholder="Write your message"
1245 placeholderTextColor={c.faint}
1246 multiline
1247 textAlignVertical="top"
1248 selectionColor={ACCENT}
1249 aria-label="Message"
1250 style={[styles.body, { color: c.fg }, NO_OUTLINE]}
1251 />
1252 <View style={[styles.tools, { borderTopColor: c.line }]}>
1253 <Tap label="Attach a file">
1254 <View style={styles.tool}>
1255 <Paperclip size={20} color={c.muted} strokeWidth={2.1} />
1256 </View>
1257 </Tap>
1258 <Tap label="Insert a photo">
1259 <View style={styles.tool}>
1260 <ImageIcon size={20} color={c.muted} strokeWidth={2.1} />
1261 </View>
1262 </Tap>
1263 <Tap label="Formatting">
1264 <View style={styles.tool}>
1265 <Type size={20} color={c.muted} strokeWidth={2.1} />
1266 </View>
1267 </Tap>
1268 <View style={styles.fill} />
1269 <Tap label="Discard draft" onPress={onDiscard} to={0.94}>
1270 <View style={[styles.discard, { backgroundColor: tint(c.danger, 0.1) }]}>
1271 <Trash2 size={16} color={c.danger} strokeWidth={2.2} />
1272 <Text style={[styles.discardText, { color: c.danger }]}>Discard</Text>
1273 </View>
1274 </Tap>
1275 </View>
1276 </Animated.View>
1277 </KeyboardAvoidingView>
1278 </View>
1279 );
1280}
1281
1282// ─── Screen ─────────────────────────────────────────────────────────────────
1283
1284export default function MailInboxScreen() {
1285 const c = usePalette();
1286 const insets = useSafeAreaInsets();
1287 const { width, height } = useWindowDimensions();
1288 // Replace with your mail query; `gone` stands in for the archive and trash folders.
1289 const [threads, setThreads] = useState<Thread[]>(THREADS);
1290 const [tab, setTab] = useState<Tab>('primary');
1291 const [dir, setDir] = useState(1);
1292 const [query, setQuery] = useState('');
1293 const [searchFocused, setSearchFocused] = useState(false);
1294 const [selected, setSelected] = useState<string[]>([]);
1295 const [leaving, setLeaving] = useState<string[]>([]);
1296 const [fresh, setFresh] = useState<string[]>([]);
1297 const [flash, setFlash] = useState<{ ids: string[]; token: number }>({ ids: [], token: 0 });
1298 const [snack, setSnack] = useState<Snack | null>(null);
1299 const [composing, setComposing] = useState(false);
1300 const [draft, setDraft] = useState<Draft>(EMPTY_DRAFT);
1301 // Rows stagger in once; after that a tab change slides the whole list.
1302 const [intro, setIntro] = useState(true);
1303 const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
1304 const leavingRef = useRef(new Set<string>());
1305 const lastCount = useRef(0);
1306 const listRef = useAnimatedRef<Animated.ScrollView>();
1307 const searchRef = useRef<ComponentRef<typeof TextInput>>(null);
1308
1309 const later = (fn: () => void, ms: number) => {
1310 timers.current.push(setTimeout(fn, ms));
1311 };
1312 useEffect(() => {
1313 const t = setTimeout(() => setIntro(false), 1300);
1314 return () => {
1315 clearTimeout(t);
1316 timers.current.forEach(clearTimeout);
1317 };
1318 }, []);
1319 useEffect(() => {
1320 if (!snack || snack.kind === 'sending') return;
1321 const t = setTimeout(() => setSnack(null), snack.undo ? UNDO_MS : 2600);
1322 return () => clearTimeout(t);
1323 }, [snack]);
1324 const showSnack = (s: Omit<Snack, 'id'>) => setSnack({ ...s, id: Date.now() });
1325
1326 const colW = Math.min(width, COLUMN);
1327 const live = threads.filter((t) => !t.gone);
1328 const counts: Record<Tab, number> = {
1329 primary: live.filter((t) => t.tab === 'primary' && t.unread).length,
1330 updates: live.filter((t) => t.tab === 'updates' && t.unread).length,
1331 promotions: live.filter((t) => t.tab === 'promotions' && t.unread).length,
1332 };
1333 const totalUnread = counts.primary + counts.updates + counts.promotions;
1334 const q = query.trim().toLowerCase();
1335 const inTab = live.filter((t) => t.tab === tab);
1336 const shown = q ? inTab.filter((t) => `${t.from} ${t.subject} ${t.snippet}`.toLowerCase().includes(q)) : inTab;
1337 const groups = DAYS.map((d) => ({ ...d, rows: shown.filter((t) => t.day === d.id) })).filter((g) => g.rows.length > 0);
1338 const selecting = selected.length > 0;
1339 if (selecting) lastCount.current = selected.length;
1340 const anyUnread = threads.some((t) => selected.includes(t.id) && t.unread);
1341
1342 // ─── Actions ───
1343 const update = (ids: string[], patch: (t: Thread) => Partial<Thread>) => setThreads((all) => all.map((t) => (ids.includes(t.id) ? { ...t, ...patch(t) } : t)));
1344 const open = (id: string) => update([id], () => ({ unread: false })); // push your thread screen here too
1345 const toggleRead = (id: string) => update([id], (t) => ({ unread: !t.unread }));
1346 const toggleStar = (id: string) => update([id], (t) => ({ starred: !t.starred }));
1347 const toggleSelect = (id: string) => setSelected((s) => (s.includes(id) ? s.filter((x) => x !== id) : [...s, id]));
1348
1349 const remove = (ids: string[], how: 'archived' | 'deleted') => {
1350 setSelected([]);
1351 ids.forEach((id) => leavingRef.current.add(id));
1352 setLeaving((l) => [...l, ...ids]);
1353 later(() => {
1354 const still = ids.filter((id) => leavingRef.current.has(id));
1355 still.forEach((id) => leavingRef.current.delete(id));
1356 update(still, () => ({ gone: how }));
1357 setLeaving((l) => l.filter((id) => !ids.includes(id)));
1358 }, 290);
1359 const one = ids.length === 1;
1360 showSnack({
1361 kind: how === 'archived' ? 'archive' : 'delete',
1362 text: one ? `Conversation ${how}` : `${ids.length} conversations ${how}`,
1363 undo: ids,
1364 });
1365 };
1366 const undo = (ids: string[]) => {
1367 ids.forEach((id) => leavingRef.current.delete(id));
1368 setLeaving((l) => l.filter((id) => !ids.includes(id)));
1369 update(ids, () => ({ gone: undefined }));
1370 setFresh(ids);
1371 later(() => setFresh([]), 800);
1372 setSnack(null);
1373 };
1374 const markSelected = () => {
1375 const n = selected.length;
1376 update(selected, () => ({ unread: !anyUnread }));
1377 setSelected([]);
1378 showSnack({ kind: 'read', text: `${n} marked as ${anyUnread ? 'read' : 'unread'}` });
1379 };
1380 const selectAll = () => {
1381 const ids = shown.map((t) => t.id);
1382 setSelected((s) => (ids.every((id) => s.includes(id)) ? [] : ids));
1383 };
1384
1385 const changeTab = (next: Tab) => {
1386 if (next === tab) return;
1387 setDir(TABS.findIndex((t) => t.id === next) > TABS.findIndex((t) => t.id === tab) ? 1 : -1);
1388 setTab(next);
1389 setSelected([]);
1390 listRef.current?.scrollTo({ y: Math.min(scrollY.value, LARGE_H), animated: false });
1391 };
1392 // A summary number jumps to its tab and makes the mail behind it blink.
1393 const pick = (p: Pick) => {
1394 const ids = live.filter((t) => (p === 'replies' ? t.needsReply : p === 'bill' ? t.kind === 'bill' : t.kind === 'package')).map((t) => t.id);
1395 const target: Tab = p === 'packages' ? 'updates' : 'primary';
1396 if (target !== tab) {
1397 changeTab(target);
1398 later(() => setFlash({ ids, token: Date.now() }), 320);
1399 } else {
1400 setFlash({ ids, token: Date.now() });
1401 }
1402 };
1403
1404 const openCompose = () => {
1405 setSelected([]);
1406 setComposing(true);
1407 };
1408 const closeCompose = () => {
1409 setComposing(false);
1410 if (hasContent(draft)) showSnack({ kind: 'draft', text: 'Saved to drafts' });
1411 };
1412 const discard = () => {
1413 const had = hasContent(draft);
1414 setComposing(false);
1415 setDraft(EMPTY_DRAFT);
1416 if (had) showSnack({ kind: 'discard', text: 'Draft discarded' });
1417 };
1418 // Replace the timer with your send call.
1419 const send = () => {
1420 const to = draft.to.trim();
1421 setComposing(false);
1422 setDraft(EMPTY_DRAFT);
1423 showSnack({ kind: 'sending', text: `Sending to ${to}` });
1424 later(() => showSnack({ kind: 'sent', text: 'Message sent' }), SEND_MS + 80);
1425 };
1426
1427 // ─── Scroll: the title folds into the bar, the search field shrinks to an icon, the compose button tucks in ───
1428 const scrollY = useSharedValue(0);
1429 const lastY = useSharedValue(0);
1430 const anchor = useSharedValue(0);
1431 const heading = useSharedValue(0);
1432 const fabOpen = useSharedValue(1);
1433 const fabWant = useSharedValue(1);
1434 const hold = useSharedValue(0);
1435 const sel = useSharedValue(0);
1436 useEffect(() => {
1437 hold.value = withTiming(searchFocused || query ? 1 : 0, { duration: 220 });
1438 }, [searchFocused, query, hold]);
1439 useEffect(() => {
1440 sel.value = withTiming(selecting ? 1 : 0, { duration: 220, easing: Easing.out(Easing.cubic) });
1441 }, [selecting, sel]);
1442
1443 const onScroll = useAnimatedScrollHandler((e) => {
1444 const y = e.contentOffset.y;
1445 const prev = lastY.value;
1446 const d = y > prev ? 1 : y < prev ? -1 : 0;
1447 if (d !== 0 && d !== heading.value) {
1448 heading.value = d;
1449 anchor.value = prev;
1450 }
1451 const travel = y - anchor.value;
1452 let want = fabWant.value;
1453 if (y < 32 || travel < -24) want = 1;
1454 else if (travel > 24) want = 0;
1455 if (want !== fabWant.value) {
1456 fabWant.value = want;
1457 fabOpen.value = withSpring(want, { damping: 20, stiffness: 260, mass: 0.7 });
1458 }
1459 lastY.value = y;
1460 scrollY.value = y;
1461 });
1462
1463 const pillFull = colW - GUTTER * 2 - ME_SIZE - 10;
1464 const headerSheet = useAnimatedStyle(() => ({ transform: [{ translateY: -Math.min(LARGE_H, Math.max(0, scrollY.value)) }] }));
1465 const largeTitle = useAnimatedStyle(() => ({
1466 opacity: interpolate(scrollY.value, [0, LARGE_H * 0.6], [1, 0], 'clamp'),
1467 transform: [{ scale: interpolate(scrollY.value, [-120, 0, LARGE_H], [1.12, 1, 0.92], 'clamp') }],
1468 }));
1469 const barTitle = useAnimatedStyle(() => {
1470 const p = interpolate(scrollY.value, [LARGE_H * 0.55, LARGE_H], [0, 1], 'clamp') * (1 - hold.value);
1471 return { opacity: p, transform: [{ translateY: (1 - p) * 8 }] };
1472 });
1473 const pill = useAnimatedStyle(() => {
1474 const s = Math.min(LARGE_H, Math.max(0, scrollY.value)) * (1 - hold.value);
1475 return { width: interpolate(s, [0, LARGE_H], [pillFull, PILL_MIN]) };
1476 });
1477 const pillText = useAnimatedStyle(() => ({ opacity: interpolate(Math.max(0, scrollY.value) * (1 - hold.value), [0, LARGE_H * 0.45], [1, 0], 'clamp') }));
1478 const tabsLine = useAnimatedStyle(() => ({ opacity: interpolate(scrollY.value, [LARGE_H, LARGE_H + 18], [0, 1], 'clamp') }));
1479 const navNormal = useAnimatedStyle(() => ({ opacity: 1 - sel.value }));
1480
1481 const focusSearch = () => {
1482 if (scrollY.value > LARGE_H * 0.5) {
1483 listRef.current?.scrollTo({ y: 0, animated: true });
1484 later(() => searchRef.current?.focus(), 280);
1485 } else {
1486 searchRef.current?.focus();
1487 }
1488 };
1489
1490 const replies = live.filter((t) => t.needsReply).length;
1491 const bills = live.filter((t) => t.kind === 'bill').length;
1492 const packages = live.filter((t) => t.kind === 'package').length;
1493 const headerH = insets.top + NAV_H + LARGE_H + TABS_H;
1494 let order = 0;
1495
1496 return (
1497 <View style={[styles.screen, { backgroundColor: c.bg }]}>
1498 <View style={styles.column}>
1499 <Animated.ScrollView
1500 ref={listRef}
1501 onScroll={onScroll}
1502 scrollEventThrottle={16}
1503 showsVerticalScrollIndicator={false}
1504 keyboardShouldPersistTaps="handled"
1505 contentContainerStyle={{ paddingTop: headerH + 10, paddingBottom: insets.bottom + FAB_H + 40, minHeight: height + LARGE_H }}
1506 >
1507 <Animated.View key={tab} entering={intro ? undefined : dir > 0 ? FadeInRight.duration(280) : FadeInLeft.duration(280)}>
1508 {tab === 'primary' && !q ? (
1509 <Animated.View entering={intro ? FadeInDown.delay(140).duration(440) : undefined} style={styles.summaryWrap}>
1510 <SummaryCard replies={replies} bills={bills} packages={packages} onPick={pick} c={c} />
1511 </Animated.View>
1512 ) : null}
1513
1514 {groups.map((g) => (
1515 <View key={g.id}>
1516 <Collapse leaving={g.rows.every((t) => leaving.includes(t.id))} fresh={g.rows.every((t) => fresh.includes(t.id))} enter={intro ? FadeIn.delay(180).duration(360) : undefined}>
1517 <Text role="heading" style={[styles.groupTitle, { color: c.muted }]}>
1518 {g.title}
1519 </Text>
1520 </Collapse>
1521 {g.rows.map((t, i) => (
1522 <Collapse
1523 key={t.id}
1524 leaving={leaving.includes(t.id)}
1525 fresh={fresh.includes(t.id)}
1526 enter={intro ? FadeInDown.delay(220 + Math.min(order++, 7) * 55).duration(400) : undefined}
1527 >
1528 <ThreadRow
1529 thread={t}
1530 selected={selected.includes(t.id)}
1531 selecting={selecting}
1532 flashToken={flash.ids.includes(t.id) ? flash.token : 0}
1533 divider={i < g.rows.length - 1}
1534 width={colW}
1535 c={c}
1536 onOpen={open}
1537 onSelect={toggleSelect}
1538 onStar={toggleStar}
1539 onToggleRead={toggleRead}
1540 onArchive={(id) => remove([id], 'archived')}
1541 />
1542 </Collapse>
1543 ))}
1544 </View>
1545 ))}
1546
1547 {shown.length === 0 ? (
1548 <Animated.View entering={FadeIn.delay(120).duration(300)} style={styles.empty}>
1549 <View style={[styles.emptyIcon, { backgroundColor: c.accentSoft }]}>
1550 {q ? <SearchX size={26} color={c.accent} strokeWidth={2} /> : <CheckCheck size={26} color={c.accent} strokeWidth={2} />}
1551 </View>
1552 <Text style={[styles.emptyTitle, { color: c.fg }]}>{q ? 'No mail matches' : 'All caught up'}</Text>
1553 <Text style={[styles.emptyText, { color: c.muted }]}>{q ? `Nothing in ${TABS.find((x) => x.id === tab)?.title} for "${query.trim()}".` : 'Archived mail is one swipe away in All mail.'}</Text>
1554 {q ? (
1555 <Tap label="Clear search" onPress={() => setQuery('')} to={0.95}>
1556 <View style={[styles.emptyButton, { backgroundColor: c.surface }]}>
1557 <Text style={[styles.emptyButtonText, { color: c.fg }]}>Clear search</Text>
1558 </View>
1559 </Tap>
1560 ) : null}
1561 </Animated.View>
1562 ) : (
1563 <Text style={[styles.footer, { color: c.faint }]}>Showing mail from the last 7 days</Text>
1564 )}
1565 </Animated.View>
1566 </Animated.ScrollView>
1567
1568 {/* Header: the bar stays; the large title and tabs ride up under it as the list scrolls */}
1569 <View style={[styles.header, { height: headerH }]}>
1570 <Animated.View style={[styles.headerSheet, { top: insets.top + NAV_H, backgroundColor: c.bg }, headerSheet]}>
1571 <Animated.View entering={FadeIn.duration(420)} style={styles.largeSlot}>
1572 <Animated.View style={[styles.largeRow, largeTitle]}>
1573 <Text role="heading" style={[styles.largeTitle, { color: c.fg }]}>
1574 Inbox
1575 </Text>
1576 {totalUnread > 0 ? (
1577 <View style={[styles.newPill, { backgroundColor: c.accentSoft }]}>
1578 <Animated.Text key={totalUnread} entering={FadeInDown.duration(220)} style={[styles.newPillText, { color: c.accent }]}>
1579 {totalUnread} unread
1580 </Animated.Text>
1581 </View>
1582 ) : null}
1583 </Animated.View>
1584 </Animated.View>
1585 <Animated.View entering={FadeInDown.delay(80).duration(380)}>
1586 <Tabs value={tab} counts={counts} onChange={changeTab} c={c} />
1587 </Animated.View>
1588 <Animated.View style={[styles.headerLine, { backgroundColor: c.line }, tabsLine]} />
1589 </Animated.View>
1590
1591 <View style={[styles.nav, { height: insets.top + NAV_H, paddingTop: insets.top, backgroundColor: c.bg }]}>
1592 <View style={selecting ? styles.noTouch : null}>
1593 <Animated.View style={[styles.navRow, navNormal]}>
1594 <Tap label={`Account, ${ME.name}`}>
1595 <View style={[styles.meRing, { borderColor: c.accentSoft }]}>
1596 <Photo uri={ME.photo} size={ME_SIZE - 6} alt={ME.name} c={c} />
1597 </View>
1598 </Tap>
1599 <View style={[StyleSheet.absoluteFill, styles.barTitleWrap]}>
1600 <Animated.Text style={[styles.barTitle, { color: c.fg }, barTitle]}>Inbox</Animated.Text>
1601 </View>
1602 <View style={styles.pillSlot}>
1603 <Animated.View entering={FadeIn.delay(60).duration(380)} style={[styles.pill, { backgroundColor: c.surface }, pill]}>
1604 <Pressable role="button" aria-label="Search mail" onPress={focusSearch} style={styles.pillIcon}>
1605 <Search size={18} color={c.muted} strokeWidth={2.3} />
1606 </Pressable>
1607 <Animated.View style={[styles.fill, pillText]}>
1608 <TextInput
1609 ref={searchRef}
1610 value={query}
1611 onChangeText={setQuery}
1612 onFocus={() => setSearchFocused(true)}
1613 onBlur={() => setSearchFocused(false)}
1614 placeholder="Search mail"
1615 placeholderTextColor={c.muted}
1616 selectionColor={ACCENT}
1617 returnKeyType="search"
1618 aria-label="Search mail"
1619 style={[styles.pillInput, { color: c.fg }, NO_OUTLINE]}
1620 />
1621 </Animated.View>
1622 {query ? (
1623 <Animated.View entering={ZoomIn.duration(180)}>
1624 <Pressable role="button" aria-label="Clear search" hitSlop={8} onPress={() => setQuery('')} style={[styles.pillClear, { backgroundColor: c.faint }]}>
1625 <X size={12} color={c.bg} strokeWidth={3} />
1626 </Pressable>
1627 </Animated.View>
1628 ) : null}
1629 </Animated.View>
1630 </View>
1631 </Animated.View>
1632 </View>
1633 <View style={[styles.selSlot, selecting ? styles.passThrough : styles.noTouch, { top: insets.top }]}>
1634 <SelectionBar
1635 count={selected.length || lastCount.current}
1636 anyUnread={anyUnread}
1637 progress={sel}
1638 onClose={() => setSelected([])}
1639 onArchive={() => remove(selected, 'archived')}
1640 onDelete={() => remove(selected, 'deleted')}
1641 onRead={markSelected}
1642 onAll={selectAll}
1643 c={c}
1644 />
1645 </View>
1646 </View>
1647 </View>
1648
1649 <ComposeFab open={fabOpen} hidden={selecting || composing} lift={!!snack} bottom={insets.bottom + 16} onPress={openCompose} />
1650 <Snackbar snack={snack} onUndo={undo} bottom={insets.bottom + 12} c={c} />
1651 </View>
1652
1653 <ComposeSheet open={composing} draft={draft} onChange={setDraft} onClose={closeCompose} onDiscard={discard} onSend={send} c={c} />
1654 </View>
1655 );
1656}
1657
1658// ─── Styles ─────────────────────────────────────────────────────────────────
1659
1660const styles = StyleSheet.create({
1661 screen: { flex: 1, overflow: 'hidden' },
1662 column: { flex: 1, width: '100%', maxWidth: COLUMN, alignSelf: 'center' },
1663 fill: { flex: 1 },
1664 noTouch: { pointerEvents: 'none' },
1665 passThrough: { pointerEvents: 'box-none' },
1666
1667 // Small pieces
1668 photo: { overflow: 'hidden' },
1669 photoImage: { width: '100%', height: '100%' },
1670 mark: { alignItems: 'center', justifyContent: 'center', overflow: 'hidden' },
1671 markShine: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, borderWidth: 1, borderColor: 'rgba(255, 255, 255, 0.22)' },
1672 initialsText: { color: '#FFFFFF', fontWeight: '700', letterSpacing: 0.3 },
1673 spinner: { width: 18, height: 18, borderRadius: 9, borderWidth: 2.2 },
1674 round: { width: 36, height: 36, borderRadius: 18, alignItems: 'center', justifyContent: 'center' },
1675
1676 // Header
1677 header: { position: 'absolute', top: 0, left: 0, right: 0, pointerEvents: 'box-none' },
1678 headerSheet: { position: 'absolute', left: 0, right: 0 },
1679 headerLine: { height: StyleSheet.hairlineWidth },
1680 nav: { position: 'absolute', top: 0, left: 0, right: 0 },
1681 navRow: { height: NAV_H, flexDirection: 'row', alignItems: 'center', paddingHorizontal: GUTTER },
1682 meRing: { width: ME_SIZE, height: ME_SIZE, borderRadius: ME_SIZE / 2, borderWidth: 2, alignItems: 'center', justifyContent: 'center' },
1683 barTitleWrap: { alignItems: 'center', justifyContent: 'center', pointerEvents: 'none' },
1684 barTitle: { fontSize: 17, fontWeight: '700', letterSpacing: -0.3 },
1685 pillSlot: { flex: 1, marginLeft: 10, alignItems: 'flex-end' },
1686 pill: { height: 40, borderRadius: 20, flexDirection: 'row', alignItems: 'center', overflow: 'hidden' },
1687 pillIcon: { width: 40, height: 40, alignItems: 'center', justifyContent: 'center' },
1688 pillInput: { flex: 1, height: 40, fontSize: 16, paddingRight: 12, minWidth: 0 },
1689 pillClear: { width: 20, height: 20, borderRadius: 10, alignItems: 'center', justifyContent: 'center', marginRight: 12 },
1690 largeSlot: { height: LARGE_H, justifyContent: 'center' },
1691 largeRow: { flexDirection: 'row', alignItems: 'center', gap: 10, paddingHorizontal: GUTTER, transformOrigin: 'left center' },
1692 largeTitle: { fontSize: 32, lineHeight: 40, fontWeight: '800', letterSpacing: -1.1 },
1693 newPill: { height: 24, paddingHorizontal: 9, borderRadius: 12, justifyContent: 'center', marginTop: 3 },
1694 newPillText: { fontSize: 12.5, fontWeight: '700' },
1695
1696 // Selection bar
1697 selSlot: { position: 'absolute', left: 0, right: 0, height: NAV_H, justifyContent: 'center' },
1698 selBar: { height: 44, marginHorizontal: 10, borderRadius: 22, flexDirection: 'row', alignItems: 'center', paddingHorizontal: 4 },
1699 selButton: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },
1700 selCount: { flexDirection: 'row', alignItems: 'baseline', gap: 5, marginLeft: 2, overflow: 'hidden' },
1701 selNum: { fontSize: 17, fontWeight: '800', fontVariant: ['tabular-nums'] },
1702 selWord: { fontSize: 16, fontWeight: '600' },
1703
1704 // Tabs
1705 tabs: { height: TABS_H, flexDirection: 'row', borderBottomWidth: StyleSheet.hairlineWidth, paddingHorizontal: 4 },
1706 tab: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 6 },
1707 tabLabel: { fontSize: 14.5, letterSpacing: -0.1 },
1708 tabCount: { minWidth: 20, height: 18, paddingHorizontal: 5, borderRadius: 9, alignItems: 'center', justifyContent: 'center' },
1709 tabCountText: { fontSize: 11.5, fontWeight: '800', fontVariant: ['tabular-nums'] },
1710 tabBar: { position: 'absolute', left: 4, bottom: -StyleSheet.hairlineWidth, height: 3, borderTopLeftRadius: 3, borderTopRightRadius: 3 },
1711
1712 // Summary card
1713 summaryWrap: { paddingHorizontal: GUTTER, paddingBottom: 2 },
1714 summary: { borderRadius: 20, borderWidth: 1, paddingHorizontal: 6, paddingTop: 12, paddingBottom: 6 },
1715 summaryHead: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingHorizontal: 8 },
1716 summaryBadge: { width: 20, height: 20, borderRadius: 7, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },
1717 summaryTitle: { fontSize: 14, fontWeight: '700', letterSpacing: -0.1 },
1718 summaryMeta: { fontSize: 12.5, fontWeight: '500' },
1719 summaryRow: { flexDirection: 'row', alignItems: 'stretch', marginTop: 6 },
1720 summarySep: { width: 1, marginVertical: 10 },
1721 stat: { flex: 1, borderRadius: 14, paddingHorizontal: 8, paddingVertical: 7 },
1722 statTop: { flexDirection: 'row', alignItems: 'baseline', gap: 4 },
1723 statNum: { fontSize: 21, lineHeight: 25, fontWeight: '800', letterSpacing: -0.6, fontVariant: ['tabular-nums'] },
1724 statNoun: { flexShrink: 1, fontSize: 13.5, fontWeight: '700', letterSpacing: -0.1 },
1725 statBottom: { flexDirection: 'row', alignItems: 'center', gap: 4, marginTop: 1 },
1726 statRest: { flexShrink: 1, fontSize: 12.5, fontWeight: '500' },
1727
1728 // List
1729 groupTitle: { paddingHorizontal: GUTTER, paddingTop: 16, paddingBottom: 4, fontSize: 12, fontWeight: '700', letterSpacing: 0.7, textTransform: 'uppercase' },
1730 collapse: { overflow: 'hidden' },
1731 rowFront: {},
1732 row: { flexDirection: 'row', paddingLeft: GUTTER, paddingRight: 8, paddingVertical: 11, gap: 12 },
1733 unreadDot: { position: 'absolute', left: 5, top: 11 + AVATAR / 2 - 4, width: 8, height: 8, borderRadius: 4 },
1734 avatarBox: { width: AVATAR, height: AVATAR },
1735 avatarBack: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, borderRadius: AVATAR / 2, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },
1736 rowBody: { flex: 1, minWidth: 0 },
1737 rowTop: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingRight: 6, height: 20 },
1738 sender: { flexShrink: 1, fontSize: 15.5, letterSpacing: -0.2 },
1739 countBubble: { minWidth: 20, height: 18, paddingHorizontal: 5, borderRadius: 6, alignItems: 'center', justifyContent: 'center' },
1740 countText: { fontSize: 11.5, fontWeight: '700', fontVariant: ['tabular-nums'] },
1741 time: { fontSize: 12.5, fontVariant: ['tabular-nums'] },
1742 rowMid: { flexDirection: 'row', alignItems: 'center' },
1743 rowText: { flex: 1, minWidth: 0 },
1744 subjectRow: { flexDirection: 'row', alignItems: 'center', gap: 6, marginTop: 1 },
1745 subject: { flexShrink: 1, fontSize: 14.5, lineHeight: 19 },
1746 snippet: { fontSize: 14, lineHeight: 19 },
1747 label: { height: 18, paddingHorizontal: 6, borderRadius: 5, justifyContent: 'center' },
1748 labelText: { fontSize: 11, fontWeight: '700', letterSpacing: 0.1 },
1749 star: { width: 36, height: 36, alignItems: 'center', justifyContent: 'center' },
1750 starSpark: { position: 'absolute', width: 4, height: 4, borderRadius: 2, backgroundColor: STAR, pointerEvents: 'none' },
1751 chips: { flexDirection: 'row', flexWrap: 'wrap', gap: 6, marginTop: 7, paddingRight: 8 },
1752 fileChip: { height: 26, maxWidth: 200, flexDirection: 'row', alignItems: 'center', gap: 6, paddingHorizontal: 9, borderRadius: 8, borderWidth: 1 },
1753 fileName: { flexShrink: 1, fontSize: 12.5, fontWeight: '600' },
1754 track: { flexDirection: 'row', alignItems: 'center', gap: 6, marginTop: 8, paddingRight: 12 },
1755 trackText: { fontSize: 12.5, fontWeight: '600' },
1756 trackBar: { flex: 1, flexDirection: 'row', gap: 3, marginLeft: 4 },
1757 trackSeg: { flex: 1, height: 4, borderRadius: 2 },
1758 divider: { position: 'absolute', left: GUTTER + AVATAR + 12, right: 0, bottom: 0, height: StyleSheet.hairlineWidth },
1759
1760 // Swipe actions
1761 swipeRead: { backgroundColor: ACCENT },
1762 swipeArchive: { backgroundColor: ARCHIVE },
1763 swipeStart: { position: 'absolute', left: 0, top: 0, bottom: 0, justifyContent: 'center' },
1764 swipeEnd: { position: 'absolute', right: 0, top: 0, bottom: 0, justifyContent: 'center' },
1765 swipeGlyph: { width: GLYPH, alignItems: 'center', gap: 3 },
1766 swipeLabel: { fontSize: 11.5, fontWeight: '700' },
1767
1768 // Empty and footer
1769 empty: { alignItems: 'center', paddingHorizontal: 40, paddingTop: 56 },
1770 emptyIcon: { width: 60, height: 60, borderRadius: 30, alignItems: 'center', justifyContent: 'center' },
1771 emptyTitle: { marginTop: 16, fontSize: 18, fontWeight: '700', letterSpacing: -0.3 },
1772 emptyText: { marginTop: 6, fontSize: 14.5, lineHeight: 21, textAlign: 'center' },
1773 emptyButton: { marginTop: 16, height: 38, paddingHorizontal: 16, borderRadius: 19, justifyContent: 'center' },
1774 emptyButtonText: { fontSize: 14.5, fontWeight: '600' },
1775 footer: { textAlign: 'center', fontSize: 12.5, fontWeight: '500', paddingTop: 22 },
1776
1777 // Compose button
1778 fabSlot: { position: 'absolute', right: GUTTER },
1779 fab: {
1780 height: FAB_H,
1781 borderRadius: 18,
1782 backgroundColor: ACCENT,
1783 flexDirection: 'row',
1784 alignItems: 'center',
1785 gap: 10,
1786 paddingLeft: (FAB_H - 21) / 2,
1787 overflow: 'hidden',
1788 boxShadow: `0px 10px 24px ${tint(ACCENT, 0.36)}`,
1789 },
1790 fabIcon: { width: 21, height: 21, flexShrink: 0 },
1791 fabLabel: { flexShrink: 0, color: ON_ACCENT, fontSize: 16, fontWeight: '700', letterSpacing: -0.2 },
1792
1793 // Snackbar
1794 snack: { position: 'absolute', left: 12, right: 12, minHeight: SNACK_H, borderRadius: 14, overflow: 'hidden', justifyContent: 'center' },
1795 snackInner: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingLeft: 16, paddingRight: 6, minHeight: SNACK_H },
1796 snackCheck: { width: 20, height: 20, borderRadius: 10, alignItems: 'center', justifyContent: 'center' },
1797 snackText: { flex: 1, fontSize: 14.5, fontWeight: '600' },
1798 snackAction: { height: 40, paddingHorizontal: 14, justifyContent: 'center' },
1799 snackActionText: { fontSize: 14.5, fontWeight: '800' },
1800 snackBar: { position: 'absolute', left: 0, right: 0, bottom: 0, height: 3, transformOrigin: 'left center' },
1801
1802 // Compose sheet
1803 sheetLayer: { zIndex: 20 },
1804 sheetAvoid: { flex: 1, justifyContent: 'flex-end', alignItems: 'center' },
1805 sheet: { width: '100%', maxWidth: COLUMN, borderTopLeftRadius: 26, borderTopRightRadius: 26, overflow: 'hidden', boxShadow: '0px -10px 40px rgba(0, 0, 0, 0.18)' },
1806 sheetHead: { paddingTop: 8, paddingBottom: 6 },
1807 grabber: { alignSelf: 'center', width: 38, height: 5, borderRadius: 3 },
1808 sheetTitleRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 14, marginTop: 8 },
1809 sheetTitle: { fontSize: 17, fontWeight: '700', letterSpacing: -0.3 },
1810 sendPill: { height: 36, paddingHorizontal: 14, borderRadius: 18, backgroundColor: ACCENT, flexDirection: 'row', alignItems: 'center', gap: 7 },
1811 sendText: { color: ON_ACCENT, fontSize: 15, fontWeight: '700' },
1812 field: { minHeight: 48, flexDirection: 'row', alignItems: 'center', gap: 8, marginHorizontal: 20, borderBottomWidth: StyleSheet.hairlineWidth },
1813 fieldLabel: { width: 60, fontSize: 15 },
1814 fieldInput: { flex: 1, height: 46, fontSize: 15.5, minWidth: 0 },
1815 fromText: { flex: 1, fontSize: 15, fontWeight: '600' },
1816 fieldError: { marginHorizontal: 20, marginTop: 6, fontSize: 12.5, fontWeight: '600' },
1817 suggest: { flexDirection: 'row', gap: 8, paddingHorizontal: 20, paddingTop: 10, paddingBottom: 2 },
1818 suggestChip: { height: 34, flexDirection: 'row', alignItems: 'center', gap: 7, paddingLeft: 5, paddingRight: 12, borderRadius: 17 },
1819 suggestName: { fontSize: 14, fontWeight: '600' },
1820 body: { flex: 1, paddingHorizontal: 20, paddingTop: 14, fontSize: 15.5, lineHeight: 22 },
1821 tools: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 10, paddingTop: 8, borderTopWidth: StyleSheet.hairlineWidth },
1822 tool: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },
1823 discard: { height: 36, flexDirection: 'row', alignItems: 'center', gap: 6, paddingHorizontal: 12, borderRadius: 18 },
1824 discardText: { fontSize: 14, fontWeight: '700' },
1825});

More screens like this.

All Productivity