Breathing Exercise

A guided breathing session: a flower of soft petals opens on the inhale, holds and closes on the exhale while the instruction cross-fades and a countdown ticks in its heart. Pick Box, 4-7-8 or 5-5 (each with its own tiny path diagram and a dot that travels it), choose a length, then pause, resume or end into a completion state with a streak and a mood check.

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

Details

File
components/patterns/breathing-exercise.tsx
Lines
953
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/breathing-exercise.tsx
1import { useEffect, useRef, useState, type ReactNode } from 'react';
2import { Pressable, ScrollView, StyleSheet, Text, View, useColorScheme, useWindowDimensions, type LayoutChangeEvent, type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
3import Animated, {
4 Easing,
5 FadeIn,
6 FadeInDown,
7 ZoomIn,
8 cancelAnimation,
9 interpolate,
10 useAnimatedProps,
11 useAnimatedStyle,
12 useSharedValue,
13 withDelay,
14 withRepeat,
15 withSequence,
16 withSpring,
17 withTiming,
18 type SharedValue,
19} from 'react-native-reanimated';
20import { LinearGradient } from 'expo-linear-gradient';
21import { useSafeAreaInsets } from 'react-native-safe-area-context';
22import Svg, { Circle, Defs, Path, RadialGradient, Rect, Stop } from 'react-native-svg';
23import { Check, Flame, Pause, Play, Vibrate, VibrateOff, Volume2, VolumeX } from 'lucide-react-native';
24
25// ─── Brand ──────────────────────────────────────────────────────────────────
26// The screen's accent, for the controls, progress and selection, and the colour of the breathing flower, its glow and the night sky. Every accent colour below derives from these, so changing them rebrands the screen.
27
28const ACCENT = '#0F8A7C';
29const ACCENT_DARK = '#5FE0C0'; // the accent on dark backgrounds
30const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill
31
32/** `hex` at `alpha` opacity, as rgba(). */
33function tint(hex: string, alpha: number) {
34 const n = parseInt(hex.slice(1), 16);
35 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;
36}
37
38/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */
39function shade(hex: string, amount: number) {
40 const n = parseInt(hex.slice(1), 16);
41 const target = amount < 0 ? 255 : 0;
42 const p = Math.abs(amount);
43 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');
44 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();
45}
46
47/** `hex` with its hue turned by `deg` degrees and its HSL lightness and saturation moved by `light` / `sat` (-1 to 1). */
48function spin(hex: string, deg: number, light = 0, sat = 0) {
49 const n = parseInt(hex.slice(1), 16);
50 const r = ((n >> 16) & 255) / 255;
51 const g = ((n >> 8) & 255) / 255;
52 const b = (n & 255) / 255;
53 const max = Math.max(r, g, b);
54 const min = Math.min(r, g, b);
55 const d = max - min;
56 const s = Math.min(1, Math.max(0, (d === 0 ? 0 : d / (1 - Math.abs(max + min - 1))) + sat));
57 const l = Math.min(1, Math.max(0, (max + min) / 2 + light));
58 const h0 = d === 0 ? 0 : max === r ? ((g - b) / d + 6) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
59 const h = (((h0 * 60 + deg) % 360) + 360) % 360;
60 const a = s * Math.min(l, 1 - l);
61 const f = (m: number) => {
62 const k = (m + h / 30) % 12;
63 return Math.round(255 * (l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1)))).toString(16).padStart(2, '0');
64 };
65 return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();
66}
67
68/** `hex` with its hue turned by `deg` and saturation moved by `sat`, at an exact HSL `lightness` (0 to 1). */
69function tone(hex: string, deg: number, lightness: number, sat = 0) {
70 const n = parseInt(hex.slice(1), 16);
71 const r = (n >> 16) & 255; const g = (n >> 8) & 255; const b = n & 255;
72 return spin(hex, deg, lightness - (Math.max(r, g, b) + Math.min(r, g, b)) / 510, sat);
73}
74
75// ─── Sample data ────────────────────────────────────────────────────────────
76
77type PhaseKind = 'in' | 'hold' | 'out';
78type Phase = { kind: PhaseKind; secs: number };
79
80const PHASE_COPY: Record<PhaseKind, { label: string; short: string; hint: string }> = {
81 in: { label: 'Breathe in', short: 'In', hint: 'Slowly, through your nose' },
82 hold: { label: 'Hold', short: 'Hold', hint: 'Stay soft, shoulders down' },
83 out: { label: 'Breathe out', short: 'Out', hint: 'Let it go through your mouth' },
84};
85
86// Each technique draws its rhythm as a closed path in a 56pt box. `stops` are in phases (0 to phases.length),
87// so the dot is at (xs[i], ys[i]) when the cycle reaches stops[i].
88type Technique = {
89 id: string;
90 name: string;
91 pattern: string;
92 title: string;
93 blurb: string;
94 phases: Phase[];
95 path: string;
96 stops: number[];
97 xs: number[];
98 ys: number[];
99};
100
101// A circle sampled every 15 degrees: up the left side on the inhale, down the right on the exhale.
102const ARC = Array.from({ length: 25 }, (_, i) => {
103 const a = Math.PI / 2 + (i / 24) * Math.PI * 2;
104 return { stop: i / 12, x: 28 + 20 * Math.cos(a), y: 28 + 20 * Math.sin(a) };
105});
106
107const TECHNIQUES: Technique[] = [
108 {
109 id: 'box',
110 name: 'Box',
111 pattern: '4-4-4-4',
112 title: 'Box breathing',
113 blurb: 'Four equal sides. Steadies your focus before a big moment.',
114 phases: [{ kind: 'in', secs: 4 }, { kind: 'hold', secs: 4 }, { kind: 'out', secs: 4 }, { kind: 'hold', secs: 4 }],
115 path: 'M8 48 L8 8 L48 8 L48 48 Z',
116 stops: [0, 1, 2, 3, 4],
117 xs: [8, 8, 48, 48, 8],
118 ys: [48, 8, 8, 48, 48],
119 },
120 {
121 id: 'relax',
122 name: 'Relax',
123 pattern: '4-7-8',
124 title: '4-7-8 breathing',
125 blurb: 'A short rise, a long hold, a longer fall. Made for winding down.',
126 phases: [{ kind: 'in', secs: 4 }, { kind: 'hold', secs: 7 }, { kind: 'out', secs: 8 }],
127 // A triangle whose sides really measure 4, 7 and 8.
128 path: 'M6 38 L16.7 18.8 L50 38 Z',
129 stops: [0, 1, 2, 3],
130 xs: [6, 16.7, 50, 6],
131 ys: [38, 18.8, 38, 38],
132 },
133 {
134 id: 'calm',
135 name: 'Calm',
136 pattern: '5-5',
137 title: 'Coherent breathing',
138 blurb: 'An even tide, five in and five out. Good at any time of day.',
139 phases: [{ kind: 'in', secs: 5 }, { kind: 'out', secs: 5 }],
140 path: 'M28 48 A20 20 0 1 1 28 8 A20 20 0 1 1 28 48 Z',
141 stops: ARC.map((p) => p.stop),
142 xs: ARC.map((p) => p.x),
143 ys: ARC.map((p) => p.y),
144 },
145];
146
147const DURATIONS = [1, 3, 5, 10];
148const STREAK = { days: 4, best: 9, week: ['M', 'T', 'W', 'T', 'F', 'S', 'S'], done: [false, false, false, true, true, true, true], today: 6 };
149
150type MoodKey = 'calmer' | 'lighter' | 'focused' | 'sleepy' | 'same';
151const MOODS: { key: MoodKey; label: string; reply: string }[] = [
152 { key: 'calmer', label: 'Calmer', reply: 'Lovely. That makes 3 calmer evenings this week.' },
153 { key: 'lighter', label: 'Lighter', reply: 'Good. A little less to carry into tomorrow.' },
154 { key: 'focused', label: 'Focused', reply: 'Noted. Box breathing tends to do that for you.' },
155 { key: 'sleepy', label: 'Sleepy', reply: 'Right on time. Lights out whenever you are ready.' },
156 { key: 'same', label: 'The same', reply: 'That is fine too. Showing up is the practice.' },
157];
158
159const LEAD_MS = 3000;
160const PETALS = 8;
161
162// ─── Palette ────────────────────────────────────────────────────────────────
163
164const SPRING = { damping: 16, stiffness: 220, mass: 0.7 };
165const BREATH_EASE = Easing.inOut(Easing.sin);
166const TABULAR: TextStyle = { fontVariant: ['tabular-nums'] };
167
168function usePalette() {
169 const dark = useColorScheme() === 'dark';
170 return {
171 dark,
172 // Night teal in the dark theme, a misty dawn over warm sand in the light one.
173 sky: (dark ? [tone(ACCENT, 16, 0.051, -0.035), tone(ACCENT, 15, 0.094, -0.054), tone(ACCENT, 13.5, 0.127, -0.112)] : ['#D3E7F1', '#E6F0EE', '#F8EBDA']) as readonly [string, string, string],
174 fg: dark ? '#E9F6F3' : '#0F3238',
175 sub: dark ? '#A8C7C2' : '#3F6066',
176 muted: dark ? '#7FA29E' : '#5B797D',
177 faint: dark ? '#4F7471' : '#93AAAB',
178 surface: dark ? 'rgba(255,255,255,0.05)' : 'rgba(255,255,255,0.66)',
179 thumb: dark ? tone(ACCENT, 12.5, 0.19, -0.237) : '#FFFFFF',
180 border: dark ? 'rgba(255,255,255,0.08)' : 'rgba(15,50,56,0.07)',
181 accent: dark ? ACCENT_DARK : ACCENT,
182 onAccent: dark ? shade(ACCENT, 0.76) : ON_ACCENT,
183 accentSoft: dark ? tint(ACCENT_DARK, 0.14) : tint(ACCENT, 0.11),
184 petal: (dark ? [spin(ACCENT, -7, 0.345, -0.08), spin(ACCENT, 27.5, 0.313, -0.017)] : [spin(ACCENT, -1.5, 0.184, -0.233), spin(ACCENT, 31, 0.345, -0.036)]) as readonly [string, string],
185 petalOpacity: dark ? 0.3 : 0.3,
186 petalEdge: dark ? 'rgba(190,255,240,0.2)' : 'rgba(255,255,255,0.55)',
187 core: (dark ? [tone(ACCENT, -8, 0.81, 0.031), tone(ACCENT, 26.5, 0.747, 0.072)] : [spin(ACCENT, 0.5, 0.061, -0.065), spin(ACCENT, 30, 0.237, -0.15)]) as readonly [string, string],
188 orbText: dark ? tone(ACCENT, 10, 0.092, -0.017) : '#FFFFFF',
189 orbSub: dark ? 'rgba(5,40,42,0.72)' : 'rgba(255,255,255,0.86)',
190 halo: dark ? spin(ACCENT, -2, 0.205, -0.201) : '#FAC596',
191 haloOpacity: dark ? 0.36 : 0.62,
192 ringTrack: dark ? 'rgba(255,255,255,0.09)' : 'rgba(15,50,56,0.1)',
193 blooms: dark ? [tone(ACCENT, 2.5, 0.267, -0.069), '#155E86', tone(ACCENT, -2.5, 0.204, -0.073)] : ['#A3D9EA', '#F8D0A8', tone(ACCENT, -13, 0.798, -0.309)],
194 bloomOpacity: dark ? 0.5 : 0.75,
195 particle: dark ? 'rgba(190,255,240,0.6)' : 'rgba(255,255,255,0.95)',
196 flame: dark ? '#FFB86B' : '#E0812B',
197 };
198}
199
200type Palette = ReturnType<typeof usePalette>;
201
202const fmt = (secs: number) => `${Math.floor(secs / 60)}:${String(secs % 60).padStart(2, '0')}`;
203
204// ─── Ambient background: slow blooms and a few drifting motes ───────────────
205
206function Bloom({ color, opacity, size, from, to, duration }: { color: string; opacity: number; size: number; from: [number, number]; to: [number, number]; duration: number }) {
207 const t = useSharedValue(0);
208 useEffect(() => {
209 t.value = withRepeat(withTiming(1, { duration, easing: BREATH_EASE }), -1, true);
210 }, [duration, t]);
211 const style = useAnimatedStyle(() => ({
212 transform: [
213 { translateX: interpolate(t.value, [0, 1], [from[0], to[0]]) },
214 { translateY: interpolate(t.value, [0, 1], [from[1], to[1]]) },
215 { scale: interpolate(t.value, [0, 1], [1, 1.18]) },
216 ],
217 }));
218 const id = `breath-bloom-${color.slice(1)}`;
219 return (
220 <Animated.View style={[styles.bloom, { width: size, height: size }, style]}>
221 <Svg width={size} height={size}>
222 <Defs>
223 <RadialGradient id={id} cx="50%" cy="50%" r="50%">
224 <Stop offset="0" stopColor={color} stopOpacity={opacity} />
225 <Stop offset="1" stopColor={color} stopOpacity={0} />
226 </RadialGradient>
227 </Defs>
228 <Rect width={size} height={size} fill={`url(#${id})`} />
229 </Svg>
230 </Animated.View>
231 );
232}
233
234const MOTES = [
235 { x: 0.08, y: 0.2, size: 3, ms: 11000 }, { x: 0.22, y: 0.52, size: 2, ms: 14000 }, { x: 0.9, y: 0.16, size: 3, ms: 12500 },
236 { x: 0.78, y: 0.45, size: 2, ms: 16000 }, { x: 0.14, y: 0.74, size: 2, ms: 13000 }, { x: 0.6, y: 0.1, size: 2, ms: 15000 },
237 { x: 0.93, y: 0.66, size: 3, ms: 17000 }, { x: 0.4, y: 0.9, size: 2, ms: 12000 }, { x: 0.3, y: 0.13, size: 2, ms: 18000 },
238 { x: 0.7, y: 0.82, size: 3, ms: 14500 },
239];
240
241function Mote({ x, y, size, ms, color, order }: { x: number; y: number; size: number; ms: number; color: string; order: number }) {
242 const t = useSharedValue(order % 2 ? 0.6 : 0.2);
243 useEffect(() => {
244 t.value = withRepeat(withTiming(order % 2 ? 0 : 1, { duration: ms, easing: BREATH_EASE }), -1, true);
245 }, [ms, order, t]);
246 const style = useAnimatedStyle(() => ({
247 opacity: interpolate(t.value, [0, 0.5, 1], [0.15, 0.8, 0.2]),
248 transform: [{ translateY: interpolate(t.value, [0, 1], [18, -26]) }, { translateX: interpolate(t.value, [0, 1], [-6, 8]) }],
249 }));
250 return <Animated.View style={[styles.mote, { left: x, top: y, width: size, height: size, backgroundColor: color }, style]} />;
251}
252
253function Ambient({ width, height }: { width: number; height: number }) {
254 const c = usePalette();
255 return (
256 <View pointerEvents="none" style={styles.ambient}>
257 <LinearGradient colors={c.sky} style={StyleSheet.absoluteFill} />
258 <Bloom color={c.blooms[0]} opacity={c.bloomOpacity} size={420} from={[-190, -120]} to={[-110, -40]} duration={19000} />
259 <Bloom color={c.blooms[1]} opacity={c.bloomOpacity} size={380} from={[width - 200, height * 0.42]} to={[width - 260, height * 0.5]} duration={23000} />
260 <Bloom color={c.blooms[2]} opacity={c.bloomOpacity} size={360} from={[-140, height - 300]} to={[-60, height - 360]} duration={27000} />
261 {MOTES.map((m, i) => (
262 <Mote key={i} x={m.x * width} y={m.y * height} size={m.size} ms={m.ms} color={c.particle} order={i} />
263 ))}
264 </View>
265 );
266}
267
268// ─── The orb: a flower of petals that opens with the breath ─────────────────
269
270const AnimatedCircle = Animated.createAnimatedComponent(Circle);
271
272function Petal({ index, breath, size, reach, box, c }: { index: number; breath: SharedValue<number>; size: number; reach: number; box: number; c: Palette }) {
273 const angle = (index / PETALS) * Math.PI * 2;
274 const style = useAnimatedStyle(() => {
275 const r = interpolate(breath.value, [0, 1], [reach * 0.22, reach]);
276 return { transform: [{ translateX: Math.cos(angle) * r }, { translateY: Math.sin(angle) * r }] };
277 });
278 const inset = (box - size) / 2;
279 return (
280 <Animated.View style={[styles.petal, { left: inset, top: inset, width: size, height: size, borderRadius: size / 2, opacity: c.petalOpacity, borderColor: c.petalEdge }, style]}>
281 <LinearGradient colors={c.petal} start={{ x: 0.1, y: 0 }} end={{ x: 0.9, y: 1 }} style={StyleSheet.absoluteFill} />
282 </Animated.View>
283 );
284}
285
286function Orb({ size, breath, progress, children }: { size: number; breath: SharedValue<number>; progress: SharedValue<number>; children: ReactNode }) {
287 const c = usePalette();
288 const spin = useSharedValue(0);
289 useEffect(() => {
290 spin.value = withRepeat(withTiming(1, { duration: 120000, easing: Easing.linear }), -1);
291 }, [spin]);
292
293 const flower = size - 28;
294 const petal = Math.round(flower * 0.53);
295 const reach = (flower - petal) / 2;
296 const halo = size * 1.5;
297 const r = size / 2 - 3;
298 const len = 2 * Math.PI * r;
299
300 const flowerStyle = useAnimatedStyle(() => ({
301 transform: [{ scale: interpolate(breath.value, [0, 1], [0.6, 1]) }, { rotate: `${spin.value * 360 + breath.value * 48}deg` }],
302 }));
303 const haloStyle = useAnimatedStyle(() => ({
304 opacity: interpolate(breath.value, [0, 1], [0.45, 1]),
305 transform: [{ scale: interpolate(breath.value, [0, 1], [0.66, 1]) }],
306 }));
307 const coreStyle = useAnimatedStyle(() => ({ transform: [{ scale: interpolate(breath.value, [0, 1], [0.9, 1.06]) }] }));
308 const arc = useAnimatedProps(() => ({ strokeDashoffset: len * (1 - progress.value) }));
309
310 return (
311 <View style={[styles.orb, { width: size, height: size }]}>
312 <Animated.View pointerEvents="none" style={[styles.halo, { width: halo, height: halo, left: (size - halo) / 2, top: (size - halo) / 2 }, haloStyle]}>
313 <Svg width={halo} height={halo}>
314 <Defs>
315 <RadialGradient id="breath-halo" cx="50%" cy="50%" r="50%">
316 <Stop offset="0.3" stopColor={c.halo} stopOpacity={c.haloOpacity} />
317 <Stop offset="1" stopColor={c.halo} stopOpacity={0} />
318 </RadialGradient>
319 </Defs>
320 <Rect width={halo} height={halo} fill="url(#breath-halo)" />
321 </Svg>
322 </Animated.View>
323
324 {/* Whole-session progress runs around the orb */}
325 <Svg width={size} height={size} style={styles.ring}>
326 <Circle cx={size / 2} cy={size / 2} r={r} stroke={c.ringTrack} strokeWidth={1.5} fill="none" />
327 <AnimatedCircle
328 cx={size / 2}
329 cy={size / 2}
330 r={r}
331 stroke={c.accent}
332 strokeWidth={3}
333 strokeLinecap="round"
334 strokeDasharray={`${len} ${len}`}
335 animatedProps={arc}
336 fill="none"
337 transform={`rotate(-90 ${size / 2} ${size / 2})`}
338 />
339 </Svg>
340
341 <Animated.View style={[styles.flower, { width: size, height: size }, flowerStyle]}>
342 {Array.from({ length: PETALS }, (_, i) => (
343 <Petal key={i} index={i} breath={breath} size={petal} reach={reach} box={size} c={c} />
344 ))}
345 </Animated.View>
346
347 <Animated.View style={[styles.core, { shadowColor: c.core[0], shadowOpacity: 0.55, shadowRadius: 22, shadowOffset: { width: 0, height: 0 } }, coreStyle]}>
348 <LinearGradient colors={c.core} start={{ x: 0.1, y: 0 }} end={{ x: 0.9, y: 1 }} style={StyleSheet.absoluteFill} />
349 </Animated.View>
350 <View style={styles.orbLabel}>{children}</View>
351 </View>
352 );
353}
354
355// ─── Text that cross-fades when it changes ──────────────────────────────────
356
357function Crossfade({ text, style, height }: { text: string; style: StyleProp<TextStyle>; height: number }) {
358 const [layers, setLayers] = useState({ a: text, b: '', top: 'a' as 'a' | 'b' });
359 const mix = useSharedValue(0);
360 useEffect(() => {
361 setLayers((l) => {
362 if ((l.top === 'a' ? l.a : l.b) === text) return l;
363 return l.top === 'a' ? { ...l, b: text, top: 'b' } : { ...l, a: text, top: 'a' };
364 });
365 }, [text]);
366 useEffect(() => {
367 mix.value = withTiming(layers.top === 'b' ? 1 : 0, { duration: 700, easing: Easing.inOut(Easing.quad) });
368 }, [layers.top, mix]);
369 const aStyle = useAnimatedStyle(() => ({ opacity: 1 - mix.value, transform: [{ translateY: mix.value * -8 }] }));
370 const bStyle = useAnimatedStyle(() => ({ opacity: mix.value, transform: [{ translateY: (1 - mix.value) * -8 }] }));
371 return (
372 <View style={[styles.crossfade, { height }]} aria-live="polite">
373 <Animated.Text numberOfLines={1} aria-hidden={layers.top !== 'a'} style={[styles.crossfadeText, style, aStyle]}>
374 {layers.a}
375 </Animated.Text>
376 <Animated.Text numberOfLines={1} aria-hidden={layers.top !== 'b'} style={[styles.crossfadeText, style, bStyle]}>
377 {layers.b}
378 </Animated.Text>
379 </View>
380 );
381}
382
383// ─── Pattern diagram: the technique as a path, with a dot that travels it ───
384
385function PatternDiagram({ technique, cycle, size }: { technique: Technique; cycle: SharedValue<number>; size: number }) {
386 const c = usePalette();
387 const k = size / 56;
388 const { stops, xs, ys } = technique;
389 const dot = useAnimatedStyle(() => ({
390 transform: [{ translateX: interpolate(cycle.value, stops, xs) * k - 5 }, { translateY: interpolate(cycle.value, stops, ys) * k - 5 }],
391 }));
392 return (
393 <View style={{ width: size, height: size }} role="img" aria-label={`${technique.title} pattern`}>
394 <Svg width={size} height={size} viewBox="0 0 56 56">
395 <Path d={technique.path} stroke={c.accent} strokeOpacity={0.55} strokeWidth={2} strokeLinejoin="round" fill={c.accent} fillOpacity={0.08} />
396 </Svg>
397 <Animated.View style={[styles.diagramDot, { backgroundColor: c.accent, borderColor: c.thumb }, dot]} />
398 </View>
399 );
400}
401
402// ─── Controls ───────────────────────────────────────────────────────────────
403
404function TechniquePicker({ value, onChange }: { value: number; onChange: (i: number) => void }) {
405 const c = usePalette();
406 const [w, setW] = useState(0);
407 const x = useSharedValue(value);
408 useEffect(() => {
409 x.value = withSpring(value, SPRING);
410 }, [value, x]);
411 const slot = (w - 8) / TECHNIQUES.length;
412 const thumb = useAnimatedStyle(() => ({ transform: [{ translateX: x.value * slot }] }));
413 return (
414 <View
415 role="radiogroup"
416 aria-label="Technique"
417 onLayout={(e: LayoutChangeEvent) => setW(e.nativeEvent.layout.width)}
418 style={[styles.segmented, { backgroundColor: c.surface, borderColor: c.border }]}
419 >
420 {w > 0 && <Animated.View style={[styles.segmentThumb, { width: slot, backgroundColor: c.thumb }, c.dark ? styles.thumbDark : styles.thumbLight, thumb]} />}
421 {TECHNIQUES.map((t, i) => (
422 <Pressable key={t.id} role="radio" aria-checked={i === value} aria-label={`${t.name} ${t.pattern}`} onPress={() => onChange(i)} style={styles.segment}>
423 <Text style={[styles.segmentName, { color: i === value ? c.fg : c.muted }]}>{t.name}</Text>
424 <Text style={[styles.segmentPattern, { color: i === value ? c.accent : c.faint }, TABULAR]}>{t.pattern}</Text>
425 </Pressable>
426 ))}
427 </View>
428 );
429}
430
431function PressScale({ label, role = 'button', checked, onPress, style, children }: { label: string; role?: 'button' | 'radio' | 'switch'; checked?: boolean; onPress?: () => void; style?: StyleProp<ViewStyle>; children: ReactNode }) {
432 const scale = useSharedValue(1);
433 const anim = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
434 return (
435 <Pressable
436 role={role}
437 aria-label={label}
438 aria-checked={checked}
439 onPress={onPress}
440 onPressIn={() => (scale.value = withSpring(0.94, SPRING))}
441 onPressOut={() => (scale.value = withSpring(1, SPRING))}
442 style={style}
443 >
444 <Animated.View style={anim}>{children}</Animated.View>
445 </Pressable>
446 );
447}
448
449function IconToggle({ label, on, onPress, children }: { label: string; on: boolean; onPress: () => void; children: ReactNode }) {
450 const c = usePalette();
451 return (
452 <PressScale role="switch" label={label} checked={on} onPress={onPress}>
453 <View style={[styles.iconToggle, { backgroundColor: on ? c.accentSoft : c.surface, borderColor: on ? 'transparent' : c.border }]}>{children}</View>
454 </PressScale>
455 );
456}
457
458// ─── Mood faces, drawn with a few strokes ───────────────────────────────────
459
460const FACES: Record<MoodKey, { eyes: 'dots' | 'closed' | 'arcs'; mouth: string }> = {
461 calmer: { eyes: 'arcs', mouth: 'M9.5 17.5 Q14 21 18.5 17.5' },
462 lighter: { eyes: 'dots', mouth: 'M9 16.5 Q14 22.5 19 16.5' },
463 focused: { eyes: 'dots', mouth: 'M10.5 18.5 Q14 19.8 17.5 18.5' },
464 sleepy: { eyes: 'closed', mouth: 'M12.4 18.6 a1.6 1.8 0 1 0 3.2 0 a1.6 1.8 0 1 0 -3.2 0' },
465 same: { eyes: 'dots', mouth: 'M10.5 18.6 L17.5 18.6' },
466};
467
468function Face({ mood, color }: { mood: MoodKey; color: string }) {
469 const f = FACES[mood];
470 return (
471 <Svg width={30} height={30} viewBox="0 0 28 28">
472 <Circle cx={14} cy={14} r={12} stroke={color} strokeWidth={1.8} fill="none" />
473 {f.eyes === 'dots' && (
474 <>
475 <Circle cx={10} cy={11.5} r={1.4} fill={color} />
476 <Circle cx={18} cy={11.5} r={1.4} fill={color} />
477 </>
478 )}
479 {f.eyes === 'arcs' && <Path d="M8 12 Q10 9.6 12 12 M16 12 Q18 9.6 20 12" stroke={color} strokeWidth={1.8} strokeLinecap="round" fill="none" />}
480 {f.eyes === 'closed' && <Path d="M8 11.4 Q10 13.4 12 11.4 M16 11.4 Q18 13.4 20 11.4" stroke={color} strokeWidth={1.8} strokeLinecap="round" fill="none" />}
481 <Path d={f.mouth} stroke={color} strokeWidth={1.8} strokeLinecap="round" fill="none" />
482 </Svg>
483 );
484}
485
486// ─── Completion ─────────────────────────────────────────────────────────────
487
488type Result = { secs: number; breaths: number };
489
490function Complete({ technique, result, onDone }: { technique: Technique; result: Result; onDone: () => void }) {
491 const c = usePalette();
492 const insets = useSafeAreaInsets();
493 const [mood, setMood] = useState<MoodKey | null>(null);
494 const cycleSecs = technique.phases.reduce((n, p) => n + p.secs, 0);
495 const stats = [
496 result.secs < 60 ? { value: String(result.secs), label: 'seconds breathed' } : { value: fmt(result.secs), label: 'minutes breathed' },
497 { value: String(result.breaths), label: result.breaths === 1 ? 'full breath' : 'full breaths' },
498 { value: (60 / cycleSecs).toFixed(1), label: 'breaths a minute' },
499 ];
500 const reply = MOODS.find((m) => m.key === mood)?.reply;
501
502 return (
503 <ScrollView style={styles.fill} contentContainerStyle={[styles.complete, { paddingTop: insets.top + 28, paddingBottom: insets.bottom + 16 }]} showsVerticalScrollIndicator={false}>
504 <Animated.View entering={ZoomIn.duration(500)} style={styles.badge}>
505 <Svg width={104} height={104} viewBox="0 0 104 104">
506 {Array.from({ length: PETALS }, (_, i) => {
507 const a = (i / PETALS) * Math.PI * 2;
508 return <Circle key={i} cx={52 + Math.cos(a) * 22} cy={52 + Math.sin(a) * 22} r={28} fill={c.petal[i % 2]} fillOpacity={c.petalOpacity} />;
509 })}
510 </Svg>
511 <View style={[styles.badgeCore, { backgroundColor: c.accent }]}>
512 <Check size={22} color={c.onAccent} strokeWidth={3} />
513 </View>
514 </Animated.View>
515
516 <Animated.View entering={FadeInDown.delay(120).duration(450)} style={styles.completeHead}>
517 <Text style={[styles.completeTitle, { color: c.fg }]}>Session complete</Text>
518 <Text style={[styles.completeSub, { color: c.sub }]}>{technique.title}, Sunday evening</Text>
519 </Animated.View>
520
521 <Animated.View entering={FadeInDown.delay(200).duration(450)} style={[styles.card, styles.stats, { backgroundColor: c.surface, borderColor: c.border }]}>
522 {stats.map((s, i) => (
523 <View key={s.label} style={[styles.stat, i > 0 && styles.statDivided, i > 0 && { borderLeftColor: c.border }]}>
524 <Text style={[styles.statValue, { color: c.fg }, TABULAR]}>{s.value}</Text>
525 <Text style={[styles.statLabel, { color: c.muted }]}>{s.label}</Text>
526 </View>
527 ))}
528 </Animated.View>
529
530 <Animated.View entering={FadeInDown.delay(280).duration(450)} style={[styles.card, styles.streak, { backgroundColor: c.surface, borderColor: c.border }]}>
531 <View style={styles.streakHead}>
532 <Flame size={18} color={c.flame} strokeWidth={2.2} />
533 <Text style={[styles.streakTitle, { color: c.fg }]}>{STREAK.days}-day streak</Text>
534 <Text style={[styles.streakBest, { color: c.muted }]}>Best {STREAK.best} days</Text>
535 </View>
536 <View style={styles.week}>
537 {STREAK.week.map((d, i) => {
538 const done = STREAK.done[i];
539 const today = i === STREAK.today;
540 return (
541 <View key={i} style={styles.day}>
542 <Animated.View
543 entering={today ? ZoomIn.delay(700).springify().damping(11) : undefined}
544 style={[styles.dayDot, { backgroundColor: done ? (today ? c.accent : c.accentSoft) : 'transparent', borderColor: done ? 'transparent' : c.ringTrack }]}
545 >
546 {done ? <Check size={13} color={today ? c.onAccent : c.accent} strokeWidth={3} /> : null}
547 </Animated.View>
548 <Text style={[styles.dayLabel, { color: today ? c.fg : c.muted }, today && styles.dayToday]}>{d}</Text>
549 </View>
550 );
551 })}
552 </View>
553 </Animated.View>
554
555 <Animated.View entering={FadeInDown.delay(360).duration(450)} style={styles.moodBlock}>
556 <Text style={[styles.moodTitle, { color: c.fg }]}>How do you feel now?</Text>
557 <View role="radiogroup" aria-label="Mood" style={styles.moods}>
558 {MOODS.map((m) => {
559 const on = mood === m.key;
560 return (
561 <PressScale key={m.key} role="radio" label={m.label} checked={on} onPress={() => setMood(m.key)} style={styles.moodSlot}>
562 <View style={[styles.mood, { backgroundColor: on ? c.accentSoft : c.surface, borderColor: on ? c.accent : c.border }]}>
563 <Face mood={m.key} color={on ? c.accent : c.sub} />
564 <Text numberOfLines={1} style={[styles.moodLabel, { color: on ? c.fg : c.muted }]}>
565 {m.label}
566 </Text>
567 </View>
568 </PressScale>
569 );
570 })}
571 </View>
572 <View style={styles.replySlot}>
573 {reply ? (
574 <Animated.Text key={mood} entering={FadeIn.duration(350)} style={[styles.reply, { color: c.sub }]}>
575 {reply}
576 </Animated.Text>
577 ) : (
578 <Text style={[styles.reply, { color: c.faint }]}>Tap one. It helps tune tomorrow's session.</Text>
579 )}
580 </View>
581 </Animated.View>
582
583 <View style={styles.spacer} />
584 <Animated.View entering={FadeInDown.delay(440).duration(450)}>
585 <PressScale label="Done" onPress={onDone}>
586 <View style={[styles.primary, { backgroundColor: c.accent, shadowColor: c.accent, shadowOpacity: 0.3, shadowRadius: 18, shadowOffset: { width: 0, height: 8 } }]}>
587 <Text style={[styles.primaryLabel, { color: c.onAccent }]}>Done</Text>
588 </View>
589 </PressScale>
590 </Animated.View>
591 </ScrollView>
592 );
593}
594
595// ─── Screen ─────────────────────────────────────────────────────────────────
596
597type Mode = 'setup' | 'session' | 'done';
598type Clock = { phase: number; left: number; elapsed: number };
599
600export default function BreathingExerciseScreen() {
601 const c = usePalette();
602 const insets = useSafeAreaInsets();
603 const { width, height } = useWindowDimensions();
604
605 const [techniqueIndex, setTechniqueIndex] = useState(0);
606 const [minutes, setMinutes] = useState(5);
607 const [sound, setSound] = useState(true);
608 const [haptics, setHaptics] = useState(true);
609 const [mode, setMode] = useState<Mode>('setup');
610 const [paused, setPaused] = useState(false);
611 // phase -1 is the lead-in before the first breath.
612 const [clock, setClock] = useState<Clock>({ phase: -1, left: 3, elapsed: 0 });
613 const [result, setResult] = useState<Result>({ secs: 0, breaths: 0 });
614
615 const technique = TECHNIQUES[techniqueIndex];
616 const cycleMs = technique.phases.reduce((n, p) => n + p.secs, 0) * 1000;
617 const totalMs = minutes * 60000;
618 const elapsedMs = useRef(-LEAD_MS);
619
620 const breath = useSharedValue(0.7); // 0 closed, 1 fully open
621 const cycle = useSharedValue(0); // position in the pattern, in phases
622 const progress = useSharedValue(0); // whole session, 0 to 1
623
624 // Idle: the orb rests on a slow, shallow pulse until a session starts.
625 useEffect(() => {
626 if (mode !== 'setup') return;
627 cycle.value = withTiming(0, { duration: 300 });
628 progress.value = withTiming(0, { duration: 400 });
629 breath.value = withSequence(withTiming(0.7, { duration: 700, easing: BREATH_EASE }), withRepeat(withTiming(0.9, { duration: 3600, easing: BREATH_EASE }), -1, true));
630 }, [mode, breath, cycle, progress]);
631
632 const finish = () => {
633 const ms = Math.max(0, Math.min(elapsedMs.current, totalMs));
634 setResult({ secs: Math.round(ms / 1000), breaths: Math.floor(ms / cycleMs + 0.05) });
635 setMode('done');
636 };
637
638 // The clock: wall time while running, turned into a phase, the seconds left in it and the session time.
639 useEffect(() => {
640 if (mode !== 'session' || paused) return;
641 let last = Date.now();
642 const id = setInterval(() => {
643 const now = Date.now();
644 elapsedMs.current += now - last;
645 last = now;
646 const e = elapsedMs.current;
647 if (e >= totalMs) {
648 finish();
649 return;
650 }
651 let next: Clock;
652 if (e < 0) {
653 next = { phase: -1, left: Math.ceil(-e / 1000), elapsed: 0 };
654 } else {
655 let rest = e % cycleMs;
656 let phase = 0;
657 while (rest >= technique.phases[phase].secs * 1000) {
658 rest -= technique.phases[phase].secs * 1000;
659 phase += 1;
660 }
661 next = { phase, left: Math.ceil((technique.phases[phase].secs * 1000 - rest) / 1000), elapsed: Math.floor(e / 1000) };
662 }
663 setClock((prev) => (prev.phase === next.phase && prev.left === next.left && prev.elapsed === next.elapsed ? prev : next));
664 }, 100);
665 return () => clearInterval(id);
666 // eslint-disable-next-line react-hooks/exhaustive-deps
667 }, [mode, paused, technique, totalMs]);
668
669 // Motion: each phase is one timing run to its target. Pausing cancels it; resuming finishes what is left.
670 useEffect(() => {
671 if (mode !== 'session') return;
672 if (paused) {
673 cancelAnimation(breath);
674 cancelAnimation(cycle);
675 cancelAnimation(progress);
676 return;
677 }
678 const e = elapsedMs.current;
679 if (clock.phase < 0) {
680 breath.value = withTiming(0, { duration: Math.max(200, -e), easing: BREATH_EASE });
681 return;
682 }
683 const before = technique.phases.slice(0, clock.phase).reduce((n, p) => n + p.secs, 0) * 1000;
684 const phase = technique.phases[clock.phase];
685 const left = Math.min(phase.secs * 1000, Math.max(60, before + phase.secs * 1000 - (e % cycleMs)));
686 const previous = technique.phases[(clock.phase + technique.phases.length - 1) % technique.phases.length];
687 const target = phase.kind === 'in' ? 1 : phase.kind === 'out' ? 0 : previous.kind === 'in' ? 1 : 0;
688 breath.value = withTiming(target, { duration: left, easing: BREATH_EASE });
689 if (cycle.value < clock.phase || cycle.value > clock.phase + 1) cycle.value = clock.phase;
690 cycle.value = withTiming(clock.phase + 1, { duration: left, easing: Easing.linear });
691 progress.value = withTiming(1, { duration: Math.max(60, totalMs - e), easing: Easing.linear });
692 // eslint-disable-next-line react-hooks/exhaustive-deps
693 }, [mode, paused, clock.phase]);
694
695 const start = () => {
696 elapsedMs.current = -LEAD_MS;
697 cancelAnimation(cycle);
698 cancelAnimation(progress);
699 cycle.value = 0;
700 progress.value = 0;
701 setClock({ phase: -1, left: 3, elapsed: 0 });
702 setPaused(false);
703 setMode('session');
704 };
705
706 const ring = Math.min(300, width - 90, height - insets.top - insets.bottom - 440);
707 const phase = clock.phase >= 0 ? technique.phases[clock.phase] : null;
708 const instruction = paused ? 'Paused' : phase ? PHASE_COPY[phase.kind].label : 'Settle in';
709 const hint = paused ? 'Resume whenever you are ready' : phase ? PHASE_COPY[phase.kind].hint : 'Sit tall and soften your jaw';
710 const remaining = Math.max(0, minutes * 60 - clock.elapsed);
711
712 return (
713 <View style={[styles.screen, { backgroundColor: c.sky[1] }]}>
714 <Ambient width={width} height={height} />
715
716 {mode === 'done' ? (
717 <Complete technique={technique} result={result} onDone={() => setMode('setup')} />
718 ) : (
719 <View style={[styles.fill, { paddingTop: insets.top + 8, paddingBottom: insets.bottom + 12 }]}>
720 {/* Header */}
721 <Animated.View entering={FadeIn.duration(500)} style={styles.header}>
722 <View style={styles.fill}>
723 <Text style={[styles.eyebrow, { color: c.muted }]}>{mode === 'setup' ? 'Sunday evening' : `${technique.name} ${technique.pattern}, ${minutes} min`}</Text>
724 <Text style={[styles.title, { color: c.fg }]}>{mode === 'setup' ? 'Breathe' : technique.title}</Text>
725 </View>
726 <IconToggle label="Sound" on={sound} onPress={() => setSound((v) => !v)}>
727 {sound ? <Volume2 size={19} color={c.accent} /> : <VolumeX size={19} color={c.muted} />}
728 </IconToggle>
729 <IconToggle label="Haptics" on={haptics} onPress={() => setHaptics((v) => !v)}>
730 {haptics ? <Vibrate size={19} color={c.accent} /> : <VibrateOff size={19} color={c.muted} />}
731 </IconToggle>
732 </Animated.View>
733
734 {/* Orb */}
735 <Animated.View entering={FadeIn.duration(700)} style={styles.stage}>
736 <Orb size={ring} breath={breath} progress={progress}>
737 {mode === 'setup' ? (
738 <Animated.View key="setup" entering={FadeIn.duration(400)} style={styles.orbCopy}>
739 <Text style={[styles.orbNumber, { color: c.orbText }, TABULAR]}>{minutes}</Text>
740 <Text style={[styles.orbUnit, { color: c.orbSub }]}>min</Text>
741 </Animated.View>
742 ) : (
743 <Animated.View key="session" entering={FadeIn.duration(400)} style={styles.orbCopy}>
744 <Text aria-label="Seconds left in this phase" style={[styles.orbNumber, { color: c.orbText }, TABULAR]}>
745 {clock.left}
746 </Text>
747 <Text style={[styles.orbUnit, { color: c.orbSub }]}>sec</Text>
748 </Animated.View>
749 )}
750 </Orb>
751 </Animated.View>
752
753 {mode === 'setup' ? (
754 <View key="setup" style={styles.panel}>
755 <Animated.View entering={FadeInDown.delay(80).duration(450)}>
756 <TechniquePicker value={techniqueIndex} onChange={setTechniqueIndex} />
757 </Animated.View>
758
759 <Animated.View entering={FadeInDown.delay(150).duration(450)} style={[styles.card, styles.pattern, { backgroundColor: c.surface, borderColor: c.border }]}>
760 <PatternDiagram technique={technique} cycle={cycle} size={52} />
761 <Animated.View key={technique.id} entering={FadeIn.duration(300)} style={styles.fill}>
762 <Text style={[styles.patternTitle, { color: c.fg }]}>{technique.title}</Text>
763 <Text style={[styles.patternBlurb, { color: c.muted }]}>{technique.blurb}</Text>
764 </Animated.View>
765 </Animated.View>
766
767 <Animated.View entering={FadeInDown.delay(220).duration(450)} style={styles.durationRow}>
768 <Text style={[styles.durationLabel, { color: c.muted }]}>Length</Text>
769 <View role="radiogroup" aria-label="Duration" style={styles.durations}>
770 {DURATIONS.map((d) => {
771 const on = d === minutes;
772 return (
773 <PressScale key={d} role="radio" label={`${d} min`} checked={on} onPress={() => setMinutes(d)}>
774 <View style={[styles.duration, { backgroundColor: on ? c.accentSoft : c.surface, borderColor: on ? c.accent : c.border }]}>
775 <Text style={[styles.durationValue, { color: on ? c.fg : c.muted }, TABULAR]}>{d}</Text>
776 <Text style={[styles.durationUnit, { color: on ? c.accent : c.faint }]}>min</Text>
777 </View>
778 </PressScale>
779 );
780 })}
781 </View>
782 </Animated.View>
783
784 <Animated.View entering={FadeInDown.delay(290).duration(450)}>
785 <PressScale label="Start session" onPress={start}>
786 <View style={[styles.primary, { backgroundColor: c.accent, shadowColor: c.accent, shadowOpacity: 0.3, shadowRadius: 18, shadowOffset: { width: 0, height: 8 } }]}>
787 <Play size={17} color={c.onAccent} fill={c.onAccent} />
788 <Text style={[styles.primaryLabel, { color: c.onAccent }]}>Start</Text>
789 </View>
790 </PressScale>
791 </Animated.View>
792 </View>
793 ) : (
794 <Animated.View key="session" entering={FadeIn.duration(450)} style={styles.panel}>
795 <View style={styles.guide}>
796 <Crossfade text={instruction} height={40} style={[styles.instruction, { color: c.fg }]} />
797 <Crossfade text={hint} height={22} style={[styles.hint, { color: c.muted }]} />
798 </View>
799
800 <View style={[styles.card, styles.pattern, { backgroundColor: c.surface, borderColor: c.border }]}>
801 <PatternDiagram technique={technique} cycle={cycle} size={52} />
802 <View style={styles.sessionInfo}>
803 <View style={styles.steps}>
804 {technique.phases.map((p, i) => {
805 const on = i === clock.phase;
806 return (
807 <View key={i} style={[styles.step, { backgroundColor: on ? c.accentSoft : 'transparent' }]}>
808 <Text style={[styles.stepLabel, { color: on ? c.accent : c.faint }, TABULAR]}>
809 {PHASE_COPY[p.kind].short} {p.secs}
810 </Text>
811 </View>
812 );
813 })}
814 </View>
815 <View style={styles.times}>
816 <Text aria-label="Elapsed" style={[styles.time, { color: c.fg }, TABULAR]}>
817 {fmt(clock.elapsed)}
818 </Text>
819 <Text style={[styles.timeNote, { color: c.muted }]}>elapsed</Text>
820 <View style={styles.fill} />
821 <Text aria-label="Remaining" style={[styles.time, { color: c.fg }, TABULAR]}>
822 {fmt(remaining)}
823 </Text>
824 <Text style={[styles.timeNote, { color: c.muted }]}>left</Text>
825 </View>
826 </View>
827 </View>
828
829 <View style={styles.controls}>
830 <PressScale label={paused ? 'Resume' : 'Pause'} onPress={() => setPaused((p) => !p)}>
831 <View style={[styles.pause, { backgroundColor: c.accent, shadowColor: c.accent, shadowOpacity: 0.3, shadowRadius: 18, shadowOffset: { width: 0, height: 8 } }]}>
832 {paused ? <Play size={24} color={c.onAccent} fill={c.onAccent} /> : <Pause size={24} color={c.onAccent} fill={c.onAccent} />}
833 </View>
834 </PressScale>
835 <Pressable role="link" aria-label="End session" onPress={finish} hitSlop={8} style={({ pressed }) => [styles.end, pressed && styles.pressed]}>
836 <Text style={[styles.endLabel, { color: c.sub }]}>End</Text>
837 </Pressable>
838 </View>
839 </Animated.View>
840 )}
841 </View>
842 )}
843 </View>
844 );
845}
846
847// ─── Styles ─────────────────────────────────────────────────────────────────
848
849const styles = StyleSheet.create({
850 screen: { flex: 1, overflow: 'hidden' },
851 fill: { flex: 1 },
852 pressed: { opacity: 0.5 },
853 spacer: { flex: 1, minHeight: 16 },
854
855 // Ambient
856 ambient: { position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, overflow: 'hidden' },
857 bloom: { position: 'absolute', left: 0, top: 0 },
858 mote: { position: 'absolute', borderRadius: 2 },
859
860 // Header
861 header: { flexDirection: 'row', alignItems: 'center', gap: 10, paddingHorizontal: 24, height: 56 },
862 eyebrow: { fontSize: 13, fontWeight: '500', letterSpacing: 0.2 },
863 title: { marginTop: 2, fontSize: 28, fontWeight: '700', letterSpacing: -0.8 },
864 iconToggle: { width: 40, height: 40, borderRadius: 20, borderWidth: 1, alignItems: 'center', justifyContent: 'center' },
865
866 // Orb
867 stage: { flex: 1, alignItems: 'center', justifyContent: 'center' },
868 orb: { alignItems: 'center', justifyContent: 'center' },
869 halo: { position: 'absolute' },
870 ring: { position: 'absolute', left: 0, top: 0 },
871 flower: { position: 'absolute', left: 0, top: 0 },
872 petal: { position: 'absolute', overflow: 'hidden', borderWidth: 1 },
873 core: { width: 78, height: 78, borderRadius: 39, overflow: 'hidden' },
874 orbLabel: { position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, alignItems: 'center', justifyContent: 'center' },
875 orbCopy: { alignItems: 'center' },
876 orbNumber: { fontSize: 36, lineHeight: 38, fontWeight: '700', letterSpacing: -1 },
877 orbUnit: { fontSize: 12, fontWeight: '600', letterSpacing: 0.4, marginTop: -1 },
878
879 // Panels
880 panel: { height: 318, paddingHorizontal: 24, justifyContent: 'flex-end', gap: 14 },
881 card: { borderRadius: 20, borderWidth: 1 },
882 segmented: { height: 60, borderRadius: 20, borderWidth: 1, padding: 4, flexDirection: 'row' },
883 segmentThumb: { position: 'absolute', left: 4, top: 4, bottom: 4, borderRadius: 16 },
884 thumbLight: { shadowColor: '#0F3238', shadowOpacity: 0.1, shadowRadius: 10, shadowOffset: { width: 0, height: 3 } },
885 thumbDark: { shadowColor: '#000000', shadowOpacity: 0.3, shadowRadius: 10, shadowOffset: { width: 0, height: 3 } },
886 segment: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 1 },
887 segmentName: { fontSize: 15, fontWeight: '600' },
888 segmentPattern: { fontSize: 12, fontWeight: '600', letterSpacing: 0.3 },
889
890 pattern: { flexDirection: 'row', alignItems: 'center', gap: 14, paddingHorizontal: 14, height: 80 },
891 patternTitle: { fontSize: 16, fontWeight: '600', letterSpacing: -0.2 },
892 patternBlurb: { marginTop: 3, fontSize: 13, lineHeight: 18 },
893 diagramDot: { position: 'absolute', left: 0, top: 0, width: 10, height: 10, borderRadius: 5, borderWidth: 2 },
894
895 durationRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
896 durationLabel: { fontSize: 14, fontWeight: '500' },
897 durations: { flexDirection: 'row', gap: 8 },
898 duration: { width: 62, height: 44, borderRadius: 14, borderWidth: 1, flexDirection: 'row', alignItems: 'baseline', justifyContent: 'center', gap: 3, paddingTop: 11 },
899 durationValue: { fontSize: 16, fontWeight: '700' },
900 durationUnit: { fontSize: 11, fontWeight: '600' },
901
902 primary: { height: 58, borderRadius: 20, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 },
903 primaryLabel: { fontSize: 17, fontWeight: '700', letterSpacing: -0.2 },
904
905 // Session
906 guide: { alignItems: 'center', gap: 2, marginBottom: 6 },
907 crossfade: { alignSelf: 'stretch' },
908 crossfadeText: { position: 'absolute', left: 0, right: 0, textAlign: 'center' },
909 instruction: { fontSize: 32, lineHeight: 40, fontWeight: '700', letterSpacing: -0.9 },
910 hint: { fontSize: 15, lineHeight: 22 },
911 sessionInfo: { flex: 1, gap: 8 },
912 steps: { flexDirection: 'row', gap: 4 },
913 step: { flex: 1, height: 26, borderRadius: 9, alignItems: 'center', justifyContent: 'center' },
914 stepLabel: { fontSize: 12, fontWeight: '700' },
915 times: { flexDirection: 'row', alignItems: 'baseline', gap: 5, paddingHorizontal: 4 },
916 time: { fontSize: 15, fontWeight: '700' },
917 timeNote: { fontSize: 12 },
918 controls: { alignItems: 'center', gap: 6, marginTop: 4 },
919 pause: { width: 68, height: 68, borderRadius: 34, alignItems: 'center', justifyContent: 'center' },
920 end: { paddingHorizontal: 20, paddingVertical: 8 },
921 endLabel: { fontSize: 15, fontWeight: '600' },
922
923 // Completion
924 complete: { flexGrow: 1, paddingHorizontal: 24 },
925 badge: { alignSelf: 'center', width: 104, height: 104, alignItems: 'center', justifyContent: 'center' },
926 badgeCore: { position: 'absolute', width: 44, height: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center' },
927 completeHead: { alignItems: 'center', marginTop: 12 },
928 completeTitle: { fontSize: 30, fontWeight: '700', letterSpacing: -0.9 },
929 completeSub: { marginTop: 6, fontSize: 15 },
930 stats: { marginTop: 24, flexDirection: 'row', paddingVertical: 16 },
931 stat: { flex: 1, alignItems: 'center', paddingHorizontal: 6 },
932 statDivided: { borderLeftWidth: 1 },
933 statValue: { fontSize: 24, fontWeight: '700', letterSpacing: -0.6 },
934 statLabel: { marginTop: 3, fontSize: 12, textAlign: 'center' },
935 streak: { marginTop: 12, padding: 16, gap: 14 },
936 streakHead: { flexDirection: 'row', alignItems: 'center', gap: 8 },
937 streakTitle: { flex: 1, fontSize: 16, fontWeight: '700', letterSpacing: -0.2 },
938 streakBest: { fontSize: 13 },
939 week: { flexDirection: 'row', justifyContent: 'space-between' },
940 day: { alignItems: 'center', gap: 6 },
941 dayDot: { width: 30, height: 30, borderRadius: 15, borderWidth: 1.5, alignItems: 'center', justifyContent: 'center' },
942 dayLabel: { fontSize: 12, fontWeight: '500' },
943 dayToday: { fontWeight: '700' },
944 moodBlock: { marginTop: 24 },
945 moodTitle: { fontSize: 18, fontWeight: '700', letterSpacing: -0.3 },
946 moods: { marginTop: 12, flexDirection: 'row', gap: 8 },
947 moodSlot: { flex: 1 },
948 mood: { height: 76, borderRadius: 18, borderWidth: 1, alignItems: 'center', justifyContent: 'center', gap: 6 },
949 moodLabel: { fontSize: 12, fontWeight: '600' },
950 replySlot: { marginTop: 12, minHeight: 20 },
951 reply: { fontSize: 14, lineHeight: 20 },
952});

More screens like this.

All Health & Fitness