We're live on Product Hunt, support us.Upvote

Notification settings

Fine-grained notification preferences with a live lock-screen preview: tapping a category drops its notification onto a drawn lock screen, which also shows when it would be held, bundled into a digest or sent by email only. Category switches fold their Push, Email and SMS chips away, Pause all counts down in a banner with a draining ring, quiet hours draw their span on a 24-hour ring, and a sheet previews sounds with a playing equalizer and vibration patterns that buzz a phone. Every change pops a Changes saved toast with Undo.

notificationssettingspreferencespushquiet hoursdigestswitchbottom sheetanimationreanimated
Paste into Claude Code Cursor Codex Lovable RapidNative

Or let your agent fetch it: connect the gluestack MCP server, then ask for notification-settings.

Live preview · follows the site themeOpen full screen

Details

File
components/patterns/notification-settings.tsx
Lines
1890
Stack
React Native, StyleSheet
Packages
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/notification-settings.tsx
1import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
2import { PanResponder, Pressable, ScrollView, StyleSheet, Text, View, useColorScheme, useWindowDimensions, type LayoutChangeEvent, type StyleProp, type ViewStyle } from 'react-native';
3import Animated, {
4 cancelAnimation,
5 Easing,
6 FadeIn,
7 FadeInDown,
8 interpolate,
9 interpolateColor,
10 useAnimatedProps,
11 useAnimatedRef,
12 useAnimatedScrollHandler,
13 useAnimatedStyle,
14 useSharedValue,
15 withDelay,
16 withRepeat,
17 withSequence,
18 withSpring,
19 withTiming,
20} from 'react-native-reanimated';
21import Svg, { Circle, Defs, Line, LinearGradient as SvgGradient, Path, Rect, Stop, Text as SvgText } from 'react-native-svg';
22import { useSafeAreaInsets } from 'react-native-safe-area-context';
23import {
24 AtSign,
25 BellOff,
26 BellRing,
27 CalendarDays,
28 Check,
29 ChevronLeft,
30 ChevronRight,
31 Ellipsis,
32 Hourglass,
33 Layers,
34 Lock,
35 Mail,
36 Megaphone,
37 MessageCircle,
38 MessageSquareText,
39 Moon,
40 Package,
41 Play,
42 RotateCcw,
43 Settings,
44 ShieldCheck,
45 Smartphone,
46 Sun,
47 Sunrise,
48 Tag,
49 TrendingDown,
50 TriangleAlert,
51 Volume2,
52 VolumeX,
53 X,
54 type LucideIcon,
55} from 'lucide-react-native';
56
57// ─── Brand ──────────────────────────────────────────────────────────────────
58// The screen's accent and name. Every accent colour below derives from these, so changing them rebrands the screen.
59
60const ACCENT = '#3B82F6';
61const ACCENT_DARK = '#6AA4FF'; // the accent as text on dark backgrounds
62const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill
63const APP_NAME = 'Brindle';
64
65/** `hex` at `alpha` opacity, as rgba(). */
66function tint(hex: string, alpha: number) {
67 const n = parseInt(hex.slice(1), 16);
68 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;
69}
70
71/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */
72function shade(hex: string, amount: number) {
73 const n = parseInt(hex.slice(1), 16);
74 const target = amount < 0 ? 255 : 0;
75 const p = Math.abs(amount);
76 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');
77 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();
78}
79
80/** `hex` with its hue turned by `deg` degrees and its HSL lightness and saturation moved by `light` / `sat` (-1 to 1).
81 * For accent-related colours of a different hue (an amber-to-coral gradient from one accent). */
82function spin(hex: string, deg: number, light = 0, sat = 0) {
83 const n = parseInt(hex.slice(1), 16);
84 const r = ((n >> 16) & 255) / 255;
85 const g = ((n >> 8) & 255) / 255;
86 const b = (n & 255) / 255;
87 const max = Math.max(r, g, b);
88 const min = Math.min(r, g, b);
89 const d = max - min;
90 const s = Math.min(1, Math.max(0, (d === 0 ? 0 : d / (1 - Math.abs(max + min - 1))) + sat));
91 const l = Math.min(1, Math.max(0, (max + min) / 2 + light));
92 const h0 = d === 0 ? 0 : max === r ? ((g - b) / d + 6) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
93 const h = (((h0 * 60 + deg) % 360) + 360) % 360;
94 const a = s * Math.min(l, 1 - l);
95 const f = (m: number) => {
96 const k = (m + h / 30) % 12;
97 return Math.round(255 * (l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1)))).toString(16).padStart(2, '0');
98 };
99 return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();
100}
101
102/** `hex` with its hue turned by `deg` and saturation moved by `sat`, at an exact HSL `lightness` (0 to 1).
103 * For surfaces that must stay as dark or as pale as designed whatever the accent: dark-theme backdrops, pale washes,
104 * cards on them and the ink that sits on them. */
105function tone(hex: string, deg: number, lightness: number, sat = 0) {
106 const n = parseInt(hex.slice(1), 16);
107 const r = (n >> 16) & 255; const g = (n >> 8) & 255; const b = n & 255;
108 return spin(hex, deg, lightness - (Math.max(r, g, b) + Math.min(r, g, b)) / 510, sat);
109}
110
111// ─── Sample data ────────────────────────────────────────────────────────────
112
113const USER = { email: 'ana.ruiz@example.com', phone: '+1 (415) ••• 0142' };
114// The moment the screen is set at, so every countdown and quiet-hours check reads the same on every run.
115const NOW = { hour: 9 + 41 / 60, time: '9:41', date: 'Friday 4 December' };
116
117type Channel = 'push' | 'email' | 'sms';
118type CatId = 'messages' | 'mentions' | 'orders' | 'prices' | 'news' | 'security';
119
120const CHANNELS: { id: Channel; label: string; icon: LucideIcon }[] = [
121 { id: 'push', label: 'Push', icon: Smartphone },
122 { id: 'email', label: 'Email', icon: Mail },
123 { id: 'sms', label: 'SMS', icon: MessageSquareText },
124];
125
126type Category = {
127 id: CatId;
128 title: string;
129 detail: string;
130 icon: LucideIcon;
131 color: string;
132 lowPriority?: boolean;
133 locked?: Channel[];
134 sample: { title: string; body: string; avatar?: { initials: string; color: string } };
135};
136
137const CATEGORIES: Category[] = [
138 {
139 id: 'messages',
140 title: 'Messages',
141 detail: 'Buyers and sellers writing to you',
142 icon: MessageCircle,
143 color: '#0EA5E9',
144 sample: { title: 'Maya Chen', body: 'Is the armchair still available? I can pick it up Saturday morning.', avatar: { initials: 'MC', color: '#F97316' } },
145 },
146 {
147 id: 'mentions',
148 title: 'Mentions and replies',
149 detail: 'Answers on listings you asked about',
150 icon: AtSign,
151 color: '#F59E0B',
152 sample: { title: 'Leo Park replied to you', body: '"Both drawers slide smoothly and there is no wobble at all."', avatar: { initials: 'LP', color: '#14B8A6' } },
153 },
154 {
155 id: 'orders',
156 title: 'Orders and deliveries',
157 detail: 'Payments, shipping and drop-offs',
158 icon: Package,
159 color: '#10B981',
160 sample: { title: 'Out for delivery', body: 'Ceramic table lamp arrives today, 14:00 to 16:00. Your courier is 6 stops away.' },
161 },
162 {
163 id: 'prices',
164 title: 'Price drops',
165 detail: 'Saved items that get cheaper',
166 icon: TrendingDown,
167 color: '#F43F5E',
168 lowPriority: true,
169 sample: { title: 'Price drop on a saved item', body: 'Vintage film camera is now $84, down from $120. 3 others saved it.' },
170 },
171 {
172 id: 'news',
173 title: 'Product news',
174 detail: 'New features and tips, about twice a month',
175 icon: Megaphone,
176 color: '#8B5CF6',
177 lowPriority: true,
178 sample: { title: 'New: counter offers', body: 'Reply to any offer with your own price, right from the chat.' },
179 },
180 {
181 id: 'security',
182 title: 'Security',
183 detail: 'Sign-ins and payout changes',
184 icon: ShieldCheck,
185 color: '#64748B',
186 locked: ['push', 'email'],
187 sample: { title: 'New sign-in to your account', body: 'A browser on a laptop near Lisbon at 09:12. Not you? Tap to secure your account.' },
188 },
189];
190
191const SECURITY_REASON =
192 'Sign-in alerts, password changes and payout edits always reach you by push and email, so you can stop someone else fast. SMS is an optional backup.';
193
194type PauseId = '1h' | 'tomorrow' | 'week' | 'manual';
195const PAUSES: { id: PauseId; label: string; hint: string; until: string; ms: number | null; icon: LucideIcon }[] = [
196 { id: '1h', label: '1 hour', hint: 'Until 10:41', until: 'until 10:41', ms: 60 * 60_000, icon: Hourglass },
197 { id: 'tomorrow', label: 'Until tomorrow 8:00', hint: '22 h 19 min', until: 'until 8:00 tomorrow', ms: (22 * 60 + 19) * 60_000, icon: Sunrise },
198 { id: 'week', label: '1 week', hint: 'Until Fri 11 Dec', until: 'until Fri 11 Dec', ms: 7 * 24 * 60 * 60_000, icon: CalendarDays },
199 { id: 'manual', label: 'Until I turn it back on', hint: 'No end time', until: 'until you resume', ms: null, icon: BellOff },
200];
201
202type Freq = 'daily' | 'weekdays' | 'weekly';
203const FREQS: { id: Freq; label: string; when: string; next: string; waiting: number; mix: string; title: string }[] = [
204 { id: 'daily', label: 'Daily', when: 'at 18:00', next: 'Today, 18:00', waiting: 6, mix: '3 price drops, 2 product updates and 1 selling tip', title: 'Your 18:00 summary' },
205 { id: 'weekdays', label: 'Weekdays', when: 'on weekdays at 18:00', next: 'Today, 18:00', waiting: 6, mix: '3 price drops, 2 product updates and 1 selling tip', title: 'Your 18:00 summary' },
206 { id: 'weekly', label: 'Weekly', when: 'on Sundays at 18:00', next: 'Sunday, 18:00', waiting: 23, mix: '14 price drops, 6 product updates and 3 selling tips', title: 'Your weekly summary' },
207];
208
209const SOUNDS = [
210 { id: 'pebble', name: 'Pebble', length: 0.6 },
211 { id: 'chime', name: 'Chime', length: 1.2 },
212 { id: 'woodblock', name: 'Woodblock', length: 0.5 },
213 { id: 'ripple', name: 'Ripple', length: 1.6 },
214 { id: 'shopbell', name: 'Shop bell', length: 1.4 },
215 { id: 'none', name: 'None', length: 0 },
216];
217
218// Each pulse is [start, duration] in milliseconds on a 700 ms loop.
219type Pulse = [number, number];
220const VIBES: { id: string; name: string; pulses: Pulse[] }[] = [
221 { id: 'double', name: 'Double', pulses: [[0, 90], [190, 90]] },
222 { id: 'short', name: 'Short', pulses: [[0, 110]] },
223 { id: 'heartbeat', name: 'Heartbeat', pulses: [[0, 70], [130, 170]] },
224 { id: 'rapid', name: 'Rapid', pulses: [[0, 50], [110, 50], [220, 50], [330, 50], [440, 50]] },
225 { id: 'long', name: 'Long', pulses: [[0, 520]] },
226 { id: 'off', name: 'Off', pulses: [] },
227];
228
229const FROM_HOURS = [20, 21, 22, 23, 0, 1];
230const TO_HOURS = [5, 6, 7, 8, 9, 10];
231
232type CatPref = { on: boolean; ch: Record<Channel, boolean> };
233type Prefs = {
234 cats: Record<CatId, CatPref>;
235 quiet: { on: boolean; from: number; to: number };
236 digest: { on: boolean; freq: Freq };
237 sound: string;
238 vibe: string;
239};
240
241const DEFAULTS: Prefs = {
242 cats: {
243 messages: { on: true, ch: { push: true, email: true, sms: false } },
244 mentions: { on: true, ch: { push: true, email: false, sms: false } },
245 orders: { on: true, ch: { push: true, email: true, sms: true } },
246 prices: { on: true, ch: { push: true, email: false, sms: false } },
247 news: { on: false, ch: { push: false, email: true, sms: false } },
248 security: { on: true, ch: { push: true, email: true, sms: false } },
249 },
250 quiet: { on: true, from: 22, to: 7 },
251 digest: { on: true, freq: 'daily' },
252 sound: 'pebble',
253 vibe: 'double',
254};
255
256// ─── Palette ────────────────────────────────────────────────────────────────
257
258const COLUMN = 520;
259const SPRING = { damping: 18, stiffness: 240, mass: 0.7 };
260const PRESS = { damping: 16, stiffness: 320, mass: 0.6 };
261const POP = { damping: 15, stiffness: 230, mass: 0.7 };
262const LIVE = '#22C55E';
263const LOCK_INK = '#FFFFFF';
264const TOAST_INK = '#F4F4F5';
265const ACCENT_PRESSED = shade(ACCENT, 0.12);
266
267function usePalette() {
268 const dark = useColorScheme() === 'dark';
269 return {
270 dark,
271 bg: dark ? '#18181B' : '#F2F3F6',
272 card: dark ? '#232327' : '#FFFFFF',
273 raised: dark ? '#2C2C31' : '#F2F3F6',
274 sheet: dark ? '#232327' : '#FFFFFF',
275 menu: dark ? '#2C2C31' : '#FFFFFF',
276 segThumb: dark ? '#3D3D44' : '#FFFFFF',
277 fg: dark ? '#F4F4F5' : '#101217',
278 muted: dark ? '#A1A1AA' : '#686C78',
279 faint: dark ? '#62626B' : '#B5B8C2',
280 border: dark ? '#36363C' : '#E4E6EB',
281 line: dark ? '#303035' : '#ECEDF1',
282 track: dark ? '#44444B' : '#E1E3E8',
283 pressed: dark ? '#34343A' : '#F2F3F6',
284 accent: dark ? ACCENT_DARK : ACCENT,
285 accentText: dark ? ACCENT_DARK : shade(ACCENT, 0.2),
286 accentSoft: dark ? tint(ACCENT_DARK, 0.16) : tint(ACCENT, 0.09),
287 accentRing: dark ? tint(ACCENT_DARK, 0.5) : tint(ACCENT, 0.42),
288 hold: dark ? '#FBBF24' : '#D97706',
289 holdSoft: dark ? 'rgba(251, 191, 36, 0.15)' : 'rgba(245, 158, 11, 0.13)',
290 toast: dark ? '#3A3A41' : '#1E2026',
291 toastMuted: dark ? '#B4B4BC' : '#A3A6B0',
292 backdrop: dark ? 'rgba(10, 10, 12, 0.55)' : 'rgba(16, 18, 23, 0.36)',
293 cardShadow: dark ? '0px 0px 0px 1px rgba(255, 255, 255, 0.045)' : '0px 1px 2px rgba(16, 18, 23, 0.06)',
294 menuShadow: dark ? '0px 14px 34px rgba(0, 0, 0, 0.45), 0px 0px 0px 1px rgba(255, 255, 255, 0.07)' : '0px 14px 34px rgba(16, 18, 23, 0.16), 0px 0px 0px 1px rgba(16, 18, 23, 0.05)',
295 lockShadow: dark ? '0px 0px 0px 1px rgba(255, 255, 255, 0.06)' : '0px 10px 28px rgba(16, 18, 23, 0.14)',
296 glass: dark ? 'rgba(48, 48, 54, 0.9)' : 'rgba(255, 255, 255, 0.88)',
297 glassInk: dark ? '#F4F4F5' : '#101217',
298 glassMuted: dark ? '#B4B4BC' : '#4B4F5A',
299 wash: (hex: string) => tint(hex, dark ? 0.2 : 0.12),
300 // The drawn lock-screen wallpaper: an accent-tinted sky over two hills and a low sun.
301 sky: dark ? [tone(ACCENT, 4, 0.14, -0.45), tone(ACCENT, -10, 0.3, -0.42), '#B57A5E'] : [tone(ACCENT, 0, 0.42, -0.25), tone(ACCENT, -14, 0.7, -0.3), '#F6C9A5'],
302 hillBack: dark ? tone(ACCENT, -8, 0.21, -0.55) : tone(ACCENT, -8, 0.44, -0.5),
303 hillFront: dark ? tone(ACCENT, -16, 0.12, -0.55) : tone(ACCENT, -16, 0.27, -0.55),
304 sun: dark ? '#F1CFAE' : '#FFF0DA',
305 };
306}
307type Palette = ReturnType<typeof usePalette>;
308
309// ─── Rules ──────────────────────────────────────────────────────────────────
310
311const hh = (h: number) => `${String(h).padStart(2, '0')}:00`;
312const spanHours = (from: number, to: number) => (to - from + 24) % 24 || 24;
313const isQuietAt = (from: number, to: number, at: number) => (from < to ? at >= from && at < to : at >= from || at < to);
314const cap = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
315const listing = (items: string[]) => (items.length < 2 ? items.join('') : `${items.slice(0, -1).join(', ')} and ${items[items.length - 1]}`);
316
317function formatLeft(ms: number) {
318 const total = Math.ceil(ms / 60_000);
319 const d = Math.floor(total / 1440);
320 const h = Math.floor((total % 1440) / 60);
321 const m = total % 60;
322 if (d > 0) return h ? `${d} d ${h} h left` : `${d} d left`;
323 if (h > 0) return m ? `${h} h ${m} min left` : `${h} h left`;
324 return `${m} min left`;
325}
326
327type PauseState = { id: PauseId; at: number };
328
329type Preview = { kind: 'notice' } | { kind: 'digest' } | { kind: 'note'; icon: LucideIcon; title: string; sub: string; hold: boolean };
330
331/** What the lock screen would show for one category, given every other setting. */
332function previewFor(cat: Category, prefs: Prefs, pause: PauseState | null, blocked: boolean): Preview {
333 const p = prefs.cats[cat.id];
334 const others = CHANNELS.filter((c) => c.id !== 'push' && p.ch[c.id]).map((c) => c.label);
335 if (!p.on) return { kind: 'note', icon: BellOff, title: 'Off on every channel', sub: `Nothing arrives for ${cat.title}`, hold: false };
336 if (!p.ch.push) return { kind: 'note', icon: Mail, title: 'Not on your lock screen', sub: others.length ? `Arrives by ${listing(others)} instead` : 'No other channel is on', hold: false };
337 if (blocked) return { kind: 'note', icon: TriangleAlert, title: 'Blocked in phone Settings', sub: others.length ? `${listing(others)} still ${others.length > 1 ? 'arrive' : 'arrives'}` : 'Turn it on in Settings to see it here', hold: true };
338 if (pause && !cat.locked) {
339 const opt = PAUSES.find((x) => x.id === pause.id) ?? PAUSES[0];
340 return { kind: 'note', icon: BellOff, title: `Paused ${opt.until}`, sub: 'It will be waiting when you resume', hold: true };
341 }
342 if (prefs.quiet.on && !cat.locked && isQuietAt(prefs.quiet.from, prefs.quiet.to, NOW.hour)) {
343 return { kind: 'note', icon: Moon, title: 'Held for quiet hours', sub: `Delivered at ${hh(prefs.quiet.to)}`, hold: true };
344 }
345 if (prefs.digest.on && cat.lowPriority) return { kind: 'digest' };
346 return { kind: 'notice' };
347}
348
349// ─── Small pieces ───────────────────────────────────────────────────────────
350
351type Role = 'button' | 'switch' | 'checkbox' | 'radio' | 'menuitem';
352
353/** A pressable that springs down a little while held. */
354function Tap({
355 label,
356 onPress,
357 role = 'button',
358 checked,
359 to = 0.96,
360 style,
361 children,
362}: {
363 label: string;
364 onPress?: () => void;
365 role?: Role;
366 checked?: boolean;
367 to?: number;
368 style?: StyleProp<ViewStyle>;
369 children: ReactNode;
370}) {
371 const s = useSharedValue(1);
372 const anim = useAnimatedStyle(() => ({ transform: [{ scale: s.value }] }));
373 return (
374 <Pressable
375 role={role}
376 aria-label={label}
377 aria-checked={checked}
378 hitSlop={4}
379 onPress={onPress}
380 onPressIn={() => (s.value = withSpring(to, PRESS))}
381 onPressOut={() => (s.value = withSpring(1, PRESS))}
382 >
383 <Animated.View style={[style, anim]}>{children}</Animated.View>
384 </Pressable>
385 );
386}
387
388/** A spring switch: the track fills with the accent and the thumb stretches while pressed. */
389function Toggle({ on, label, onChange, pal }: { on: boolean; label: string; onChange: (on: boolean) => void; pal: Palette }) {
390 const t = useSharedValue(on ? 1 : 0);
391 const press = useSharedValue(0);
392 useEffect(() => {
393 t.value = withSpring(on ? 1 : 0, SPRING);
394 }, [on, t]);
395 const off = pal.track;
396 const track = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(t.value, [0, 1], [off, ACCENT]) }));
397 const thumb = useAnimatedStyle(() => ({ width: 24 + press.value * 5, transform: [{ translateX: t.value * (18 - press.value * 5) }] }));
398 return (
399 <Pressable
400 role="switch"
401 aria-checked={on}
402 aria-label={label}
403 hitSlop={8}
404 onPress={() => onChange(!on)}
405 onPressIn={() => (press.value = withTiming(1, { duration: 120 }))}
406 onPressOut={() => (press.value = withTiming(0, { duration: 180 }))}
407 >
408 <Animated.View style={[styles.switchTrack, track]}>
409 <Animated.View style={[styles.switchThumb, thumb]} />
410 </Animated.View>
411 </Pressable>
412 );
413}
414
415/** Opens to its content's measured height and folds shut, fading as it goes. */
416function Collapse({ open, children }: { open: boolean; children: ReactNode }) {
417 const t = useSharedValue(open ? 1 : 0);
418 const h = useSharedValue(0);
419 useEffect(() => {
420 t.value = withTiming(open ? 1 : 0, { duration: open ? 340 : 260, easing: Easing.out(Easing.cubic) });
421 }, [open, t]);
422 const box = useAnimatedStyle(() => ({ height: h.value * t.value }));
423 const inner = useAnimatedStyle(() => ({ opacity: t.value, transform: [{ translateY: (1 - t.value) * -8 }] }));
424 return (
425 <Animated.View aria-hidden={!open} style={[styles.collapse, { pointerEvents: open ? 'auto' : 'none' }, box]}>
426 <Animated.View
427 onLayout={(e: LayoutChangeEvent) => {
428 h.value = e.nativeEvent.layout.height;
429 }}
430 style={[styles.collapseInner, inner]}
431 >
432 {children}
433 </Animated.View>
434 </Animated.View>
435 );
436}
437
438function Spinner({ color }: { color: string }) {
439 const r = useSharedValue(0);
440 useEffect(() => {
441 r.value = withRepeat(withTiming(360, { duration: 750, easing: Easing.linear }), -1);
442 return () => cancelAnimation(r);
443 }, [r]);
444 const style = useAnimatedStyle(() => ({ transform: [{ rotate: `${r.value}deg` }] }));
445 return <Animated.View style={[styles.spinner, { borderColor: tint(color, 0.3), borderTopColor: color }, style]} />;
446}
447
448function IconTile({ icon: Icon, color, pal, size = 38 }: { icon: LucideIcon; color: string; pal: Palette; size?: number }) {
449 return (
450 <View style={[styles.iconTile, { width: size, height: size, borderRadius: size * 0.32, backgroundColor: pal.wash(color) }]}>
451 <Icon size={size * 0.47} color={color} strokeWidth={2.2} />
452 </View>
453 );
454}
455
456function SectionHead({ title, aside, pal }: { title: string; aside?: string; pal: Palette }) {
457 return (
458 <View style={styles.sectionHead}>
459 <Text role="heading" style={[styles.sectionTitle, { color: pal.muted }]}>
460 {title}
461 </Text>
462 {aside ? <Text style={[styles.sectionAside, { color: pal.muted }]}>{aside}</Text> : null}
463 </View>
464 );
465}
466
467/** The app's drawn mark: a price tag on the accent. */
468function AppIcon({ size }: { size: number }) {
469 return (
470 <View style={[styles.appIcon, { width: size, height: size, borderRadius: size * 0.26 }]}>
471 <Tag size={size * 0.5} color={ON_ACCENT} strokeWidth={2.4} />
472 </View>
473 );
474}
475
476// ─── Channel chip: fills with the accent and grows a tick when on ───────────
477
478function ChannelChip({
479 channel,
480 on,
481 locked,
482 warn,
483 onPress,
484 pal,
485}: {
486 channel: (typeof CHANNELS)[number];
487 on: boolean;
488 locked: boolean;
489 warn: boolean;
490 onPress: () => void;
491 pal: Palette;
492}) {
493 const t = useSharedValue(on ? 1 : 0);
494 const s = useSharedValue(1);
495 const shake = useSharedValue(0);
496 useEffect(() => {
497 t.value = withTiming(on ? 1 : 0, { duration: 220, easing: Easing.out(Easing.quad) });
498 }, [on, t]);
499 const offBg = pal.card;
500 const onBg = pal.accentSoft;
501 const offEdge = pal.border;
502 const onEdge = pal.accentRing;
503 const box = useAnimatedStyle(() => ({
504 backgroundColor: interpolateColor(t.value, [0, 1], [offBg, onBg]),
505 borderColor: interpolateColor(t.value, [0, 1], [offEdge, onEdge]),
506 transform: [{ translateX: shake.value }, { scale: s.value }],
507 }));
508 const tick = useAnimatedStyle(() => ({ width: t.value * 15, opacity: t.value, transform: [{ scale: 0.4 + 0.6 * t.value }] }));
509 const Icon = channel.icon;
510 const ink = on ? pal.accentText : pal.muted;
511 const press = () => {
512 if (locked) {
513 shake.value = withSequence(withTiming(-4, { duration: 50 }), withTiming(4, { duration: 70 }), withTiming(-2.5, { duration: 60 }), withTiming(0, { duration: 60 }));
514 }
515 onPress();
516 };
517 return (
518 <Pressable
519 role="checkbox"
520 aria-checked={on}
521 aria-disabled={locked}
522 aria-label={locked ? `${channel.label}, always on` : channel.label}
523 onPress={press}
524 onPressIn={() => (s.value = withSpring(0.93, PRESS))}
525 onPressOut={() => (s.value = withSpring(1, PRESS))}
526 >
527 <Animated.View style={[styles.chip, box]}>
528 <Icon size={14} color={ink} strokeWidth={2.2} />
529 <Text style={[styles.chipLabel, { color: ink }]}>{channel.label}</Text>
530 {locked ? (
531 <Lock size={11} color={pal.accentText} strokeWidth={2.6} />
532 ) : warn ? (
533 <TriangleAlert size={12} color={pal.hold} strokeWidth={2.4} />
534 ) : (
535 <Animated.View style={[styles.chipTick, tick]}>
536 <Check size={13} color={pal.accentText} strokeWidth={3} />
537 </Animated.View>
538 )}
539 </Animated.View>
540 </Pressable>
541 );
542}
543
544// ─── Category card ──────────────────────────────────────────────────────────
545
546function CategoryCard({
547 cat,
548 pref,
549 index,
550 selected,
551 inDigest,
552 blocked,
553 paused,
554 onSelect,
555 onToggle,
556 onChip,
557 pal,
558}: {
559 cat: Category;
560 pref: CatPref;
561 index: number;
562 selected: boolean;
563 inDigest: boolean;
564 blocked: boolean;
565 paused: boolean;
566 onSelect: () => void;
567 onToggle: (on: boolean) => void;
568 onChip: (ch: Channel) => void;
569 pal: Palette;
570}) {
571 const [why, setWhy] = useState(false);
572 const ring = useSharedValue(selected ? 1 : 0);
573 const dim = useSharedValue(0);
574 useEffect(() => {
575 ring.value = withTiming(selected ? 1 : 0, { duration: 220 });
576 }, [selected, ring]);
577 useEffect(() => {
578 dim.value = withTiming(paused && !cat.locked ? 1 : 0, { duration: 300 });
579 }, [paused, cat.locked, dim]);
580 const ringStyle = useAnimatedStyle(() => ({ opacity: ring.value }));
581 const dimStyle = useAnimatedStyle(() => ({ opacity: 1 - dim.value * 0.4 }));
582 const locked = !!cat.locked;
583 const explain = () => {
584 onSelect();
585 setWhy((w) => !w);
586 };
587 return (
588 <Animated.View entering={FadeInDown.delay(300 + index * 60).duration(420)}>
589 <Animated.View style={[styles.catCard, { backgroundColor: pal.card, boxShadow: pal.cardShadow }, dimStyle]}>
590 <Animated.View style={[StyleSheet.absoluteFill, styles.catRing, { borderColor: pal.accent }, ringStyle]} />
591 <View style={styles.catHead}>
592 <Pressable role="button" aria-label={`Preview ${cat.title}`} aria-pressed={selected} onPress={locked ? explain : onSelect} style={styles.catHit}>
593 <IconTile icon={cat.icon} color={cat.color} pal={pal} />
594 <View style={styles.fill}>
595 <View style={styles.catTitleRow}>
596 <Text numberOfLines={1} style={[styles.catTitle, { color: pal.fg }]}>
597 {cat.title}
598 </Text>
599 {inDigest ? (
600 <View style={[styles.digestTag, { backgroundColor: pal.raised }]}>
601 <Layers size={10} color={pal.muted} strokeWidth={2.4} />
602 <Text style={[styles.digestTagLabel, { color: pal.muted }]}>Digest</Text>
603 </View>
604 ) : null}
605 </View>
606 <Text numberOfLines={1} style={[styles.catDetail, { color: pal.muted }]}>
607 {pref.on ? cat.detail : 'Off on every channel'}
608 </Text>
609 </View>
610 </Pressable>
611 {locked ? (
612 <Tap label="Why security alerts stay on" onPress={explain} style={[styles.lockPill, { backgroundColor: pal.raised }]}>
613 <Lock size={12} color={pal.muted} strokeWidth={2.4} />
614 <Text style={[styles.lockPillLabel, { color: pal.muted }]}>Always on</Text>
615 </Tap>
616 ) : (
617 <Toggle on={pref.on} label={`${cat.title} notifications`} onChange={onToggle} pal={pal} />
618 )}
619 </View>
620 <Collapse open={pref.on}>
621 <View role="group" aria-label={`${cat.title} channels`} style={styles.chips}>
622 {CHANNELS.map((ch) => {
623 const isLocked = !!cat.locked?.includes(ch.id);
624 return (
625 <ChannelChip
626 key={ch.id}
627 channel={ch}
628 on={pref.ch[ch.id]}
629 locked={isLocked}
630 warn={ch.id === 'push' && blocked && pref.ch.push}
631 onPress={() => {
632 if (isLocked) {
633 onSelect();
634 setWhy(true);
635 } else onChip(ch.id);
636 }}
637 pal={pal}
638 />
639 );
640 })}
641 </View>
642 </Collapse>
643 {locked ? (
644 <Collapse open={why}>
645 <View style={[styles.why, { backgroundColor: pal.raised }]}>
646 <Lock size={14} color={pal.muted} strokeWidth={2.4} />
647 <Text style={[styles.whyText, { color: pal.fg }]}>{SECURITY_REASON}</Text>
648 </View>
649 </Collapse>
650 ) : null}
651 </Animated.View>
652 </Animated.View>
653 );
654}
655
656// ─── Lock-screen preview: a drawn phone screen where the notification lands ─
657
658function Wallpaper({ pal }: { pal: Palette }) {
659 return (
660 <Svg width="100%" height="100%" viewBox="0 0 360 210" preserveAspectRatio="xMidYMid slice" style={StyleSheet.absoluteFill}>
661 <Defs>
662 <SvgGradient id="ns-sky" x1="0" y1="0" x2="0" y2="1">
663 <Stop offset="0" stopColor={pal.sky[0]} />
664 <Stop offset="0.4" stopColor={pal.sky[1]} />
665 <Stop offset="0.6" stopColor={pal.sky[2]} />
666 </SvgGradient>
667 </Defs>
668 <Rect x="0" y="0" width="360" height="210" fill="url(#ns-sky)" />
669 <Circle cx="300" cy="90" r="13" fill={pal.sun} opacity={0.95} />
670 <Path d="M0 110 C 46 94 96 104 150 99 S 270 84 360 102 L 360 210 L 0 210 Z" fill={pal.hillBack} />
671 <Path d="M0 124 C 60 108 120 122 196 112 S 316 104 360 118 L 360 210 L 0 210 Z" fill={pal.hillFront} />
672 </Svg>
673 );
674}
675
676/** Drops in from above like a real notification arriving. */
677function Arrive({ delay, children }: { delay: number; children: ReactNode }) {
678 const t = useSharedValue(0);
679 useEffect(() => {
680 t.value = withDelay(delay, withSpring(1, { damping: 15, stiffness: 170, mass: 0.8 }));
681 }, [delay, t]);
682 const style = useAnimatedStyle(() => ({
683 opacity: Math.min(1, Math.max(0, t.value * 1.6)),
684 transform: [{ translateY: (1 - t.value) * -28 }, { scale: 0.93 + 0.07 * t.value }],
685 }));
686 return <Animated.View style={style}>{children}</Animated.View>;
687}
688
689function NoticeCard({ cat, digest, pal }: { cat: Category; digest: (typeof FREQS)[number] | null; pal: Palette }) {
690 const s = cat.sample;
691 const title = digest ? digest.title : s.title;
692 const body = digest ? `${digest.waiting} updates: ${digest.mix}.` : s.body;
693 return (
694 <View>
695 {digest ? (
696 <>
697 <View style={[styles.plateBack, { backgroundColor: pal.glass }]} />
698 <View style={[styles.plateMid, { backgroundColor: pal.glass }]} />
699 </>
700 ) : null}
701 <View style={[styles.notice, { backgroundColor: pal.glass }]}>
702 {s.avatar && !digest ? (
703 <View>
704 <View style={[styles.avatar, { backgroundColor: s.avatar.color }]}>
705 <Text style={styles.avatarInitials}>{s.avatar.initials}</Text>
706 </View>
707 <View style={styles.avatarBadge}>
708 <AppIcon size={16} />
709 </View>
710 </View>
711 ) : (
712 <AppIcon size={38} />
713 )}
714 <View style={styles.fill}>
715 <View style={styles.noticeTop}>
716 <Text numberOfLines={1} style={[styles.noticeTitle, { color: pal.glassInk }]}>
717 {title}
718 </Text>
719 <Text style={[styles.noticeTime, { color: pal.glassMuted }]}>now</Text>
720 </View>
721 <Text numberOfLines={2} style={[styles.noticeBody, { color: pal.glassInk }]}>
722 {body}
723 </Text>
724 </View>
725 </View>
726 </View>
727 );
728}
729
730function NoteCard({ note, pal }: { note: Extract<Preview, { kind: 'note' }>; pal: Palette }) {
731 const Icon = note.icon;
732 return (
733 <View style={[styles.notice, { backgroundColor: pal.glass }]}>
734 <View style={[styles.noteIcon, { backgroundColor: note.hold ? pal.holdSoft : pal.raised }]}>
735 <Icon size={18} color={note.hold ? pal.hold : pal.muted} strokeWidth={2.2} />
736 </View>
737 <View style={styles.fill}>
738 <Text numberOfLines={1} style={[styles.noticeTitle, { color: pal.glassInk }]}>
739 {note.title}
740 </Text>
741 <Text numberOfLines={2} style={[styles.noteSub, { color: pal.glassMuted }]}>
742 {note.sub}
743 </Text>
744 </View>
745 </View>
746 );
747}
748
749function LockPreview({ cat, preview, digest, replay, booted, pal }: { cat: Category; preview: Preview; digest: (typeof FREQS)[number]; replay: number; booted: boolean; pal: Palette }) {
750 const key = `${cat.id}-${preview.kind}-${preview.kind === 'note' ? preview.title : ''}-${replay}`;
751 return (
752 <View aria-label={`Lock screen preview for ${cat.title}`} style={[styles.lock, { boxShadow: pal.lockShadow }]}>
753 <Wallpaper pal={pal} />
754 <View style={styles.lockTop}>
755 <Lock size={13} color={LOCK_INK} strokeWidth={2.4} />
756 <Text style={styles.lockDate}>{NOW.date}</Text>
757 <Text style={styles.lockTime}>{NOW.time}</Text>
758 </View>
759 <View style={styles.lockSlot}>
760 <Arrive key={key} delay={booted ? 40 : 560}>
761 {preview.kind === 'note' ? <NoteCard note={preview} pal={pal} /> : <NoticeCard cat={cat} digest={preview.kind === 'digest' ? digest : null} pal={pal} />}
762 </Arrive>
763 </View>
764 </View>
765 );
766}
767
768// ─── Pause banner: the time left, with a ring that drains ───────────────────
769
770const DRAIN = 40;
771const DRAIN_R = 17;
772const DRAIN_C = 2 * Math.PI * DRAIN_R;
773
774function PauseBanner({ pause, left, frac, onResume, pal }: { pause: PauseState; left: string | null; frac: number; onResume: () => void; pal: Palette }) {
775 const opt = PAUSES.find((p) => p.id === pause.id) ?? PAUSES[0];
776 return (
777 <View role="status" style={[styles.banner, { backgroundColor: pal.card, boxShadow: pal.cardShadow }]}>
778 <View style={styles.drain}>
779 <Svg width={DRAIN} height={DRAIN} style={styles.drainSvg}>
780 <Circle cx={DRAIN / 2} cy={DRAIN / 2} r={DRAIN_R} stroke={pal.track} strokeWidth={3} fill="none" />
781 <Circle cx={DRAIN / 2} cy={DRAIN / 2} r={DRAIN_R} stroke={pal.hold} strokeWidth={3} strokeLinecap="round" fill="none" strokeDasharray={`${DRAIN_C} ${DRAIN_C}`} strokeDashoffset={DRAIN_C * (1 - frac)} />
782 </Svg>
783 <BellOff size={16} color={pal.hold} strokeWidth={2.3} />
784 </View>
785 <View style={styles.fill}>
786 <Text style={[styles.bannerTitle, { color: pal.fg }, styles.tabular]}>{left ? `Paused · ${left}` : 'Paused'}</Text>
787 <Text numberOfLines={2} style={[styles.bannerSub, { color: pal.muted }]}>
788 {cap(opt.until)}. Security alerts still come through.
789 </Text>
790 </View>
791 <Tap label="Resume notifications" onPress={onResume} style={styles.resume}>
792 <Text style={styles.resumeLabel}>Resume</Text>
793 </Tap>
794 </View>
795 );
796}
797
798// ─── Permission card: shown when the phone blocks notifications ─────────────
799
800function PermissionCard({ busy, onFix, pal }: { busy: boolean; onFix: () => void; pal: Palette }) {
801 return (
802 <View role="alert" style={[styles.permission, { backgroundColor: pal.card, boxShadow: pal.cardShadow }]}>
803 <View style={styles.permissionTop}>
804 <View style={[styles.noteIcon, { backgroundColor: pal.holdSoft }]}>
805 <BellOff size={18} color={pal.hold} strokeWidth={2.2} />
806 </View>
807 <View style={styles.fill}>
808 <Text style={[styles.permissionTitle, { color: pal.fg }]}>Notifications are off on this phone</Text>
809 <Text style={[styles.permissionBody, { color: pal.muted }]}>{`${APP_NAME} can't show alerts or play sounds until you allow them. Email and SMS still reach you.`}</Text>
810 </View>
811 </View>
812 <Tap label="Turn on in Settings" onPress={busy ? undefined : onFix} style={styles.permissionButton}>
813 {busy ? (
814 <Spinner color={ON_ACCENT} />
815 ) : (
816 <>
817 <Settings size={16} color={ON_ACCENT} strokeWidth={2.3} />
818 <Text style={styles.permissionButtonLabel}>Turn on in Settings</Text>
819 </>
820 )}
821 </Tap>
822 </View>
823 );
824}
825
826// ─── Quiet hours: a 24-hour ring with the quiet span drawn on it ────────────
827
828const RING = 140;
829const RC = RING / 2;
830const RR = 54;
831const RW = 11;
832const RCIRC = 2 * Math.PI * RR;
833const KNOB = 22;
834const AnimatedCircle = Animated.createAnimatedComponent(Circle);
835
836function knobAt(deg: number) {
837 'worklet';
838 const a = (deg * Math.PI) / 180;
839 return { left: RC + RR * Math.sin(a) - KNOB / 2, top: RC - RR * Math.cos(a) - KNOB / 2 };
840}
841
842const TICKS = Array.from({ length: 24 }, (_, i) => {
843 const a = (i * 15 * Math.PI) / 180;
844 const major = i % 6 === 0;
845 const r1 = major ? 39 : 42;
846 return { x1: RC + r1 * Math.sin(a), y1: RC - r1 * Math.cos(a), x2: RC + 45 * Math.sin(a), y2: RC - 45 * Math.cos(a), major };
847});
848const NOW_POS = knobAt(NOW.hour * 15);
849
850function HourRing({ from, to, pal }: { from: number; to: number; pal: Palette }) {
851 const start = useSharedValue(from * 15);
852 const span = useSharedValue(0);
853 useEffect(() => {
854 // Turn the shorter way round, so 23:00 to 00:00 steps forward instead of spinning back.
855 const target = from * 15;
856 const delta = ((((target - start.value) % 360) + 540) % 360) - 180;
857 start.value = withTiming(start.value + delta, { duration: 460, easing: Easing.out(Easing.cubic) });
858 span.value = withDelay(span.value === 0 ? 300 : 0, withTiming(spanHours(from, to) * 15, { duration: 560, easing: Easing.out(Easing.cubic) }));
859 }, [from, to, start, span]);
860 const arc = useAnimatedProps(() => ({ strokeDashoffset: RCIRC * (1 - span.value / 360) }));
861 const layer = useAnimatedStyle(() => ({ transform: [{ rotate: `${start.value - 90}deg` }] }));
862 const startKnob = useAnimatedStyle(() => knobAt(start.value));
863 const endKnob = useAnimatedStyle(() => knobAt(start.value + span.value));
864 const hours = spanHours(from, to);
865 return (
866 <View aria-label={`Quiet from ${hh(from)} to ${hh(to)}, ${hours} hours`} style={styles.ring}>
867 <Svg width={RING} height={RING} style={StyleSheet.absoluteFill}>
868 <Circle cx={RC} cy={RC} r={RR} stroke={pal.track} strokeWidth={RW} fill="none" />
869 {TICKS.map((t, i) => (
870 <Line key={i} x1={t.x1} y1={t.y1} x2={t.x2} y2={t.y2} stroke={t.major ? pal.muted : pal.faint} strokeWidth={t.major ? 1.6 : 1} strokeLinecap="round" />
871 ))}
872 {[0, 6, 12, 18].map((h) => {
873 const a = (h * 15 * Math.PI) / 180;
874 return (
875 <SvgText key={h} x={RC + 31 * Math.sin(a)} y={RC - 31 * Math.cos(a) + 3.5} fontSize={9.5} fontWeight="600" fill={pal.muted} textAnchor="middle">
876 {String(h)}
877 </SvgText>
878 );
879 })}
880 </Svg>
881 <Animated.View style={[StyleSheet.absoluteFill, layer]}>
882 <Svg width={RING} height={RING}>
883 <AnimatedCircle cx={RC} cy={RC} r={RR} stroke={ACCENT} strokeWidth={RW} strokeLinecap="round" fill="none" strokeDasharray={`${RCIRC} ${RCIRC}`} animatedProps={arc} />
884 </Svg>
885 </Animated.View>
886 <View style={[styles.nowDot, { left: NOW_POS.left + KNOB / 2 - 5, top: NOW_POS.top + KNOB / 2 - 5, backgroundColor: pal.fg, borderColor: pal.card }]} />
887 <Animated.View style={[styles.knob, { backgroundColor: pal.card }, startKnob]}>
888 <Moon size={11} color={pal.accentText} strokeWidth={2.6} />
889 </Animated.View>
890 <Animated.View style={[styles.knob, { backgroundColor: pal.card }, endKnob]}>
891 <Sun size={11} color={pal.accentText} strokeWidth={2.6} />
892 </Animated.View>
893 <View style={styles.ringCenter}>
894 <Text style={[styles.ringHours, { color: pal.fg }, styles.tabular]}>{hours} h</Text>
895 <Text style={[styles.ringLabel, { color: pal.muted }]}>quiet</Text>
896 </View>
897 </View>
898 );
899}
900
901function TimeField({ label, value, note, active, onPress, pal }: { label: string; value: string; note?: string; active: boolean; onPress: () => void; pal: Palette }) {
902 return (
903 <Pressable
904 role="radio"
905 aria-checked={active}
906 aria-label={`${label} ${value}`}
907 onPress={onPress}
908 style={[styles.timeField, { backgroundColor: active ? pal.accentSoft : pal.raised, borderColor: active ? pal.accentRing : pal.raised }]}
909 >
910 <Text style={[styles.timeLabel, { color: active ? pal.accentText : pal.muted }]}>{label}</Text>
911 <View style={styles.timeValueRow}>
912 <Text style={[styles.timeValue, { color: pal.fg }, styles.tabular]}>{value}</Text>
913 {note ? <Text style={[styles.timeNote, { color: pal.muted }]}>{note}</Text> : null}
914 </View>
915 </Pressable>
916 );
917}
918
919function QuietHours({ quiet, onToggle, onTime, pal }: { quiet: Prefs['quiet']; onToggle: (on: boolean) => void; onTime: (field: 'from' | 'to', hour: number) => void; pal: Palette }) {
920 const [edit, setEdit] = useState<'from' | 'to'>('from');
921 const hours = edit === 'from' ? FROM_HOURS : TO_HOURS;
922 const value = edit === 'from' ? quiet.from : quiet.to;
923 const inside = isQuietAt(quiet.from, quiet.to, NOW.hour);
924 return (
925 <View style={[styles.card, { backgroundColor: pal.card, boxShadow: pal.cardShadow }]}>
926 <View style={styles.settingHead}>
927 <IconTile icon={Moon} color={pal.accent} pal={pal} />
928 <View style={styles.fill}>
929 <Text style={[styles.catTitle, { color: pal.fg }]}>Quiet hours</Text>
930 <Text style={[styles.catDetail, { color: pal.muted }]}>{quiet.on ? `${hh(quiet.from)} to ${hh(quiet.to)}, every night` : 'Off'}</Text>
931 </View>
932 <Toggle on={quiet.on} label="Quiet hours" onChange={onToggle} pal={pal} />
933 </View>
934 <Collapse open={quiet.on}>
935 <View style={styles.quietBody}>
936 <View style={styles.quietRow}>
937 <HourRing from={quiet.from} to={quiet.to} pal={pal} />
938 <View role="radiogroup" aria-label="Edit start or end" style={styles.quietFields}>
939 <TimeField label="Starts" value={hh(quiet.from)} active={edit === 'from'} onPress={() => setEdit('from')} pal={pal} />
940 <TimeField label="Ends" value={hh(quiet.to)} note={quiet.to < quiet.from ? 'next day' : undefined} active={edit === 'to'} onPress={() => setEdit('to')} pal={pal} />
941 </View>
942 </View>
943 <Animated.View key={edit} entering={FadeIn.duration(220)} role="radiogroup" aria-label={edit === 'from' ? 'Start time' : 'End time'} style={styles.hourChips}>
944 {hours.map((h) => {
945 const on = h === value;
946 return (
947 <Pressable
948 key={h}
949 role="radio"
950 aria-checked={on}
951 aria-label={`${edit === 'from' ? 'Start' : 'End'} at ${hh(h)}`}
952 onPress={() => onTime(edit, h)}
953 style={({ pressed }) => [styles.hourChip, { backgroundColor: on ? ACCENT : pressed ? pal.pressed : pal.raised }]}
954 >
955 <Text style={[styles.hourChipLabel, { color: on ? ON_ACCENT : pal.fg }, styles.tabular]}>{hh(h)}</Text>
956 </Pressable>
957 );
958 })}
959 </Animated.View>
960 <View style={styles.quietNote}>
961 <View style={[styles.legendDot, { backgroundColor: pal.fg }]} />
962 <Text style={[styles.quietNoteText, { color: pal.muted }]}>
963 {inside ? `It is ${NOW.time}, inside quiet hours. Alerts wait until ${hh(quiet.to)}; Security still comes through.` : `It is ${NOW.time} now. Security alerts still come through at night.`}
964 </Text>
965 </View>
966 </View>
967 </Collapse>
968 </View>
969 );
970}
971
972// ─── Digest: frequency control with a sliding thumb ─────────────────────────
973
974function Segmented({ value, onChange, pal }: { value: Freq; onChange: (f: Freq) => void; pal: Palette }) {
975 const [w, setW] = useState(0);
976 const index = FREQS.findIndex((f) => f.id === value);
977 const x = useSharedValue(index);
978 useEffect(() => {
979 x.value = withSpring(index, SPRING);
980 }, [index, x]);
981 const seg = w > 0 ? (w - 6) / FREQS.length : 0;
982 const thumb = useAnimatedStyle(() => ({ width: seg, transform: [{ translateX: x.value * seg }] }));
983 return (
984 <View role="radiogroup" aria-label="Digest frequency" onLayout={(e: LayoutChangeEvent) => setW(e.nativeEvent.layout.width)} style={[styles.segmented, { backgroundColor: pal.raised }]}>
985 {w > 0 ? <Animated.View style={[styles.segThumb, { backgroundColor: pal.segThumb, boxShadow: pal.cardShadow }, thumb]} /> : null}
986 {FREQS.map((f) => (
987 <Pressable key={f.id} role="radio" aria-checked={f.id === value} aria-label={`${f.label} digest`} onPress={() => onChange(f.id)} style={styles.segItem}>
988 <Text style={[styles.segLabel, { color: f.id === value ? pal.fg : pal.muted }]}>{f.label}</Text>
989 </Pressable>
990 ))}
991 </View>
992 );
993}
994
995function DigestCard({ prefs, onToggle, onFreq, pal }: { prefs: Prefs; onToggle: (on: boolean) => void; onFreq: (f: Freq) => void; pal: Palette }) {
996 const f = FREQS.find((x) => x.id === prefs.digest.freq) ?? FREQS[0];
997 const bundled = CATEGORIES.filter((c) => c.lowPriority && prefs.cats[c.id].on).map((c) => c.title);
998 return (
999 <View style={[styles.card, { backgroundColor: pal.card, boxShadow: pal.cardShadow }]}>
1000 <View style={styles.settingHead}>
1001 <IconTile icon={Layers} color={pal.accent} pal={pal} />
1002 <View style={styles.fill}>
1003 <Text style={[styles.catTitle, { color: pal.fg }]}>Digest</Text>
1004 <Text style={[styles.catDetail, { color: pal.muted }]}>{`Bundle low-priority updates into one summary ${f.when}`}</Text>
1005 </View>
1006 <Toggle on={prefs.digest.on} label="Digest" onChange={onToggle} pal={pal} />
1007 </View>
1008 <Collapse open={prefs.digest.on}>
1009 <View style={styles.digestBody}>
1010 <Segmented value={prefs.digest.freq} onChange={onFreq} pal={pal} />
1011 <View style={[styles.digestNext, { backgroundColor: pal.raised }]}>
1012 <View style={styles.stack}>
1013 <View style={[styles.stackCard, styles.stackBack, { backgroundColor: pal.accentRing }]} />
1014 <View style={[styles.stackCard, styles.stackMid, { backgroundColor: pal.accentRing }]} />
1015 <View style={[styles.stackCard, { backgroundColor: pal.accent }]}>
1016 <Text style={[styles.stackCount, styles.tabular]}>{f.waiting}</Text>
1017 </View>
1018 </View>
1019 <View style={styles.fill}>
1020 <Text style={[styles.digestNextTitle, { color: pal.fg }]}>Next summary · {f.next}</Text>
1021 <Text style={[styles.digestNextSub, { color: pal.muted }]}>
1022 {bundled.length ? `${f.waiting} updates waiting from ${listing(bundled)}` : 'Nothing to bundle. Turn on Price drops or Product news.'}
1023 </Text>
1024 </View>
1025 </View>
1026 </View>
1027 </Collapse>
1028 </View>
1029 );
1030}
1031
1032// ─── Sound and vibration sheet ──────────────────────────────────────────────
1033
1034function EqBar({ i, color }: { i: number; color: string }) {
1035 const h = useSharedValue(0.3);
1036 useEffect(() => {
1037 h.value = withDelay(i * 60, withRepeat(withSequence(withTiming(1, { duration: 170 + i * 40 }), withTiming(0.25, { duration: 190 + i * 30 })), -1, true));
1038 return () => cancelAnimation(h);
1039 }, [h, i]);
1040 const style = useAnimatedStyle(() => ({ height: 3 + h.value * 11 }));
1041 return <Animated.View style={[styles.eqBar, { backgroundColor: color }, style]} />;
1042}
1043
1044function SoundRow({ sound, selected, playing, first, onPress, pal }: { sound: (typeof SOUNDS)[number]; selected: boolean; playing: boolean; first: boolean; onPress: () => void; pal: Palette }) {
1045 const dot = useSharedValue(selected ? 1 : 0);
1046 useEffect(() => {
1047 dot.value = withSpring(selected ? 1 : 0, POP);
1048 }, [selected, dot]);
1049 const dotStyle = useAnimatedStyle(() => ({ transform: [{ scale: dot.value }] }));
1050 const silent = sound.length === 0;
1051 return (
1052 <Pressable role="radio" aria-checked={selected} aria-label={silent ? 'No sound' : `Sound: ${sound.name}`} onPress={onPress} style={({ pressed }) => [styles.soundRow, pressed && { backgroundColor: pal.pressed }]}>
1053 {!first ? <View style={[styles.soundRule, { backgroundColor: pal.line }]} /> : null}
1054 <View style={[styles.radio, { borderColor: selected ? ACCENT : pal.faint }]}>
1055 <Animated.View style={[styles.radioDot, dotStyle]} />
1056 </View>
1057 <View style={styles.fill}>
1058 <Text style={[styles.soundName, { color: pal.fg }]}>{sound.name}</Text>
1059 <Text style={[styles.soundMeta, { color: playing ? pal.accentText : pal.muted }]}>{silent ? 'Silent, vibration only' : playing ? 'Playing' : `${sound.length.toFixed(1)} s`}</Text>
1060 </View>
1061 <View style={[styles.playBubble, { backgroundColor: playing ? pal.accentSoft : pal.card }]}>
1062 {silent ? (
1063 <VolumeX size={15} color={pal.muted} strokeWidth={2.2} />
1064 ) : playing ? (
1065 <View style={styles.eq}>
1066 {[0, 1, 2, 3].map((i) => (
1067 <EqBar key={i} i={i} color={pal.accent} />
1068 ))}
1069 </View>
1070 ) : (
1071 <Play size={14} color={pal.fg} fill={pal.fg} strokeWidth={2} />
1072 )}
1073 </View>
1074 </Pressable>
1075 );
1076}
1077
1078const VIBE_T = 700;
1079const STRIP_W = 76;
1080
1081function PulseBars({ pulses, color }: { pulses: Pulse[]; color: string }) {
1082 if (!pulses.length) return <View style={[styles.pulseFlat, { backgroundColor: color }]} />;
1083 return (
1084 <View style={styles.pulses}>
1085 {pulses.map(([start, dur]) => (
1086 <View key={start} style={[styles.pulse, { left: (start / VIBE_T) * STRIP_W, width: Math.max(4, (dur / VIBE_T) * STRIP_W), backgroundColor: color }]} />
1087 ))}
1088 </View>
1089 );
1090}
1091
1092/** One loop of the buzz: the phone rocks during each pulse and rests in the gaps. */
1093function buzzCycle(pulses: Pulse[]) {
1094 const steps: number[] = [];
1095 let cursor = 0;
1096 for (const [start, dur] of pulses) {
1097 if (start > cursor) steps.push(withTiming(0, { duration: start - cursor }));
1098 const n = Math.max(2, Math.round(dur / 32));
1099 for (let k = 0; k < n; k++) steps.push(withTiming(k % 2 === 0 ? 1 : -1, { duration: dur / n }));
1100 cursor = start + dur;
1101 }
1102 steps.push(withTiming(0, { duration: Math.max(16, VIBE_T - cursor) }));
1103 return steps;
1104}
1105
1106function VibeCard({ vibe, selected, nonce, onPress, pal }: { vibe: (typeof VIBES)[number]; selected: boolean; nonce: number; onPress: () => void; pal: Palette }) {
1107 const sweep = useSharedValue(0);
1108 useEffect(() => {
1109 if (!selected || !nonce || !vibe.pulses.length) return;
1110 sweep.value = 0;
1111 sweep.value = withSequence(
1112 withTiming(1, { duration: VIBE_T, easing: Easing.linear }),
1113 withTiming(0, { duration: 0 }),
1114 withTiming(1, { duration: VIBE_T, easing: Easing.linear }),
1115 withDelay(260, withTiming(0, { duration: 220 }))
1116 );
1117 }, [selected, nonce, vibe.pulses.length, sweep]);
1118 const fill = useAnimatedStyle(() => ({ width: sweep.value * STRIP_W }));
1119 return (
1120 <Pressable
1121 role="radio"
1122 aria-checked={selected}
1123 aria-label={`Vibration: ${vibe.name}`}
1124 onPress={onPress}
1125 style={[styles.vibe, { backgroundColor: selected ? pal.accentSoft : pal.raised, borderColor: selected ? pal.accentRing : pal.raised }]}
1126 >
1127 <View style={styles.vibeTop}>
1128 <Text style={[styles.vibeName, { color: selected ? pal.accentText : pal.fg }]}>{vibe.name}</Text>
1129 {selected ? <Check size={14} color={pal.accentText} strokeWidth={3} /> : null}
1130 </View>
1131 <View style={styles.strip}>
1132 <PulseBars pulses={vibe.pulses} color={pal.faint} />
1133 <Animated.View style={[styles.stripFill, fill]}>
1134 <PulseBars pulses={vibe.pulses} color={ACCENT} />
1135 </Animated.View>
1136 </View>
1137 </Pressable>
1138 );
1139}
1140
1141function BuzzPhone({ pulses, nonce, pal }: { pulses: Pulse[]; nonce: number; pal: Palette }) {
1142 const v = useSharedValue(0);
1143 useEffect(() => {
1144 if (!nonce || !pulses.length) return;
1145 v.value = withSequence(...buzzCycle(pulses), ...buzzCycle(pulses));
1146 }, [nonce, pulses, v]);
1147 const phone = useAnimatedStyle(() => ({ transform: [{ translateX: v.value * 2.2 }, { rotate: `${v.value * 6}deg` }] }));
1148 const waves = useAnimatedStyle(() => ({ opacity: Math.min(1, Math.abs(v.value) * 1.4) }));
1149 return (
1150 <View style={styles.buzz}>
1151 <Animated.View style={[styles.buzzWave, { backgroundColor: pal.accent }, waves]} />
1152 <Animated.View style={[styles.buzzPhone, { backgroundColor: pal.accentSoft }, phone]}>
1153 <Smartphone size={16} color={pal.accentText} strokeWidth={2.3} />
1154 </Animated.View>
1155 <Animated.View style={[styles.buzzWave, { backgroundColor: pal.accent }, waves]} />
1156 </View>
1157 );
1158}
1159
1160function SoundSheet({
1161 open,
1162 sound,
1163 vibe,
1164 onSound,
1165 onVibe,
1166 onClose,
1167 width,
1168 bottom,
1169 pal,
1170}: {
1171 open: boolean;
1172 sound: string;
1173 vibe: string;
1174 onSound: (id: string) => void;
1175 onVibe: (id: string) => void;
1176 onClose: () => void;
1177 width: number;
1178 bottom: number;
1179 pal: Palette;
1180}) {
1181 const { height } = useWindowDimensions();
1182 const t = useSharedValue(0);
1183 const drag = useSharedValue(0);
1184 const [playing, setPlaying] = useState<string | null>(null);
1185 const [nonce, setNonce] = useState(0);
1186 const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
1187 const closeRef = useRef(onClose);
1188 useEffect(() => {
1189 closeRef.current = onClose;
1190 }, [onClose]);
1191 useEffect(() => {
1192 if (open) drag.value = 0;
1193 t.value = open ? withSpring(1, { damping: 22, stiffness: 240, mass: 0.9 }) : withTiming(0, { duration: 240, easing: Easing.in(Easing.cubic) });
1194 if (!open) setPlaying(null);
1195 }, [open, t, drag]);
1196 useEffect(() => () => {
1197 if (timer.current) clearTimeout(timer.current);
1198 }, []);
1199 const pan = useMemo(
1200 () =>
1201 PanResponder.create({
1202 onMoveShouldSetPanResponder: (_e, g) => g.dy > 6 && Math.abs(g.dy) > Math.abs(g.dx),
1203 onPanResponderMove: (_e, g) => {
1204 drag.value = Math.max(0, g.dy);
1205 },
1206 onPanResponderRelease: (_e, g) => {
1207 if (g.dy > 110 || g.vy > 0.9) closeRef.current();
1208 else drag.value = withSpring(0, SPRING);
1209 },
1210 onPanResponderTerminate: () => {
1211 drag.value = withSpring(0, SPRING);
1212 },
1213 }),
1214 [drag]
1215 );
1216 const reach = height + 40;
1217 const sheetStyle = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - t.value) * reach + drag.value }] }));
1218 const backdrop = useAnimatedStyle(() => ({ opacity: Math.min(1, Math.max(0, t.value)) * (1 - Math.min(1, drag.value / 500)) }));
1219
1220 const play = (id: string) => {
1221 onSound(id);
1222 const s = SOUNDS.find((x) => x.id === id);
1223 if (timer.current) clearTimeout(timer.current);
1224 if (!s || !s.length) {
1225 setPlaying(null);
1226 return;
1227 }
1228 // Replace with your audio player (expo-audio) playing the sound file.
1229 setPlaying(id);
1230 timer.current = setTimeout(() => setPlaying(null), Math.max(900, s.length * 1000));
1231 };
1232 const pick = (id: string) => {
1233 onVibe(id);
1234 setNonce((n) => n + 1);
1235 };
1236 const current = VIBES.find((v) => v.id === vibe) ?? VIBES[0];
1237
1238 return (
1239 <View style={[StyleSheet.absoluteFill, { pointerEvents: open ? 'auto' : 'none' }]}>
1240 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: pal.backdrop }, backdrop]}>
1241 <Pressable role="button" aria-label="Close sound and vibration" onPress={onClose} style={styles.fill} />
1242 </Animated.View>
1243 <Animated.View role="dialog" aria-label="Sound and vibration" aria-hidden={!open} style={[styles.sheet, { width, paddingBottom: bottom + 16, backgroundColor: pal.sheet }, sheetStyle]}>
1244 <View {...pan.panHandlers}>
1245 <View style={styles.grab}>
1246 <View style={[styles.grabber, { backgroundColor: pal.faint }]} />
1247 </View>
1248 <View style={styles.sheetHead}>
1249 <View style={styles.fill}>
1250 <Text role="heading" style={[styles.sheetTitle, { color: pal.fg }]}>
1251 Sound and vibration
1252 </Text>
1253 <Text style={[styles.sheetSub, { color: pal.muted }]}>For Messages, Mentions and Orders. Tap a sound to hear it.</Text>
1254 </View>
1255 <Tap label="Close" onPress={onClose} to={0.9} style={[styles.sheetClose, { backgroundColor: pal.raised }]}>
1256 <X size={17} color={pal.fg} strokeWidth={2.4} />
1257 </Tap>
1258 </View>
1259 </View>
1260
1261 <Text style={[styles.sheetLabel, { color: pal.muted }]}>SOUND</Text>
1262 <View role="radiogroup" aria-label="Sound" style={[styles.soundList, { backgroundColor: pal.raised }]}>
1263 {SOUNDS.map((s, i) => (
1264 <SoundRow key={s.id} sound={s} first={i === 0} selected={s.id === sound} playing={playing === s.id} onPress={() => play(s.id)} pal={pal} />
1265 ))}
1266 </View>
1267
1268 <View style={styles.vibeHead}>
1269 <Text style={[styles.sheetLabel, styles.vibeLabel, { color: pal.muted }]}>VIBRATION</Text>
1270 <BuzzPhone pulses={current.pulses} nonce={nonce} pal={pal} />
1271 </View>
1272 <ScrollView horizontal showsHorizontalScrollIndicator={false} role="radiogroup" aria-label="Vibration pattern" contentContainerStyle={styles.vibes}>
1273 {VIBES.map((v) => (
1274 <VibeCard key={v.id} vibe={v} selected={v.id === vibe} nonce={nonce} onPress={() => pick(v.id)} pal={pal} />
1275 ))}
1276 </ScrollView>
1277
1278 <Pressable role="button" aria-label="Done" onPress={onClose} style={({ pressed }) => [styles.done, { backgroundColor: pressed ? ACCENT_PRESSED : ACCENT }]}>
1279 <Text style={styles.doneLabel}>Done</Text>
1280 </Pressable>
1281 </Animated.View>
1282 </View>
1283 );
1284}
1285
1286// ─── Menus: Pause durations and the overflow ────────────────────────────────
1287
1288function Popover({ open, onClose, top, right, width, label, children, pal }: { open: boolean; onClose: () => void; top: number; right: number; width: number; label: string; children: ReactNode; pal: Palette }) {
1289 const t = useSharedValue(0);
1290 useEffect(() => {
1291 t.value = open ? withSpring(1, POP) : withTiming(0, { duration: 140 });
1292 }, [open, t]);
1293 const card = useAnimatedStyle(() => ({
1294 opacity: Math.min(1, Math.max(0, t.value * 1.5)),
1295 transform: [{ translateY: (1 - t.value) * -10 }, { scale: 0.92 + 0.08 * t.value }],
1296 }));
1297 return (
1298 <View style={[StyleSheet.absoluteFill, { pointerEvents: open ? 'auto' : 'none' }]}>
1299 <Pressable role="button" aria-label="Close menu" onPress={onClose} style={StyleSheet.absoluteFill} />
1300 <Animated.View role="menu" aria-label={label} aria-hidden={!open} style={[styles.popover, { top, right, width, backgroundColor: pal.menu, boxShadow: pal.menuShadow }, card]}>
1301 {children}
1302 </Animated.View>
1303 </View>
1304 );
1305}
1306
1307function MenuItem({ icon: Icon, label, sub, checked, accent, onPress, pal }: { icon: LucideIcon; label: string; sub?: string; checked?: boolean; accent?: boolean; onPress: () => void; pal: Palette }) {
1308 return (
1309 <Pressable role="menuitem" aria-label={label} aria-checked={checked} onPress={onPress} style={({ pressed }) => [styles.menuItem, sub ? styles.menuItemTall : null, pressed && { backgroundColor: pal.pressed }]}>
1310 <Icon size={17} color={accent ? pal.accentText : pal.fg} strokeWidth={2.2} />
1311 <View style={styles.fill}>
1312 <Text numberOfLines={1} style={[styles.menuLabel, { color: accent ? pal.accentText : pal.fg }]}>
1313 {label}
1314 </Text>
1315 {sub ? <Text numberOfLines={1} style={[styles.menuSub, { color: pal.muted }]}>{sub}</Text> : null}
1316 </View>
1317 {checked ? <Check size={15} color={pal.accentText} strokeWidth={3} /> : null}
1318 </Pressable>
1319 );
1320}
1321
1322// ─── Screen ─────────────────────────────────────────────────────────────────
1323
1324type Toast = { n: number; detail: string; undo: Prefs | null };
1325
1326export default function NotificationSettingsScreen() {
1327 const pal = usePalette();
1328 const insets = useSafeAreaInsets();
1329 const { width } = useWindowDimensions();
1330 const column = Math.min(width, COLUMN);
1331 const side = (width - column) / 2;
1332 const scroll = useAnimatedRef<Animated.ScrollView>();
1333 const [prefs, setPrefs] = useState<Prefs>(DEFAULTS);
1334 const [selected, setSelected] = useState<CatId>('messages');
1335 const [pause, setPause] = useState<PauseState | null>(null);
1336 const [clock, setClock] = useState(0);
1337 const [blocked, setBlocked] = useState(false);
1338 const [fixing, setFixing] = useState(false);
1339 const [menu, setMenu] = useState<'pause' | 'more' | null>(null);
1340 const [sheet, setSheet] = useState(false);
1341 const [replay, setReplay] = useState(0);
1342 const [booted, setBooted] = useState(false);
1343 const [toast, setToast] = useState<Toast>({ n: 0, detail: '', undo: null });
1344 const [toastOn, setToastOn] = useState(false);
1345 const lastPause = useRef<PauseState | null>(null);
1346 const fixTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
1347 if (pause) lastPause.current = pause;
1348
1349 useEffect(() => {
1350 const id = setTimeout(() => setBooted(true), 1200);
1351 return () => {
1352 clearTimeout(id);
1353 if (fixTimer.current) clearTimeout(fixTimer.current);
1354 };
1355 }, []);
1356
1357 // Header: the small title and a hairline fade in once the large title scrolls away.
1358 const y = useSharedValue(0);
1359 const onScroll = useAnimatedScrollHandler((e) => {
1360 y.value = e.contentOffset.y;
1361 });
1362 const smallTitle = useAnimatedStyle(() => ({ opacity: interpolate(y.value, [36, 60], [0, 1], 'clamp'), transform: [{ translateY: interpolate(y.value, [36, 60], [6, 0], 'clamp') }] }));
1363 const rule = useAnimatedStyle(() => ({ opacity: interpolate(y.value, [0, 16], [0, 1], 'clamp') }));
1364
1365 // "Changes saved": pops up after each change and leaves on its own.
1366 const pop = useSharedValue(0);
1367 useEffect(() => {
1368 if (!toast.n) return;
1369 setToastOn(true);
1370 pop.value = withTiming(1, { duration: 280, easing: Easing.out(Easing.back(1.6)) });
1371 const id = setTimeout(() => {
1372 pop.value = withTiming(0, { duration: 220 });
1373 setToastOn(false);
1374 }, 2600);
1375 return () => clearTimeout(id);
1376 }, [toast.n, pop]);
1377 const toastTop = sheet;
1378 const toastStyle = useAnimatedStyle(() => ({
1379 opacity: Math.min(1, Math.max(0, pop.value)),
1380 transform: [{ translateY: (1 - pop.value) * (toastTop ? -22 : 22) }, { scale: 0.94 + pop.value * 0.06 }],
1381 }));
1382
1383 const say = (detail: string, undo: Prefs | null) => setToast((s) => ({ n: s.n + 1, detail, undo }));
1384 // Replace with a write to your settings API; the toast confirms each change, so there is no Save button.
1385 const commit = (next: Prefs, detail: string) => {
1386 say(detail, prefs);
1387 setPrefs(next);
1388 };
1389 const setCat = (id: CatId, pref: CatPref, detail: string) => commit({ ...prefs, cats: { ...prefs.cats, [id]: pref } }, detail);
1390
1391 const toggleCat = (cat: Category, on: boolean) => {
1392 const cur = prefs.cats[cat.id];
1393 const ch = on && !Object.values(cur.ch).some(Boolean) ? { ...cur.ch, push: true } : cur.ch;
1394 setSelected(cat.id);
1395 setCat(cat.id, { on, ch }, `${cat.title} ${on ? 'on' : 'off'}`);
1396 };
1397 const toggleChip = (cat: Category, channel: Channel) => {
1398 const cur = prefs.cats[cat.id];
1399 const ch = { ...cur.ch, [channel]: !cur.ch[channel] };
1400 const any = Object.values(ch).some(Boolean);
1401 const label = CHANNELS.find((c) => c.id === channel)?.label ?? channel;
1402 setSelected(cat.id);
1403 setCat(cat.id, { on: any, ch }, any ? `${label} ${ch[channel] ? 'on' : 'off'} for ${cat.title}` : `${cat.title} off, no channels left`);
1404 };
1405
1406 // Pause: a live countdown while it runs, resuming by itself when time is up.
1407 const opt = pause ? (PAUSES.find((p) => p.id === pause.id) ?? PAUSES[0]) : null;
1408 const remaining = pause && opt?.ms ? Math.max(0, opt.ms - (clock - pause.at)) : null;
1409 useEffect(() => {
1410 if (!pause) return;
1411 const id = setInterval(() => setClock(Date.now()), 1000);
1412 return () => clearInterval(id);
1413 }, [pause]);
1414 useEffect(() => {
1415 if (remaining === 0) setPause(null);
1416 }, [remaining]);
1417 const startPause = (id: PauseId) => {
1418 const at = Date.now();
1419 const o = PAUSES.find((p) => p.id === id) ?? PAUSES[0];
1420 setClock(at);
1421 setPause({ id, at });
1422 setMenu(null);
1423 say(`Paused ${o.until}`, null);
1424 };
1425 const resume = () => {
1426 setPause(null);
1427 setMenu(null);
1428 say('Notifications resumed', null);
1429 };
1430 const fixPermission = () => {
1431 // Replace with Linking.openSettings(), then re-check expo-notifications getPermissionsAsync() when the app returns.
1432 setFixing(true);
1433 fixTimer.current = setTimeout(() => {
1434 setFixing(false);
1435 setBlocked(false);
1436 say('Push allowed on this phone', null);
1437 }, 1100);
1438 };
1439 const undo = () => {
1440 if (!toast.undo) return;
1441 setPrefs(toast.undo);
1442 say('Last change undone', null);
1443 };
1444
1445 const cat = CATEGORIES.find((c) => c.id === selected) ?? CATEGORIES[0];
1446 const preview = previewFor(cat, prefs, pause, blocked);
1447 const freq = FREQS.find((f) => f.id === prefs.digest.freq) ?? FREQS[0];
1448 const quietNow = prefs.quiet.on && isQuietAt(prefs.quiet.from, prefs.quiet.to, NOW.hour);
1449 const breaksThrough = !!cat.locked && prefs.cats[cat.id].ch.push && !blocked && (!!pause || quietNow);
1450 const onCount = CATEGORIES.filter((c) => prefs.cats[c.id].on).length;
1451 const left = remaining !== null ? formatLeft(remaining) : null;
1452 const shownPause = pause ?? lastPause.current;
1453 const frac = remaining !== null && opt?.ms ? remaining / opt.ms : 1;
1454 const status = blocked ? 'Push is blocked in phone Settings' : pause ? `Paused · ${left ?? 'until you resume'}` : `Delivering · ${onCount} of ${CATEGORIES.length} categories on`;
1455 const soundName = SOUNDS.find((s) => s.id === prefs.sound)?.name ?? 'Pebble';
1456 const vibeName = VIBES.find((v) => v.id === prefs.vibe)?.name ?? 'Double';
1457 const headerH = insets.top + 54;
1458
1459 return (
1460 <View style={[styles.screen, { backgroundColor: pal.bg }]}>
1461 <View style={[styles.column, { width: column }]}>
1462 {/* Header: opaque, under the status bar, with the master Pause control */}
1463 <View style={[styles.header, { paddingTop: insets.top, backgroundColor: pal.bg }]}>
1464 <View style={styles.headerRow}>
1465 <Tap label="Back" to={0.9} style={[styles.iconButton, { backgroundColor: pal.card, boxShadow: pal.cardShadow }]}>
1466 <ChevronLeft size={21} color={pal.fg} strokeWidth={2.2} />
1467 </Tap>
1468 <Animated.Text numberOfLines={1} style={[styles.headerTitle, { color: pal.fg }, smallTitle]}>
1469 Notifications
1470 </Animated.Text>
1471 <View style={styles.headerActions}>
1472 <Tap
1473 label={pause ? 'Paused. Change or resume' : 'Pause all notifications'}
1474 onPress={() => setMenu('pause')}
1475 style={[styles.pausePill, pause ? styles.pausePillOn : { backgroundColor: pal.card, boxShadow: pal.cardShadow }]}
1476 >
1477 <BellOff size={15} color={pause ? ON_ACCENT : pal.fg} strokeWidth={2.3} />
1478 <Text style={[styles.pauseLabel, { color: pause ? ON_ACCENT : pal.fg }]}>{pause ? 'Paused' : 'Pause all'}</Text>
1479 </Tap>
1480 <Tap label="More options" to={0.9} onPress={() => setMenu('more')} style={[styles.iconButton, { backgroundColor: pal.card, boxShadow: pal.cardShadow }]}>
1481 <Ellipsis size={19} color={pal.fg} strokeWidth={2.4} />
1482 </Tap>
1483 </View>
1484 </View>
1485 <Animated.View style={[styles.headerRule, { backgroundColor: pal.border }, rule]} />
1486 </View>
1487
1488 <Animated.ScrollView ref={scroll} onScroll={onScroll} scrollEventThrottle={16} showsVerticalScrollIndicator={false} contentContainerStyle={[styles.content, { paddingBottom: insets.bottom + 96 }]}>
1489 <Animated.View entering={FadeIn.duration(320)} style={styles.titleBlock}>
1490 <Text role="heading" style={[styles.largeTitle, { color: pal.fg }]}>
1491 Notifications
1492 </Text>
1493 <View style={styles.statusRow}>
1494 <View style={[styles.statusDot, { backgroundColor: blocked || pause ? pal.hold : LIVE }]} />
1495 <Text numberOfLines={1} style={[styles.statusText, { color: pal.muted }, styles.tabular]}>
1496 {status}
1497 </Text>
1498 </View>
1499 </Animated.View>
1500
1501 <Collapse open={blocked}>
1502 <View style={styles.topCardSlot}>
1503 <PermissionCard busy={fixing} onFix={fixPermission} pal={pal} />
1504 </View>
1505 </Collapse>
1506
1507 <Collapse open={!!pause}>
1508 <View style={styles.topCardSlot}>{shownPause ? <PauseBanner pause={shownPause} left={left} frac={frac} onResume={resume} pal={pal} /> : null}</View>
1509 </Collapse>
1510
1511 {/* Live preview of the selected category on a drawn lock screen */}
1512 <Animated.View entering={FadeInDown.delay(100).duration(440)}>
1513 <LockPreview cat={cat} preview={preview} digest={freq} replay={replay} booted={booted} pal={pal} />
1514 <View style={styles.caption}>
1515 <Text numberOfLines={1} style={[styles.captionText, { color: pal.muted }]}>
1516 {breaksThrough ? 'Comes through even now · ' : 'Previewing '}
1517 <Text style={[styles.captionStrong, { color: pal.fg }]}>{cat.title}</Text>
1518 </Text>
1519 <View style={styles.captionIcons}>
1520 {CHANNELS.map((ch) => {
1521 const on = prefs.cats[cat.id].on && prefs.cats[cat.id].ch[ch.id];
1522 const Icon = ch.icon;
1523 return (
1524 <View key={ch.id} aria-label={`${ch.label} ${on ? 'on' : 'off'}`} style={[styles.captionDot, { backgroundColor: on ? pal.accentSoft : pal.raised }]}>
1525 <Icon size={12} color={on ? pal.accentText : pal.faint} strokeWidth={2.3} />
1526 </View>
1527 );
1528 })}
1529 </View>
1530 </View>
1531 </Animated.View>
1532
1533 {/* Categories */}
1534 <Animated.View entering={FadeIn.delay(240).duration(360)}>
1535 <SectionHead title="CATEGORIES" aside="Tap a card to preview it" pal={pal} />
1536 </Animated.View>
1537 {CATEGORIES.map((c, i) => (
1538 <CategoryCard
1539 key={c.id}
1540 cat={c}
1541 pref={prefs.cats[c.id]}
1542 index={i}
1543 selected={c.id === selected}
1544 inDigest={!!c.lowPriority && prefs.digest.on && prefs.cats[c.id].on}
1545 blocked={blocked}
1546 paused={!!pause}
1547 onSelect={() => setSelected(c.id)}
1548 onToggle={(on) => toggleCat(c, on)}
1549 onChip={(ch) => toggleChip(c, ch)}
1550 pal={pal}
1551 />
1552 ))}
1553 <Text style={[styles.footnote, { color: pal.muted }]}>
1554 Email goes to {USER.email} and SMS to {USER.phone}. Change them in Account.
1555 </Text>
1556
1557 {/* Delivery */}
1558 <SectionHead title="DELIVERY" pal={pal} />
1559 <QuietHours
1560 quiet={prefs.quiet}
1561 onToggle={(on) => commit({ ...prefs, quiet: { ...prefs.quiet, on } }, on ? `Quiet hours on, ${hh(prefs.quiet.from)} to ${hh(prefs.quiet.to)}` : 'Quiet hours off')}
1562 onTime={(field, hour) => {
1563 const q = { ...prefs.quiet, [field]: hour };
1564 if (q[field] !== prefs.quiet[field]) commit({ ...prefs, quiet: q }, `Quiet hours now ${hh(q.from)} to ${hh(q.to)}`);
1565 }}
1566 pal={pal}
1567 />
1568 <DigestCard
1569 prefs={prefs}
1570 onToggle={(on) => commit({ ...prefs, digest: { ...prefs.digest, on } }, on ? `${freq.label} digest on` : 'Digest off')}
1571 onFreq={(f) => {
1572 if (f === prefs.digest.freq) return;
1573 const next = FREQS.find((x) => x.id === f) ?? FREQS[0];
1574 commit({ ...prefs, digest: { ...prefs.digest, freq: f } }, `Digest ${next.when}`);
1575 }}
1576 pal={pal}
1577 />
1578 <Tap label={`Sound and vibration, ${soundName}, ${vibeName}`} to={0.98} onPress={() => setSheet(true)} style={[styles.card, styles.linkRow, { backgroundColor: pal.card, boxShadow: pal.cardShadow }]}>
1579 <IconTile icon={Volume2} color={pal.accent} pal={pal} />
1580 <View style={styles.fill}>
1581 <Text style={[styles.catTitle, { color: pal.fg }]}>Sound and vibration</Text>
1582 <Text style={[styles.catDetail, { color: pal.muted }]}>
1583 {soundName} · {vibeName}
1584 </Text>
1585 </View>
1586 <ChevronRight size={18} color={pal.faint} strokeWidth={2.4} />
1587 </Tap>
1588
1589 <Tap label="Reset to defaults" onPress={() => commit(DEFAULTS, 'Defaults restored')} style={styles.reset}>
1590 <RotateCcw size={14} color={pal.muted} strokeWidth={2.4} />
1591 <Text style={[styles.resetLabel, { color: pal.muted }]}>Reset to defaults</Text>
1592 </Tap>
1593 </Animated.ScrollView>
1594 </View>
1595
1596 {/* Pause durations, anchored under the header pill */}
1597 <Popover open={menu === 'pause'} onClose={() => setMenu(null)} top={headerH - 4} right={side + 58} width={268} label="Pause all notifications" pal={pal}>
1598 <Text style={[styles.menuHead, { color: pal.muted }]}>PAUSE ALL NOTIFICATIONS</Text>
1599 {pause ? <MenuItem icon={BellRing} label="Resume now" accent onPress={resume} pal={pal} /> : null}
1600 {PAUSES.map((p) => (
1601 <MenuItem key={p.id} icon={p.icon} label={p.label} sub={pause?.id === p.id ? 'Running now' : p.hint} checked={pause?.id === p.id} onPress={() => startPause(p.id)} pal={pal} />
1602 ))}
1603 <View style={[styles.menuRule, { backgroundColor: pal.line }]} />
1604 <View style={styles.menuFootRow}>
1605 <ShieldCheck size={13} color={pal.muted} strokeWidth={2.3} />
1606 <Text style={[styles.menuFoot, { color: pal.muted }]}>Security alerts still come through.</Text>
1607 </View>
1608 </Popover>
1609
1610 {/* Overflow */}
1611 <Popover open={menu === 'more'} onClose={() => setMenu(null)} top={headerH - 4} right={side + 14} width={268} label="More options" pal={pal}>
1612 <MenuItem
1613 icon={BellRing}
1614 label="Send a test notification"
1615 onPress={() => {
1616 setMenu(null);
1617 scroll.current?.scrollTo({ y: 0, animated: true });
1618 setReplay((r) => r + 1);
1619 }}
1620 pal={pal}
1621 />
1622 <MenuItem
1623 icon={Smartphone}
1624 label="Simulate permission off"
1625 checked={blocked}
1626 onPress={() => {
1627 setMenu(null);
1628 setBlocked((b) => !b);
1629 scroll.current?.scrollTo({ y: 0, animated: true });
1630 }}
1631 pal={pal}
1632 />
1633 <View style={[styles.menuRule, { backgroundColor: pal.line }]} />
1634 <MenuItem
1635 icon={RotateCcw}
1636 label="Reset to defaults"
1637 onPress={() => {
1638 setMenu(null);
1639 commit(DEFAULTS, 'Defaults restored');
1640 }}
1641 pal={pal}
1642 />
1643 </Popover>
1644
1645 <SoundSheet
1646 open={sheet}
1647 sound={prefs.sound}
1648 vibe={prefs.vibe}
1649 onSound={(id) => {
1650 if (id !== prefs.sound) commit({ ...prefs, sound: id }, `Sound: ${SOUNDS.find((s) => s.id === id)?.name ?? id}`);
1651 }}
1652 onVibe={(id) => {
1653 if (id !== prefs.vibe) commit({ ...prefs, vibe: id }, `Vibration: ${VIBES.find((v) => v.id === id)?.name ?? id}`);
1654 }}
1655 onClose={() => setSheet(false)}
1656 width={column}
1657 bottom={insets.bottom}
1658 pal={pal}
1659 />
1660
1661 {/* Changes saved: at the bottom, or at the top while the sheet covers the bottom */}
1662 <View role="status" aria-live="polite" style={[styles.toastWrap, toastTop ? { top: insets.top + 10 } : { bottom: insets.bottom + 18 }]}>
1663 <Animated.View style={[styles.toast, { backgroundColor: pal.toast, maxWidth: column - 32, pointerEvents: toastOn ? 'auto' : 'none' }, toastStyle]}>
1664 <View style={styles.toastCheck}>
1665 <Check size={12} color="#FFFFFF" strokeWidth={3.4} />
1666 </View>
1667 <View style={styles.toastText}>
1668 <Text style={styles.toastTitle}>Changes saved</Text>
1669 <Text numberOfLines={1} style={[styles.toastDetail, { color: pal.toastMuted }]}>
1670 {toast.detail}
1671 </Text>
1672 </View>
1673 {toast.undo ? (
1674 <Pressable role="button" aria-label="Undo last change" hitSlop={8} onPress={undo} style={({ pressed }) => [styles.toastUndo, pressed && styles.toastUndoPressed]}>
1675 <Text style={[styles.toastUndoLabel, { color: ACCENT_DARK }]}>Undo</Text>
1676 </Pressable>
1677 ) : null}
1678 </Animated.View>
1679 </View>
1680 </View>
1681 );
1682}
1683
1684// ─── Styles ─────────────────────────────────────────────────────────────────
1685
1686const styles = StyleSheet.create({
1687 screen: { flex: 1, alignItems: 'center', overflow: 'hidden' },
1688 column: { flex: 1 },
1689 fill: { flex: 1, minWidth: 0 },
1690 tabular: { fontVariant: ['tabular-nums'] },
1691 collapse: { overflow: 'hidden' },
1692 collapseInner: { position: 'absolute', left: 0, right: 0, top: 0 },
1693 spinner: { width: 20, height: 20, borderRadius: 10, borderWidth: 2.5 },
1694 iconTile: { alignItems: 'center', justifyContent: 'center' },
1695 appIcon: { backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },
1696
1697 // Switch
1698 switchTrack: { width: 46, height: 28, borderRadius: 14, padding: 2, justifyContent: 'center' },
1699 switchThumb: { height: 24, borderRadius: 12, backgroundColor: '#FFFFFF', boxShadow: '0px 1px 3px rgba(0, 0, 0, 0.22)' },
1700
1701 // Header
1702 header: { zIndex: 2 },
1703 headerRow: { height: 54, flexDirection: 'row', alignItems: 'center', paddingHorizontal: 14, gap: 10 },
1704 iconButton: { width: 38, height: 38, borderRadius: 19, alignItems: 'center', justifyContent: 'center' },
1705 headerTitle: { flex: 1, fontSize: 17, fontWeight: '700', letterSpacing: -0.3 },
1706 headerActions: { flexDirection: 'row', alignItems: 'center', gap: 8 },
1707 pausePill: { height: 36, borderRadius: 18, paddingHorizontal: 13, flexDirection: 'row', alignItems: 'center', gap: 6 },
1708 pausePillOn: { backgroundColor: ACCENT },
1709 pauseLabel: { fontSize: 14, fontWeight: '600' },
1710 headerRule: { height: StyleSheet.hairlineWidth },
1711
1712 // Title
1713 content: { paddingHorizontal: 16 },
1714 titleBlock: { paddingTop: 2, paddingBottom: 14 },
1715 largeTitle: { fontSize: 32, lineHeight: 38, fontWeight: '800', letterSpacing: -1 },
1716 statusRow: { flexDirection: 'row', alignItems: 'center', gap: 7, marginTop: 3 },
1717 statusDot: { width: 7, height: 7, borderRadius: 4 },
1718 statusText: { fontSize: 14, fontWeight: '500' },
1719 topCardSlot: { paddingBottom: 12 },
1720
1721 // Lock-screen preview
1722 lock: { height: 206, borderRadius: 28, overflow: 'hidden' },
1723 lockTop: { alignItems: 'center', paddingTop: 14 },
1724 lockDate: { marginTop: 4, color: LOCK_INK, fontSize: 13.5, fontWeight: '600', opacity: 0.92 },
1725 lockTime: { color: LOCK_INK, fontSize: 58, lineHeight: 64, fontWeight: '700', letterSpacing: -1.5, fontVariant: ['tabular-nums'] },
1726 lockSlot: { position: 'absolute', left: 12, right: 12, bottom: 16 },
1727 notice: { flexDirection: 'row', alignItems: 'center', gap: 11, paddingHorizontal: 12, paddingVertical: 11, borderRadius: 20 },
1728 plateMid: { position: 'absolute', left: 10, right: 10, bottom: -5, height: 30, borderRadius: 16, opacity: 0.75 },
1729 plateBack: { position: 'absolute', left: 22, right: 22, bottom: -10, height: 30, borderRadius: 14, opacity: 0.5 },
1730 avatar: { width: 38, height: 38, borderRadius: 19, alignItems: 'center', justifyContent: 'center' },
1731 avatarInitials: { color: '#FFFFFF', fontSize: 13, fontWeight: '700', marginTop: -3, marginLeft: -3 },
1732 avatarBadge: { position: 'absolute', right: -5, bottom: -5, borderRadius: 6, borderWidth: 1.5, borderColor: '#FFFFFF' },
1733 noticeTop: { flexDirection: 'row', alignItems: 'center', gap: 8 },
1734 noticeTitle: { flex: 1, fontSize: 14, fontWeight: '700', letterSpacing: -0.1 },
1735 noticeTime: { fontSize: 12, fontWeight: '500' },
1736 noticeBody: { marginTop: 1, fontSize: 13.5, lineHeight: 18 },
1737 noteIcon: { width: 38, height: 38, borderRadius: 19, alignItems: 'center', justifyContent: 'center' },
1738 noteSub: { marginTop: 2, fontSize: 13 },
1739 caption: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 10, marginTop: 10, paddingHorizontal: 4 },
1740 captionText: { flex: 1, fontSize: 13.5 },
1741 captionStrong: { fontWeight: '700' },
1742 captionIcons: { flexDirection: 'row', gap: 5 },
1743 captionDot: { width: 24, height: 24, borderRadius: 12, alignItems: 'center', justifyContent: 'center' },
1744
1745 // Sections
1746 sectionHead: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', marginTop: 22, marginBottom: 10, paddingHorizontal: 4 },
1747 sectionTitle: { fontSize: 12.5, fontWeight: '700', letterSpacing: 0.7 },
1748 sectionAside: { fontSize: 12.5 },
1749 footnote: { fontSize: 12.5, lineHeight: 18, paddingHorizontal: 4, marginTop: 2 },
1750
1751 // Category cards
1752 catCard: { borderRadius: 20, paddingHorizontal: 14, paddingVertical: 12, marginBottom: 10 },
1753 catRing: { borderRadius: 20, borderWidth: 1.5, pointerEvents: 'none' },
1754 catHead: { flexDirection: 'row', alignItems: 'center', gap: 12 },
1755 catHit: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12, minWidth: 0 },
1756 catTitleRow: { flexDirection: 'row', alignItems: 'center', gap: 7 },
1757 catTitle: { flexShrink: 1, fontSize: 15.5, fontWeight: '600', letterSpacing: -0.2 },
1758 catDetail: { marginTop: 1, fontSize: 13, lineHeight: 17 },
1759 digestTag: { flexDirection: 'row', alignItems: 'center', gap: 3, height: 18, paddingHorizontal: 6, borderRadius: 9 },
1760 digestTagLabel: { fontSize: 10.5, fontWeight: '700' },
1761 lockPill: { flexDirection: 'row', alignItems: 'center', gap: 5, height: 28, paddingHorizontal: 10, borderRadius: 14 },
1762 lockPillLabel: { fontSize: 12.5, fontWeight: '600' },
1763 chips: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, paddingTop: 12 },
1764 chip: { height: 32, borderRadius: 16, borderWidth: 1, paddingHorizontal: 11, flexDirection: 'row', alignItems: 'center', gap: 6 },
1765 chipLabel: { fontSize: 13.5, fontWeight: '600' },
1766 chipTick: { height: 14, overflow: 'hidden', alignItems: 'flex-end', justifyContent: 'center' },
1767 why: { flexDirection: 'row', gap: 9, marginTop: 12, padding: 12, borderRadius: 14 },
1768 whyText: { flex: 1, fontSize: 13, lineHeight: 18.5 },
1769
1770 // Pause banner
1771 banner: { flexDirection: 'row', alignItems: 'center', gap: 12, padding: 12, borderRadius: 20 },
1772 drain: { width: DRAIN, height: DRAIN, alignItems: 'center', justifyContent: 'center' },
1773 drainSvg: { position: 'absolute', transform: [{ rotate: '-90deg' }] },
1774 bannerTitle: { fontSize: 15, fontWeight: '700', letterSpacing: -0.2 },
1775 bannerSub: { marginTop: 1, fontSize: 12.5, lineHeight: 17 },
1776 resume: { height: 36, paddingHorizontal: 15, borderRadius: 18, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },
1777 resumeLabel: { color: ON_ACCENT, fontSize: 14, fontWeight: '700' },
1778
1779 // Permission card
1780 permission: { padding: 14, borderRadius: 20 },
1781 permissionTop: { flexDirection: 'row', gap: 12 },
1782 permissionTitle: { fontSize: 15, fontWeight: '700', letterSpacing: -0.2 },
1783 permissionBody: { marginTop: 3, fontSize: 13, lineHeight: 18 },
1784 permissionButton: { marginTop: 12, height: 42, borderRadius: 21, backgroundColor: ACCENT, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 7 },
1785 permissionButtonLabel: { color: ON_ACCENT, fontSize: 14.5, fontWeight: '700' },
1786
1787 // Setting cards
1788 card: { borderRadius: 20, padding: 14, marginBottom: 10 },
1789 settingHead: { flexDirection: 'row', alignItems: 'center', gap: 12 },
1790 linkRow: { flexDirection: 'row', alignItems: 'center', gap: 12 },
1791
1792 // Quiet hours
1793 quietBody: { paddingTop: 14 },
1794 quietRow: { flexDirection: 'row', alignItems: 'center', gap: 16 },
1795 ring: { width: RING, height: RING },
1796 knob: { position: 'absolute', width: KNOB, height: KNOB, borderRadius: KNOB / 2, alignItems: 'center', justifyContent: 'center', boxShadow: '0px 1px 4px rgba(0, 0, 0, 0.18)' },
1797 nowDot: { position: 'absolute', width: 10, height: 10, borderRadius: 5, borderWidth: 2 },
1798 ringCenter: { position: 'absolute', left: 0, right: 0, top: RC - 16, alignItems: 'center' },
1799 ringHours: { fontSize: 17, lineHeight: 20, fontWeight: '800', letterSpacing: -0.5 },
1800 ringLabel: { fontSize: 10.5, fontWeight: '600' },
1801 quietFields: { flex: 1, gap: 8 },
1802 timeField: { borderRadius: 14, borderWidth: 1.5, paddingHorizontal: 12, paddingVertical: 8 },
1803 timeLabel: { fontSize: 12, fontWeight: '600' },
1804 timeValueRow: { flexDirection: 'row', alignItems: 'baseline', gap: 6 },
1805 timeValue: { fontSize: 22, fontWeight: '700', letterSpacing: -0.5 },
1806 timeNote: { fontSize: 12 },
1807 hourChips: { flexDirection: 'row', gap: 6, marginTop: 14 },
1808 hourChip: { flex: 1, height: 34, borderRadius: 11, alignItems: 'center', justifyContent: 'center' },
1809 hourChipLabel: { fontSize: 13, fontWeight: '600' },
1810 quietNote: { flexDirection: 'row', gap: 8, marginTop: 12 },
1811 legendDot: { width: 7, height: 7, borderRadius: 4, marginTop: 6 },
1812 quietNoteText: { flex: 1, fontSize: 12.5, lineHeight: 18 },
1813
1814 // Digest
1815 digestBody: { paddingTop: 14, gap: 10 },
1816 segmented: { height: 38, borderRadius: 12, padding: 3, flexDirection: 'row' },
1817 segThumb: { position: 'absolute', left: 3, top: 3, bottom: 3, borderRadius: 9 },
1818 segItem: { flex: 1, alignItems: 'center', justifyContent: 'center' },
1819 segLabel: { fontSize: 13.5, fontWeight: '600' },
1820 digestNext: { flexDirection: 'row', alignItems: 'center', gap: 12, padding: 12, borderRadius: 14 },
1821 stack: { width: 36, height: 38, justifyContent: 'flex-start' },
1822 stackCard: { position: 'absolute', left: 0, right: 0, top: 0, height: 30, borderRadius: 9, alignItems: 'center', justifyContent: 'center' },
1823 stackMid: { top: 4, left: 3, right: 3 },
1824 stackBack: { top: 8, left: 6, right: 6 },
1825 stackCount: { color: ON_ACCENT, fontSize: 14, fontWeight: '800' },
1826 digestNextTitle: { fontSize: 14, fontWeight: '700' },
1827 digestNextSub: { marginTop: 1, fontSize: 12.5, lineHeight: 17 },
1828
1829 reset: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 6, height: 44, marginTop: 8 },
1830 resetLabel: { fontSize: 14, fontWeight: '600' },
1831
1832 // Menus
1833 popover: { position: 'absolute', borderRadius: 18, paddingVertical: 6 },
1834 menuHead: { fontSize: 11.5, fontWeight: '700', letterSpacing: 0.6, paddingHorizontal: 14, paddingTop: 6, paddingBottom: 4 },
1835 menuItem: { flexDirection: 'row', alignItems: 'center', gap: 11, height: 44, paddingHorizontal: 14 },
1836 menuLabel: { fontSize: 15, fontWeight: '500' },
1837 menuItemTall: { height: 54 },
1838 menuSub: { fontSize: 12.5, marginTop: 1 },
1839 menuRule: { height: StyleSheet.hairlineWidth, marginVertical: 4, marginHorizontal: 14 },
1840 menuFootRow: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingHorizontal: 14, paddingVertical: 8 },
1841 menuFoot: { fontSize: 12.5 },
1842
1843 // Sheet
1844 sheet: { position: 'absolute', bottom: 0, alignSelf: 'center', borderTopLeftRadius: 30, borderTopRightRadius: 30, paddingHorizontal: 18 },
1845 grab: { alignItems: 'center', paddingTop: 8, paddingBottom: 6 },
1846 grabber: { width: 38, height: 5, borderRadius: 3 },
1847 sheetHead: { flexDirection: 'row', alignItems: 'flex-start', gap: 12, marginTop: 4 },
1848 sheetTitle: { fontSize: 21, fontWeight: '800', letterSpacing: -0.5 },
1849 sheetSub: { marginTop: 3, fontSize: 13.5, lineHeight: 19 },
1850 sheetClose: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center' },
1851 sheetLabel: { fontSize: 12, fontWeight: '700', letterSpacing: 0.7, marginTop: 18, marginBottom: 8, paddingHorizontal: 2 },
1852 soundList: { borderRadius: 18, overflow: 'hidden' },
1853 soundRow: { height: 50, flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 12 },
1854 soundRule: { position: 'absolute', top: 0, left: 44, right: 0, height: StyleSheet.hairlineWidth },
1855 radio: { width: 20, height: 20, borderRadius: 10, borderWidth: 2, alignItems: 'center', justifyContent: 'center' },
1856 radioDot: { width: 10, height: 10, borderRadius: 5, backgroundColor: ACCENT },
1857 soundName: { fontSize: 15, fontWeight: '600' },
1858 soundMeta: { fontSize: 12, marginTop: 1 },
1859 playBubble: { width: 34, height: 34, borderRadius: 17, alignItems: 'center', justifyContent: 'center' },
1860 eq: { flexDirection: 'row', alignItems: 'center', gap: 2, height: 14 },
1861 eqBar: { width: 3, borderRadius: 2 },
1862 vibeHead: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
1863 vibeLabel: { marginBottom: 6 },
1864 buzz: { flexDirection: 'row', alignItems: 'center', gap: 4, marginTop: 10 },
1865 buzzPhone: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center' },
1866 buzzWave: { width: 2.5, height: 12, borderRadius: 2 },
1867 vibes: { gap: 8, paddingRight: 4 },
1868 vibe: { width: 116, height: 76, borderRadius: 16, borderWidth: 1.5, padding: 11, justifyContent: 'space-between' },
1869 vibeTop: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
1870 vibeName: { fontSize: 14, fontWeight: '700' },
1871 strip: { width: STRIP_W, height: 14 },
1872 stripFill: { position: 'absolute', left: 0, top: 0, bottom: 0, overflow: 'hidden' },
1873 pulses: { width: STRIP_W, height: 14 },
1874 pulse: { position: 'absolute', top: 1, height: 12, borderRadius: 3 },
1875 pulseFlat: { width: STRIP_W, height: 2, borderRadius: 1, marginTop: 6 },
1876 done: { height: 52, borderRadius: 26, alignItems: 'center', justifyContent: 'center', marginTop: 18 },
1877 doneLabel: { color: ON_ACCENT, fontSize: 16, fontWeight: '700' },
1878
1879 // Toast
1880 toastWrap: { position: 'absolute', left: 0, right: 0, alignItems: 'center', pointerEvents: 'box-none' },
1881 toast: { minWidth: 250, height: 54, borderRadius: 18, flexDirection: 'row', alignItems: 'center', gap: 10, paddingLeft: 12, paddingRight: 8, boxShadow: '0px 12px 30px rgba(0, 0, 0, 0.24)' },
1882 toastCheck: { width: 22, height: 22, borderRadius: 11, backgroundColor: LIVE, alignItems: 'center', justifyContent: 'center' },
1883 toastText: { flexShrink: 1, paddingRight: 6 },
1884 toastTitle: { color: TOAST_INK, fontSize: 14, fontWeight: '700' },
1885 toastDetail: { fontSize: 12.5, marginTop: 1 },
1886 toastUndo: { marginLeft: 'auto', height: 36, paddingHorizontal: 12, borderRadius: 12, justifyContent: 'center' },
1887 toastUndoPressed: { opacity: 0.6 },
1888 toastUndoLabel: { fontSize: 14, fontWeight: '700' },
1889});

More screens like this.

All Profile & Settings