A three-slide intro driven entirely by the swipe: illustration pieces drift at different speeds in parallax, the full-screen gradient cross-fades to each slide's colour, the copy slides and fades, a timer ring winds and chart bars grow as their slides arrive. Pill dots stretch with the scroll, Skip jumps to the end, and Next widens into Get started.
Or let your agent fetch it: connect the gluestack MCP server, then ask for welcome-carousel.

Details
1import { useEffect, useRef, useState, type ReactNode } from 'react';2import { Pressable, StyleSheet, Text, View, useColorScheme, useWindowDimensions } from 'react-native';3import Animated, {4 Easing,5 FadeIn,6 FadeInDown,7 ZoomIn,8 interpolate,9 interpolateColor,10 runOnJS,11 useAnimatedReaction,12 useAnimatedScrollHandler,13 useAnimatedStyle,14 useSharedValue,15 withDelay,16 withRepeat,17 withSpring,18 withTiming,19 type SharedValue,20} from 'react-native-reanimated';21import { LinearGradient } from 'expo-linear-gradient';22import { useSafeAreaInsets } from 'react-native-safe-area-context';23import Svg, { Circle, Defs, Path, RadialGradient, Rect, Stop } from 'react-native-svg';24import { ArrowRight, BellOff, CalendarDays, Check, Flame, Moon, Pause, Sparkles, TrendingUp, Trophy, Video, Zap } from 'lucide-react-native';2526// ─── Brand ──────────────────────────────────────────────────────────────────27// The app's accent and name. The accent paints the first slide (its backdrop, glow and card art); the other two28// slides keep their own art palettes, and the controls stay white on every slide. Slide 1's colours derive from these,29// so changing them rebrands the screen.3031const ACCENT = '#2F6BFF';32const ACCENT_DARK = '#6E97FF';33const APP_NAME = 'gluestack';3435/** `hex` with its hue turned by `deg` degrees and its HSL lightness and saturation moved by `light` / `sat` (-1 to 1). */36function spin(hex: string, deg: number, light = 0, sat = 0) {37 const n = parseInt(hex.slice(1), 16);38 const r = ((n >> 16) & 255) / 255;39 const g = ((n >> 8) & 255) / 255;40 const b = (n & 255) / 255;41 const max = Math.max(r, g, b);42 const min = Math.min(r, g, b);43 const d = max - min;44 const s = Math.min(1, Math.max(0, (d === 0 ? 0 : d / (1 - Math.abs(max + min - 1))) + sat));45 const l = Math.min(1, Math.max(0, (max + min) / 2 + light));46 const h0 = d === 0 ? 0 : max === r ? ((g - b) / d + 6) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;47 const h = (((h0 * 60 + deg) % 360) + 360) % 360;48 const a = s * Math.min(l, 1 - l);49 const f = (m: number) => {50 const k = (m + h / 30) % 12;51 return Math.round(255 * (l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1)))).toString(16).padStart(2, '0');52 };53 return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();54}5556/** `hex` with its hue turned by `deg` and saturation moved by `sat`, at an exact HSL `lightness` (0 to 1). */57function tone(hex: string, deg: number, lightness: number, sat = 0) {58 const n = parseInt(hex.slice(1), 16);59 const r = (n >> 16) & 255; const g = (n >> 8) & 255; const b = n & 255;60 return spin(hex, deg, lightness - (Math.max(r, g, b) + Math.min(r, g, b)) / 510, sat);61}6263// ─── Sample data ────────────────────────────────────────────────────────────6465const SLIDES = [66 {67 key: 'plan',68 title: 'Plan your day\nin a minute',69 body: `Drop in your tasks and ${APP_NAME} shapes the day around your meetings.`,70 },71 {72 key: 'focus',73 title: 'Focus sessions\nthat stick',74 body: 'Timed blocks with gentle breaks. Alerts stay quiet until you come up for air.',75 },76 {77 key: 'progress',78 title: 'Watch the\nhabit grow',79 body: 'Weekly recaps and streaks show where your time really went, without the guilt.',80 },81] as const;8283const TASKS = [84 { time: '09:00', title: 'Design review', done: true },85 { time: '11:30', title: 'Write launch notes', done: true },86 { time: '14:00', title: 'Call with Priya', done: false },87];8889const TIMER = { left: '18:42', label: 'Deep work', session: 3, of: 4, progress: 0.68 };9091const WEEK = [92 { day: 'M', hours: 2.4 },93 { day: 'T', hours: 3.6 },94 { day: 'W', hours: 2.9 },95 { day: 'T', hours: 4.4 },96 { day: 'F', hours: 3.1 },97 { day: 'S', hours: 5.2 },98 { day: 'S', hours: 1.8 },99];100const BEST_DAY = 5;101102// ─── Palette ────────────────────────────────────────────────────────────────103104const SPRING = { damping: 16, stiffness: 220, mass: 0.7 };105const TABULAR = { fontVariant: ['tabular-nums' as const] };106107type Tone = {108 bg: readonly [string, string];109 bloom: string;110 accent: string;111 pop: string;112 popFg: string;113 card: string;114 edge: string;115 fg: string;116 muted: string;117 line: string;118 /** The primary button's fill: white in light; in dark it wears the slide's own colour. */119 button: string;120};121122// Light is saturated, dark is near black with a coloured glow. Text on the backdrop is white in both.123const LIGHT: Tone[] = [124 { bg: [ACCENT, spin(ACCENT, 4, -0.261, -0.13)], bloom: tone(ACCENT, -0.5, 0.863), accent: spin(ACCENT, 1.5, -0.052, -0.13), pop: '#FFD15C', popFg: '#3B2A00', card: '#FFFFFF', edge: 'transparent', fg: tone(ACCENT, 5, 0.121, -0.452), muted: tone(ACCENT, 2.5, 0.51, -0.84), line: tone(ACCENT, -0.5, 0.959, -0.19), button: '#FFFFFF' },125 { bg: ['#0FA590', '#04524B'], bloom: '#8DF0DD', accent: '#0B9A86', pop: '#D4F56A', popFg: '#22330A', card: '#FFFFFF', edge: 'transparent', fg: '#0C1F1C', muted: '#6B8480', line: '#E8F5F2', button: '#FFFFFF' },126 { bg: ['#F9623E', '#AC1C4C'], bloom: '#FFC9A8', accent: '#F0522F', pop: '#FFE27A', popFg: '#402A00', card: '#FFFFFF', edge: 'transparent', fg: '#2A1210', muted: '#927672', line: '#FDEEE9', button: '#FFFFFF' },127];128const DARK: Tone[] = [129 { bg: [tone(ACCENT, 3, 0.274, -0.286), tone(ACCENT, 4, 0.051, -0.308)], bloom: ACCENT, accent: ACCENT_DARK, pop: '#FFD15C', popFg: '#3B2A00', card: tone(ACCENT, 2.5, 0.137, -0.543), edge: 'rgba(255,255,255,0.10)', fg: '#FFFFFF', muted: tone(ACCENT, -1.5, 0.704, -0.728), line: tone(ACCENT, 2.5, 0.243, -0.548), button: ACCENT_DARK },130 { bg: ['#0B4D45', '#030E0D'], bloom: '#17C3A9', accent: '#2DD4BF', pop: '#D4F56A', popFg: '#22330A', card: '#0F2A26', edge: 'rgba(255,255,255,0.10)', fg: '#FFFFFF', muted: '#8FB5AF', line: '#193D38', button: '#2DD4BF' },131 { bg: ['#70202E', '#120609'], bloom: '#FF6B4A', accent: '#FF8364', pop: '#FFE27A', popFg: '#402A00', card: '#2C161C', edge: 'rgba(255,255,255,0.10)', fg: '#FFFFFF', muted: '#C7A3A7', line: '#40222A', button: '#FF8364' },132];133134function usePalette() {135 const dark = useColorScheme() === 'dark';136 return {137 dark,138 tones: dark ? DARK : LIGHT,139 onBg: '#FFFFFF',140 onBgMuted: dark ? 'rgba(255,255,255,0.72)' : 'rgba(255,255,255,0.86)',141 glass: dark ? 'rgba(255,255,255,0.10)' : 'rgba(255,255,255,0.20)',142 glassLine: dark ? 'rgba(255,255,255,0.16)' : 'rgba(255,255,255,0.36)',143 buttonFg: dark ? '#0B0914' : '#15122B',144 logoInk: dark ? '#0B0914' : '#15122B',145 };146}147148// ─── Layout ─────────────────────────────────────────────────────────────────149150const HEADER_H = 52;151const STAGE = { w: 340, h: 360 };152const TEXT_H = 156;153const BUTTON_H = 56;154const NEXT_W = 168;155// Text, dots, button and the quiet link, stacked above the home indicator.156const FOOTER_H = TEXT_H + 12 + 8 + 24 + BUTTON_H + 4 + 44 + 4;157158type Motion = { index: number; scrollX: SharedValue<number>; width: number };159160// ─── Backdrop: one gradient per slide, cross-faded by scroll position ───────161162function Backdrop({ index, scrollX, width, tone, dark }: Motion & { tone: Tone; dark: boolean }) {163 const fade = useAnimatedStyle(() => ({164 opacity: index === 0 ? 1 : interpolate(scrollX.value, [(index - 1) * width, index * width], [0, 1], 'clamp'),165 }));166 const drift = useAnimatedStyle(() => ({167 transform: [{ translateX: (scrollX.value - index * width) * -0.18 }],168 }));169 const size = 560;170 const id = `bloom-${index}`;171 return (172 <Animated.View pointerEvents="none" style={[StyleSheet.absoluteFill, fade]}>173 <LinearGradient colors={tone.bg} style={StyleSheet.absoluteFill} />174 <Animated.View style={[styles.bloom, { left: (width - size) / 2, width: size, height: size }, drift]}>175 <Svg width={size} height={size}>176 <Defs>177 <RadialGradient id={id} cx="50%" cy="50%" r="50%">178 <Stop offset="0" stopColor={tone.bloom} stopOpacity={dark ? 0.5 : 0.55} />179 <Stop offset="1" stopColor={tone.bloom} stopOpacity={0} />180 </RadialGradient>181 </Defs>182 <Rect width={size} height={size} fill={`url(#${id})`} />183 </Svg>184 </Animated.View>185 </Animated.View>186 );187}188189// ─── Parallax layer: each piece of an illustration travels at its own speed ─190191type LayerProps = Motion & {192 x: number;193 y: number;194 /** 0 moves with the page, above 0 lags behind it, below 0 runs ahead. */195 depth: number;196 tilt?: number;197 spin?: number;198 bob?: number;199 order?: number;200 children: ReactNode;201};202203function Layer({ index, scrollX, width, x, y, depth, tilt = 0, spin = 0, bob = 6, order = 0, children }: LayerProps) {204 const float = useSharedValue(0);205 useEffect(() => {206 float.value = withDelay(order * 240, withRepeat(withTiming(1, { duration: 2600 + order * 380, easing: Easing.inOut(Easing.sin) }), -1, true));207 }, [float, order]);208 const style = useAnimatedStyle(() => {209 const offset = scrollX.value / width - index;210 const away = Math.min(Math.abs(offset), 1);211 return {212 opacity: interpolate(away, [0.5, 0.95], [1, 0], 'clamp'),213 transform: [214 { translateX: offset * width * depth },215 { translateY: (float.value - 0.5) * bob },216 { rotate: `${tilt + offset * spin}deg` },217 { scale: 1 - away * 0.14 },218 ],219 };220 });221 return (222 <Animated.View style={[styles.layer, { left: x, top: y }, style]}>223 <Animated.View entering={ZoomIn.delay(160 + order * 90).springify().damping(14)}>{children}</Animated.View>224 </Animated.View>225 );226}227228// ─── Illustration pieces ────────────────────────────────────────────────────229230function Card({ tone, width, children }: { tone: Tone; width: number; children: ReactNode }) {231 return <View style={[styles.lift, styles.card, { width, backgroundColor: tone.card, borderColor: tone.edge }]}>{children}</View>;232}233234function Chip({ tone, pop, children }: { tone: Tone; pop?: boolean; children: ReactNode }) {235 return (236 <View style={[styles.lift, styles.chip, { backgroundColor: pop ? tone.pop : tone.card, borderColor: pop ? 'transparent' : tone.edge }]}>237 {children}238 </View>239 );240}241242function Glass({ size, children }: { size: number; children: ReactNode }) {243 const c = usePalette();244 return (245 <View style={[styles.glass, { width: size, height: size, borderRadius: size / 2, backgroundColor: c.glass, borderColor: c.glassLine }]}>246 {children}247 </View>248 );249}250251function Star({ size, color }: { size: number; color: string }) {252 return (253 <Svg width={size} height={size} viewBox="0 0 24 24">254 <Path fill={color} d="M12 0c.9 6.6 4.5 10.2 12 12-7.5 1.8-11.1 5.4-12 12-.9-6.6-4.5-10.2-12-12C7.5 10.2 11.1 6.6 12 0Z" />255 </Svg>256 );257}258259// ─── Slide 1: today's plan, a progress chip and the next meeting ────────────260261function PlanArt({ tone, ...m }: Motion & { tone: Tone }) {262 return (263 <>264 <Layer {...m} x={0} y={10} depth={0.3} bob={0}>265 <Svg width={STAGE.w} height={STAGE.w}>266 {[168, 124, 80].map((r, i) => (267 <Circle key={r} cx={STAGE.w / 2} cy={STAGE.w / 2} r={r} stroke="#fff" strokeOpacity={0.1 + i * 0.05} strokeWidth={1.2} fill="none" />268 ))}269 </Svg>270 </Layer>271272 <Layer {...m} x={34} y={56} depth={0.12} tilt={-5} spin={-6} bob={5} order={0}>273 <Card tone={tone} width={266}>274 <View style={styles.planHead}>275 <View style={[styles.planIcon, { backgroundColor: tone.accent }]}>276 <CalendarDays size={18} color="#fff" strokeWidth={2.2} />277 </View>278 <View style={styles.fill}>279 <Text style={[styles.planTitle, { color: tone.fg }]}>Today</Text>280 <Text style={[styles.small, { color: tone.muted }]}>Tuesday, 17 Nov</Text>281 </View>282 <Text style={[styles.planCount, { color: tone.muted }]}>{TASKS.length} tasks</Text>283 </View>284 <View style={styles.tasks}>285 {TASKS.map((task) => (286 <View key={task.title} style={[styles.task, { backgroundColor: tone.line }]}>287 <View style={[styles.taskCheck, { backgroundColor: task.done ? tone.accent : 'transparent', borderWidth: task.done ? 0 : 2, borderColor: tone.muted }]}>288 {task.done ? <Check size={12} color="#fff" strokeWidth={3.2} /> : null}289 </View>290 <Text style={[styles.taskTitle, { color: tone.fg }]} numberOfLines={1}>291 {task.title}292 </Text>293 <Text style={[styles.small, { color: tone.muted }, TABULAR]}>{task.time}</Text>294 </View>295 ))}296 </View>297 </Card>298 </Layer>299300 <Layer {...m} x={2} y={252} depth={0.5} bob={8} order={1}>301 <Glass size={56}>302 <Zap size={22} color="#fff" fill="#fff" />303 </Glass>304 </Layer>305306 <Layer {...m} x={182} y={24} depth={-0.4} tilt={7} spin={10} bob={8} order={2}>307 <Chip tone={tone} pop>308 <Sparkles size={15} color={tone.popFg} strokeWidth={2.4} />309 <Text style={[styles.chipLabel, { color: tone.popFg }]}>2 of 3 done</Text>310 </Chip>311 </Layer>312313 <Layer {...m} x={132} y={272} depth={-0.7} tilt={4} spin={-8} bob={7} order={3}>314 <View style={[styles.lift, styles.meeting, { backgroundColor: tone.card, borderColor: tone.edge }]}>315 <LinearGradient colors={['#FF9A62', '#F0468A']} style={styles.avatar}>316 <Text style={styles.avatarLetter}>P</Text>317 </LinearGradient>318 <View style={styles.fill}>319 <Text style={[styles.chipLabel, { color: tone.fg }]} numberOfLines={1}>320 Call with Priya321 </Text>322 <Text style={[styles.small, { color: tone.muted }, TABULAR]}>14:00, 30 min</Text>323 </View>324 <Video size={18} color={tone.accent} strokeWidth={2.2} />325 </View>326 </Layer>327328 <Layer {...m} x={20} y={26} depth={-0.25} bob={10} order={4}>329 <Star size={20} color={tone.pop} />330 </Layer>331 <Layer {...m} x={312} y={206} depth={-0.9} bob={12} order={5}>332 <Star size={13} color="#fff" />333 </Layer>334 </>335 );336}337338// ─── Slide 2: a focus timer whose ring winds on as the slide arrives ────────339340function FocusArt({ tone, ...m }: Motion & { tone: Tone }) {341 const { index, scrollX, width } = m;342 const size = 236;343 const r = 98;344 const length = 2 * Math.PI * r;345 const wind = useAnimatedStyle(() => ({346 transform: [{ rotate: `${-90 + (scrollX.value / width - index) * 150}deg` }],347 }));348 return (349 <>350 <Layer {...m} x={0} y={2} depth={0.3} bob={0}>351 <Svg width={STAGE.w} height={STAGE.w}>352 <Circle cx={170} cy={170} r={164} stroke="#fff" strokeOpacity={0.22} strokeWidth={1.2} strokeDasharray="2 9" strokeLinecap="round" fill="none" />353 <Circle cx={54} cy={54} r={5} fill="#fff" fillOpacity={0.7} />354 <Circle cx={318} cy={240} r={4} fill={tone.pop} />355 </Svg>356 </Layer>357358 <Layer {...m} x={52} y={54} depth={0.12} bob={5} order={0}>359 <View style={[styles.lift, styles.timer, { width: size, height: size, borderRadius: size / 2, backgroundColor: tone.card, borderColor: tone.edge }]}>360 <Animated.View style={[StyleSheet.absoluteFill, wind]}>361 <Svg width={size} height={size}>362 <Circle cx={size / 2} cy={size / 2} r={r} stroke={tone.line} strokeWidth={12} fill="none" />363 <Circle364 cx={size / 2}365 cy={size / 2}366 r={r}367 stroke={tone.accent}368 strokeWidth={12}369 strokeLinecap="round"370 strokeDasharray={`${length * TIMER.progress} ${length}`}371 fill="none"372 />373 </Svg>374 </Animated.View>375 <Text style={[styles.timerLabel, { color: tone.accent }]}>{TIMER.label.toUpperCase()}</Text>376 <Text style={[styles.timerValue, { color: tone.fg }, TABULAR]}>{TIMER.left}</Text>377 <Text style={[styles.timerNote, { color: tone.muted }]}>until your break</Text>378 </View>379 </Layer>380381 <Layer {...m} x={272} y={40} depth={0.45} bob={9} order={1}>382 <Glass size={54}>383 <Moon size={22} color="#fff" fill="#fff" />384 </Glass>385 </Layer>386387 <Layer {...m} x={2} y={34} depth={-0.4} tilt={-7} spin={9} bob={8} order={2}>388 <Chip tone={tone}>389 <Text style={[styles.chipLabel, { color: tone.fg }]}>390 Session {TIMER.session} of {TIMER.of}391 </Text>392 <View style={styles.sessions}>393 {Array.from({ length: TIMER.of }, (_, i) => (394 <View key={i} style={[styles.session, { backgroundColor: tone.accent, opacity: i < TIMER.session ? 1 : 0.25 }]} />395 ))}396 </View>397 </Chip>398 </Layer>399400 <Layer {...m} x={20} y={252} depth={0.55} bob={7} order={3}>401 <View style={[styles.lift, styles.pause, { backgroundColor: tone.card, borderColor: tone.edge }]}>402 <Pause size={24} color={tone.accent} fill={tone.accent} />403 </View>404 </Layer>405406 <Layer {...m} x={124} y={280} depth={-0.7} tilt={5} spin={-8} bob={8} order={4}>407 <Chip tone={tone} pop>408 <BellOff size={15} color={tone.popFg} strokeWidth={2.4} />409 <Text style={[styles.chipLabel, { color: tone.popFg }]}>Notifications paused</Text>410 </Chip>411 </Layer>412 </>413 );414}415416// ─── Slide 3: a week of focus, with bars that grow as the slide arrives ─────417418function Bar({ index, scrollX, width, slot, ratio, day, best, tone }: Motion & { slot: number; ratio: number; day: string; best: boolean; tone: Tone }) {419 const style = useAnimatedStyle(() => {420 const start = (index - 1 + slot * 0.05) * width;421 return { height: Math.max(8, 104 * ratio * interpolate(scrollX.value, [start, index * width], [0.15, 1], 'clamp')) };422 });423 return (424 <View style={styles.bar}>425 <Animated.View style={[styles.barFill, { backgroundColor: tone.accent, opacity: best ? 1 : 0.28 }, style]} />426 <Text style={[styles.barDay, { fontWeight: best ? '700' : '500', color: best ? tone.fg : tone.muted }]}>{day}</Text>427 </View>428 );429}430431function ProgressArt({ tone, ...m }: Motion & { tone: Tone }) {432 const peak = Math.max(...WEEK.map((d) => d.hours));433 return (434 <>435 <Layer {...m} x={0} y={8} depth={0.3} bob={0}>436 <Svg width={STAGE.w} height={STAGE.w}>437 <Circle cx={170} cy={170} r={166} stroke="#fff" strokeOpacity={0.16} strokeWidth={1.2} fill="none" />438 <Circle cx={170} cy={170} r={166} stroke="#fff" strokeOpacity={0.5} strokeWidth={3} strokeDasharray="0.1 86.8" strokeLinecap="round" fill="none" />439 <Circle cx={26} cy={86} r={5} fill={tone.pop} />440 </Svg>441 </Layer>442443 <Layer {...m} x={30} y={58} depth={0.12} tilt={3} spin={-6} bob={5} order={0}>444 <Card tone={tone} width={280}>445 <View style={styles.weekHead}>446 <View>447 <Text style={[styles.weekLabel, { color: tone.muted }]}>Focused this week</Text>448 <Text style={[styles.weekTotal, { color: tone.fg }, TABULAR]}>21h 40m</Text>449 </View>450 <View style={styles.trend}>451 <TrendingUp size={13} color="#16A34A" strokeWidth={2.6} />452 <Text style={styles.trendLabel}>18%</Text>453 </View>454 </View>455 <View style={styles.bars}>456 {WEEK.map((d, i) => (457 <Bar key={i} {...m} slot={i} ratio={d.hours / peak} day={d.day} best={i === BEST_DAY} tone={tone} />458 ))}459 </View>460 </Card>461 </Layer>462463 <Layer {...m} x={276} y={2} depth={-0.4} tilt={10} spin={12} bob={7} order={1}>464 <View style={[styles.lift, styles.trophy, { backgroundColor: tone.pop }]}>465 <Trophy size={28} color={tone.popFg} strokeWidth={2.2} />466 </View>467 </Layer>468469 <Layer {...m} x={4} y={284} depth={-0.7} tilt={-6} spin={-8} bob={8} order={2}>470 <Chip tone={tone}>471 <Flame size={16} color={tone.accent} fill={tone.accent} />472 <Text style={[styles.chipLabel, { color: tone.fg }]}>9-day streak</Text>473 </Chip>474 </Layer>475476 <Layer {...m} x={280} y={292} depth={0.5} bob={8} order={3}>477 <Glass size={52}>478 <Star size={20} color="#fff" />479 </Glass>480 </Layer>481 </>482 );483}484485const ART = [PlanArt, FocusArt, ProgressArt];486487// ─── Copy: title and body trail the swipe at different speeds ───────────────488489function SlideCopy({ index, scrollX, width, title, body, active }: Motion & { title: string; body: string; active: boolean }) {490 const c = usePalette();491 const range = [(index - 1) * width, index * width, (index + 1) * width];492 const fade = useAnimatedStyle(() => ({493 opacity: interpolate(scrollX.value, [(index - 0.5) * width, index * width, (index + 0.5) * width], [0, 1, 0], 'clamp'),494 }));495 const titleStyle = useAnimatedStyle(() => ({496 transform: [{ translateX: interpolate(scrollX.value, range, [width * 0.3, 0, -width * 0.3]) }],497 }));498 const bodyStyle = useAnimatedStyle(() => ({499 transform: [{ translateX: interpolate(scrollX.value, range, [width * 0.6, 0, -width * 0.6]) }],500 }));501 return (502 <Animated.View aria-hidden={!active} style={[StyleSheet.absoluteFill, styles.copy, fade]}>503 <Animated.Text role="heading" style={[styles.copyTitle, { color: c.onBg }, titleStyle]}>504 {title}505 </Animated.Text>506 <Animated.Text style={[styles.copyBody, { color: c.onBgMuted }, bodyStyle]}>{body}</Animated.Text>507 </Animated.View>508 );509}510511// ─── Pagination: the active dot stretches into a pill ───────────────────────512513function PageDot({ index, scrollX, width, active, onPress }: Motion & { active: boolean; onPress: () => void }) {514 const style = useAnimatedStyle(() => {515 const t = Math.max(0, 1 - Math.abs(scrollX.value / width - index));516 return { width: 8 + t * 20, opacity: 0.35 + t * 0.65 };517 });518 return (519 <Pressable onPress={onPress} hitSlop={10} role="tab" aria-selected={active} aria-label={`Slide ${index + 1} of ${SLIDES.length}`}>520 <Animated.View style={[styles.dot, style]} />521 </Pressable>522 );523}524525// ─── Primary button: "Next" widens into "Get started" on the last slide ─────526527function PrimaryButton({ scrollX, width, last, done, onPress }: { scrollX: SharedValue<number>; width: number; last: boolean; done: boolean; onPress: () => void }) {528 const c = usePalette();529 const scale = useSharedValue(1);530 const lastIndex = SLIDES.length - 1;531 const full = Math.min(width - 48, 420);532 const stops = SLIDES.map((_, i) => i * width);533 const fills = c.tones.map((t) => t.button);534535 const shell = useAnimatedStyle(() => {536 const p = interpolate(scrollX.value, [(lastIndex - 1) * width, lastIndex * width], [0, 1], 'clamp');537 return { width: NEXT_W + (full - NEXT_W) * p, transform: [{ scale: scale.value }] };538 });539 const fill = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(scrollX.value, stops, fills) }));540 const nextLabel = useAnimatedStyle(() => {541 const p = interpolate(scrollX.value, [(lastIndex - 1) * width, lastIndex * width], [0, 1], 'clamp');542 return { opacity: interpolate(p, [0, 0.45], [1, 0], 'clamp'), transform: [{ translateY: -p * 18 }] };543 });544 const startLabel = useAnimatedStyle(() => {545 const p = interpolate(scrollX.value, [(lastIndex - 1) * width, lastIndex * width], [0, 1], 'clamp');546 return { opacity: interpolate(p, [0.55, 1], [0, 1], 'clamp'), transform: [{ translateY: (1 - p) * 18 }] };547 });548549 const label = [styles.buttonText, { color: c.buttonFg }];550 return (551 <Pressable552 role="button"553 aria-label={done ? 'Welcome aboard' : last ? 'Get started' : 'Next'}554 onPress={onPress}555 onPressIn={() => (scale.value = withSpring(0.95, SPRING))}556 onPressOut={() => (scale.value = withSpring(1, SPRING))}557 >558 <Animated.View style={[styles.button, shell]}>559 <Animated.View style={[styles.buttonFill, fill]}>560 {done ? (561 <Animated.View entering={ZoomIn.springify().damping(13)} style={styles.label}>562 <Check size={20} color={c.buttonFg} strokeWidth={3} />563 <Text style={label}>Welcome aboard</Text>564 </Animated.View>565 ) : (566 <>567 <Animated.View style={[styles.label, nextLabel]}>568 <Text style={label}>Next</Text>569 <ArrowRight size={19} color={c.buttonFg} strokeWidth={2.6} />570 </Animated.View>571 <Animated.View style={[styles.label, startLabel]}>572 <Text style={label}>Get started</Text>573 <ArrowRight size={19} color={c.buttonFg} strokeWidth={2.6} />574 </Animated.View>575 </>576 )}577 </Animated.View>578 </Animated.View>579 </Pressable>580 );581}582583// ─── Screen ─────────────────────────────────────────────────────────────────584585export default function WelcomeCarouselScreen() {586 const c = usePalette();587 const insets = useSafeAreaInsets();588 const window = useWindowDimensions();589 const width = window.width;590 // The window height is a first guess; the measured height wins once the screen has laid out.591 const [measured, setMeasured] = useState(0);592 const height = measured || window.height;593 const scrollRef = useRef<Animated.ScrollView>(null);594 const scrollX = useSharedValue(0);595 const [index, setIndex] = useState(0);596 const [done, setDone] = useState(false);597 const lastIndex = SLIDES.length - 1;598 const last = index === lastIndex;599600 const onScroll = useAnimatedScrollHandler((e) => {601 scrollX.value = e.contentOffset.x;602 });603 // Mirror the settled page into state for labels and the button's action.604 useAnimatedReaction(605 () => Math.min(lastIndex, Math.max(0, Math.round(scrollX.value / width))),606 (now, before) => {607 if (now !== before) runOnJS(setIndex)(now);608 }609 );610611 const goTo = (i: number) => scrollRef.current?.scrollTo({ x: i * width, animated: true });612 const onPrimary = () => {613 if (!last) return goTo(index + 1);614 // Replace with navigation to your sign-up flow.615 setDone(true);616 };617 useEffect(() => {618 if (!done) return;619 const reset = setTimeout(() => setDone(false), 2200);620 return () => clearTimeout(reset);621 }, [done]);622623 // The illustration fills the space between the header and the copy, scaled down on small screens.624 const stageTop = insets.top + HEADER_H;625 const stageRoom = height - stageTop - FOOTER_H - insets.bottom;626 const stageScale = Math.min(1, (width - 28) / STAGE.w, stageRoom / STAGE.h);627628 const skip = useAnimatedStyle(() => ({629 opacity: interpolate(scrollX.value, [(lastIndex - 1) * width, (lastIndex - 0.4) * width], [1, 0], 'clamp'),630 }));631632 return (633 <View onLayout={(e) => setMeasured(e.nativeEvent.layout.height)} style={[styles.screen, { backgroundColor: c.tones[0].bg[1] }]}>634 {/* Backdrop runs edge to edge, under the status bar and home indicator */}635 {c.tones.map((tone, i) => (636 <Backdrop key={SLIDES[i].key} index={i} scrollX={scrollX} width={width} tone={tone} dark={c.dark} />637 ))}638639 {/* Pages: only the illustrations scroll, the copy and controls float above */}640 <Animated.ScrollView641 ref={scrollRef}642 horizontal643 pagingEnabled644 bounces={false}645 decelerationRate="fast"646 showsHorizontalScrollIndicator={false}647 scrollEventThrottle={16}648 onScroll={onScroll}649 style={StyleSheet.absoluteFill}650 aria-label={`${APP_NAME} introduction`}651 >652 {SLIDES.map((slide, i) => {653 const Art = ART[i];654 return (655 <View key={slide.key} style={{ width, height, paddingTop: stageTop }}>656 <View style={[styles.stageRoom, { height: stageRoom }]}>657 <View style={[styles.stage, { transform: [{ scale: stageScale }] }]}>658 <Art index={i} scrollX={scrollX} width={width} tone={c.tones[i]} />659 </View>660 </View>661 </View>662 );663 })}664 </Animated.ScrollView>665666 {/* Header */}667 <View668 pointerEvents="box-none"669 style={[styles.header, { top: insets.top }]}670 >671 <Animated.View entering={FadeIn.duration(500)} pointerEvents="none" style={styles.brand}>672 <View style={styles.logo}>673 <Star size={15} color={c.logoInk} />674 </View>675 <Text style={[styles.appName, { color: c.onBg }]}>{APP_NAME}</Text>676 </Animated.View>677 <Animated.View style={skip}>678 <Pressable role="button" aria-label="Skip introduction" disabled={last} onPress={() => goTo(lastIndex)} hitSlop={12} style={styles.skip}>679 <Text style={[styles.quiet, { color: c.onBgMuted }]}>Skip</Text>680 </Pressable>681 </Animated.View>682 </View>683684 {/* Copy and controls, above the home indicator */}685 <View pointerEvents="box-none" style={[styles.footer, { paddingBottom: insets.bottom + 4 }]}>686 <Animated.View entering={FadeInDown.delay(260).duration(520)} pointerEvents="none" style={styles.copySlot}>687 {SLIDES.map((slide, i) => (688 <SlideCopy key={slide.key} index={i} scrollX={scrollX} width={width} title={slide.title} body={slide.body} active={i === index} />689 ))}690 </Animated.View>691692 <Animated.View entering={FadeIn.delay(420).duration(400)} role="tablist" style={styles.dots}>693 {SLIDES.map((slide, i) => (694 <PageDot key={slide.key} index={i} scrollX={scrollX} width={width} active={i === index} onPress={() => goTo(i)} />695 ))}696 </Animated.View>697698 <Animated.View entering={FadeInDown.delay(480).springify().damping(16)} style={styles.buttonSlot}>699 <PrimaryButton scrollX={scrollX} width={width} last={last} done={done} onPress={onPrimary} />700 </Animated.View>701702 <Animated.View entering={FadeIn.delay(620).duration(400)} style={styles.linkSlot}>703 <Pressable role="link" aria-label="I already have an account" hitSlop={4} style={({ pressed }) => [styles.link, { opacity: pressed ? 0.6 : 1 }]}>704 <Text style={[styles.quiet, { color: c.onBgMuted }]}>I already have an account</Text>705 </Pressable>706 </Animated.View>707 </View>708 </View>709 );710}711712// ─── Styles ─────────────────────────────────────────────────────────────────713714const styles = StyleSheet.create({715 screen: { flex: 1, overflow: 'hidden' },716 fill: { flex: 1 },717 bloom: { position: 'absolute', top: -150 },718 stageRoom: { alignItems: 'center', justifyContent: 'center' },719 stage: { width: STAGE.w, height: STAGE.h },720 layer: { position: 'absolute' },721722 // Illustration pieces723 lift: { shadowColor: '#000', shadowOpacity: 0.22, shadowRadius: 24, shadowOffset: { width: 0, height: 14 }, borderWidth: 1 },724 card: { borderRadius: 26, padding: 16 },725 chip: { flexDirection: 'row', alignItems: 'center', gap: 7, height: 38, paddingHorizontal: 14, borderRadius: 19 },726 chipLabel: { fontSize: 13, fontWeight: '700' },727 glass: { alignItems: 'center', justifyContent: 'center', borderWidth: 1 },728 small: { fontSize: 12 },729730 // Slide 1731 planHead: { flexDirection: 'row', alignItems: 'center', gap: 10, marginBottom: 12 },732 planIcon: { width: 36, height: 36, borderRadius: 12, alignItems: 'center', justifyContent: 'center' },733 planTitle: { fontSize: 15, fontWeight: '700' },734 planCount: { fontSize: 12, fontWeight: '600' },735 tasks: { gap: 8 },736 task: { height: 44, borderRadius: 14, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 10 },737 taskCheck: { width: 20, height: 20, borderRadius: 10, alignItems: 'center', justifyContent: 'center' },738 taskTitle: { flex: 1, fontSize: 14, fontWeight: '500' },739 meeting: { width: 204, borderRadius: 22, padding: 12, flexDirection: 'row', alignItems: 'center', gap: 10 },740 avatar: { width: 38, height: 38, borderRadius: 19, alignItems: 'center', justifyContent: 'center' },741 avatarLetter: { fontSize: 15, fontWeight: '700', color: '#fff' },742743 // Slide 2744 timer: { alignItems: 'center', justifyContent: 'center' },745 timerLabel: { fontSize: 12, fontWeight: '700', letterSpacing: 1.4 },746 timerValue: { fontSize: 50, lineHeight: 58, fontWeight: '700', letterSpacing: -1.5 },747 timerNote: { fontSize: 13 },748 sessions: { flexDirection: 'row', gap: 3 },749 session: { width: 6, height: 6, borderRadius: 3 },750 pause: { width: 64, height: 64, borderRadius: 32, alignItems: 'center', justifyContent: 'center' },751752 // Slide 3753 weekHead: { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between' },754 weekLabel: { fontSize: 12, fontWeight: '500' },755 weekTotal: { fontSize: 30, lineHeight: 38, fontWeight: '700', letterSpacing: -0.8 },756 trend: { flexDirection: 'row', alignItems: 'center', gap: 4, height: 26, paddingHorizontal: 9, borderRadius: 13, backgroundColor: 'rgba(34,197,94,0.16)' },757 trendLabel: { fontSize: 12, fontWeight: '700', color: '#16A34A' },758 bars: { height: 128, marginTop: 14, flexDirection: 'row', alignItems: 'flex-end', gap: 9 },759 bar: { flex: 1, alignItems: 'center', justifyContent: 'flex-end', gap: 6 },760 barFill: { width: '100%', borderRadius: 8 },761 barDay: { fontSize: 11 },762 trophy: { width: 66, height: 66, borderRadius: 22, alignItems: 'center', justifyContent: 'center', borderColor: 'transparent' },763764 // Header765 header: { position: 'absolute', left: 0, right: 0, height: HEADER_H, paddingHorizontal: 24, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },766 brand: { flexDirection: 'row', alignItems: 'center', gap: 9 },767 logo: { width: 30, height: 30, borderRadius: 10, alignItems: 'center', justifyContent: 'center', backgroundColor: '#fff' },768 appName: { fontSize: 18, fontWeight: '800', letterSpacing: -0.4 },769 skip: { paddingVertical: 8, paddingLeft: 12 },770 quiet: { fontSize: 15, fontWeight: '600' },771772 // Copy and controls773 footer: { position: 'absolute', left: 0, right: 0, bottom: 0, alignItems: 'center' },774 copySlot: { alignSelf: 'stretch', height: TEXT_H },775 copy: { alignItems: 'center', paddingHorizontal: 32 },776 copyTitle: { fontSize: 31, lineHeight: 36, fontWeight: '800', letterSpacing: -0.9, textAlign: 'center' },777 copyBody: { marginTop: 12, maxWidth: 330, fontSize: 16, lineHeight: 24, textAlign: 'center' },778 dots: { marginTop: 12, height: 8, flexDirection: 'row', alignItems: 'center', gap: 7 },779 dot: { height: 8, borderRadius: 4, backgroundColor: '#FFFFFF' },780 buttonSlot: { marginTop: 24 },781 button: { height: BUTTON_H, borderRadius: BUTTON_H / 2, shadowColor: '#000', shadowOpacity: 0.28, shadowRadius: 20, shadowOffset: { width: 0, height: 10 } },782 buttonFill: { flex: 1, borderRadius: BUTTON_H / 2, overflow: 'hidden' },783 buttonText: { fontSize: 17, fontWeight: '700', letterSpacing: -0.2 },784 label: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 },785 linkSlot: { marginTop: 4 },786 link: { height: 44, paddingHorizontal: 16, justifyContent: 'center' },787});