Auth welcome

An image-led welcome before sign-in: full-bleed photos cross-fade every four seconds with a slow Ken Burns zoom while the headline's last word slides to match and a story-style dot fills. Apple, Google, email and phone buttons each spin on their own, then confirm with a toast or slide up a sheet with a validated field and a sent state. A language chip opens a picker sheet.

authwelcomesocial loginmagic linkbottom sheetanimationreanimated
Paste into Claude Code Cursor Codex Lovable RapidNative
Live preview · follows the site themeOpen full screen

Details

File
components/patterns/auth-welcome.tsx
Lines
899
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/auth-welcome.tsx
1import { useEffect, useRef, useState, type ComponentRef, type ReactNode } from 'react';
2import {
3 Image,
4 KeyboardAvoidingView,
5 Platform,
6 Pressable,
7 StyleSheet,
8 Text,
9 TextInput,
10 View,
11 useColorScheme,
12 useWindowDimensions,
13 type TextInputProps,
14} from 'react-native';
15import Animated, {
16 Easing,
17 FadeIn,
18 FadeInDown,
19 FadeOutUp,
20 ZoomIn,
21 cancelAnimation,
22 interpolate,
23 runOnJS,
24 useAnimatedStyle,
25 useSharedValue,
26 withDelay,
27 withRepeat,
28 withSequence,
29 withSpring,
30 withTiming,
31} from 'react-native-reanimated';
32import { LinearGradient } from 'expo-linear-gradient';
33import { useSafeAreaInsets } from 'react-native-safe-area-context';
34import Svg, { Path } from 'react-native-svg';
35import { ArrowRight, ArrowUpRight, Check, ChevronDown, Globe, Mail, Smartphone } from 'lucide-react-native';
36
37// ─── Brand ──────────────────────────────────────────────────────────────────
38// The screen's accent and name. Every accent colour below derives from these, so changing them rebrands the screen.
39
40const ACCENT = '#F2552C';
41const ACCENT_DARK = '#FF8A66'; // the accent on dark backgrounds
42const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill
43const APP_NAME = 'gluestack';
44
45/** `hex` with its hue turned by `deg` and its lightness and saturation moved by `light` and `sat` (HSL, -1 to 1), for colours that run warmer, cooler or brighter than the accent. */
46function spin(hex: string, deg: number, light = 0, sat = 0) {
47 const n = parseInt(hex.slice(1), 16);
48 const r = ((n >> 16) & 255) / 255;
49 const g = ((n >> 8) & 255) / 255;
50 const b = (n & 255) / 255;
51 const max = Math.max(r, g, b);
52 const min = Math.min(r, g, b);
53 const d = max - min;
54 const s = Math.min(1, Math.max(0, (d === 0 ? 0 : d / (1 - Math.abs(max + min - 1))) + sat));
55 const l = Math.min(1, Math.max(0, (max + min) / 2 + light));
56 const h0 = d === 0 ? 0 : max === r ? ((g - b) / d + 6) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
57 const h = (((h0 * 60 + deg) % 360) + 360) % 360;
58 const a = s * Math.min(l, 1 - l);
59 const f = (m: number) => {
60 const k = (m + h / 30) % 12;
61 return Math.round(255 * (l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1)))).toString(16).padStart(2, '0');
62 };
63 return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();
64}
65
66// ─── Palette ────────────────────────────────────────────────────────────────
67
68// The headline word: the accent lifted so it reads on the photos.
69const ON_PHOTO_ACCENT = spin(ACCENT, 8, 0.22, 0.09);
70const SUCCESS = '#16A34A';
71const SPRING = { damping: 16, stiffness: 220, mass: 0.7 };
72const SLIDE_MS = 4000;
73const FADE_MS = 1200;
74// The first photo holds a beat longer while the screen settles.
75const FIRST_HOLD_MS = 1200;
76const SHEET_OVERLAP = 32;
77const WORD_H = 50;
78const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
79
80function usePalette() {
81 const dark = useColorScheme() === 'dark';
82 return {
83 dark,
84 sheet: dark ? '#0C0C0E' : '#FFFFFF',
85 sheetEdge: dark ? 'rgba(255,255,255,0.09)' : 'rgba(255,255,255,0)',
86 fg: dark ? '#FAFAFA' : '#0A0A0A',
87 muted: dark ? '#9A9AA2' : '#6B6B73',
88 faint: dark ? '#5E5E66' : '#A1A1AA',
89 solid: dark ? '#FFFFFF' : '#0A0A0A',
90 onSolid: dark ? '#0A0A0A' : '#FFFFFF',
91 soft: dark ? '#1C1C20' : '#F3F3F5',
92 border: dark ? '#303036' : '#DEDEE3',
93 field: dark ? '#151518' : '#FAFAFA',
94 link: dark ? ACCENT_DARK : spin(ACCENT, 0, -0.08, -0.11),
95 grabber: dark ? '#3A3A40' : '#D4D4D8',
96 rowPressed: dark ? '#1C1C20' : '#F3F3F5',
97 toast: dark ? '#FFFFFF' : '#111113',
98 onToast: dark ? '#0A0A0A' : '#FFFFFF',
99 error: dark ? '#FF6B6B' : '#E5484D',
100 successSoft: dark ? 'rgba(22,163,74,0.2)' : 'rgba(22,163,74,0.12)',
101 };
102}
103
104// ─── Sample data ────────────────────────────────────────────────────────────
105
106const photo = (id: string, w: number) => `https://images.unsplash.com/photo-${id}?w=${w}&q=80&fit=crop`;
107
108// One photo per headline word. `tint` shows while the photo loads; `lift` nudges the crop up so
109// the subject sits above the headline.
110const SLIDES = [
111 { word: 'trip', id: '1527631746610-bca00a040d60', alt: 'A traveller with a backpack walking down an old town alley', tint: '#4A3A34', lift: 0.02 },
112 { word: 'weekend', id: '1529156069898-49953e39b3ac', alt: 'Four friends arm in arm watching cable cars over the sea', tint: '#8C7B74', lift: 0.1 },
113 { word: 'run', id: '1552674605-db6ffd4facb5', alt: 'Three runners silhouetted against a blue dawn', tint: '#0E3E86', lift: 0 },
114 { word: 'adventure', id: '1551632811-561732d1e306', alt: 'Two hikers on a trail below snowy peaks', tint: '#56634A', lift: 0.06 },
115];
116
117const MEMBERS = [
118 { id: '1494790108377-be9c29b29330', alt: 'Member portrait, Nora' },
119 { id: '1500648767791-00dcc994a43e', alt: 'Member portrait, Leo' },
120 { id: '1438761681033-6461ffad8d80', alt: 'Member portrait, Ines' },
121 { id: '1507003211169-0a1dd7228f2d', alt: 'Member portrait, Sam' },
122];
123
124const LANGUAGES = [
125 { code: 'EN', name: 'English', note: 'English' },
126 { code: 'ES', name: 'Español', note: 'Spanish' },
127 { code: 'FR', name: 'Français', note: 'French' },
128 { code: 'DE', name: 'Deutsch', note: 'German' },
129 { code: 'PT', name: 'Português', note: 'Portuguese' },
130 { code: 'JA', name: '日本語', note: 'Japanese' },
131];
132
133type Method = 'apple' | 'google' | 'email' | 'phone';
134type StepKind = 'email' | 'phone';
135
136const STEPS: Record<StepKind, {
137 title: string;
138 hint: string;
139 label: string;
140 placeholder: string;
141 cta: string;
142 error: string;
143 sentTitle: string;
144 sentBody: (v: string) => string;
145 again: string;
146 other: string;
147 valid: (v: string) => boolean;
148 input: TextInputProps;
149}> = {
150 email: {
151 title: 'Continue with email',
152 hint: 'We will send you a magic link. No password to remember.',
153 label: 'Email address',
154 placeholder: 'you@example.com',
155 cta: 'Send magic link',
156 error: 'Enter a valid email address.',
157 sentTitle: 'Check your inbox',
158 sentBody: (v) => `We sent a sign-in link to ${v}. It expires in 15 minutes.`,
159 again: 'Use a different email',
160 other: 'Use my phone number instead',
161 valid: (v) => EMAIL_RE.test(v.trim()),
162 input: { keyboardType: 'email-address', autoCapitalize: 'none', autoComplete: 'email', textContentType: 'emailAddress' },
163 },
164 phone: {
165 title: 'Continue with phone',
166 hint: 'We will text you a 6-digit code. Standard rates apply.',
167 label: 'Phone number',
168 placeholder: '415 555 0134',
169 cta: 'Text me a code',
170 error: 'Enter a 10-digit phone number.',
171 sentTitle: 'Code on its way',
172 sentBody: (v) => `We texted a 6-digit code to +1 ${v.trim()}. It can take a minute.`,
173 again: 'Use a different number',
174 other: 'Use my email instead',
175 valid: (v) => v.replace(/\D/g, '').length === 10,
176 input: { keyboardType: 'phone-pad', autoComplete: 'tel', textContentType: 'telephoneNumber' },
177 },
178};
179
180// ─── Marks ──────────────────────────────────────────────────────────────────
181
182function Star({ size, color }: { size: number; color: string }) {
183 return (
184 <Svg width={size} height={size} viewBox="0 0 24 24">
185 <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" />
186 </Svg>
187 );
188}
189
190function AppleLogo({ color }: { color: string }) {
191 return (
192 <Svg width={19} height={19} viewBox="0 0 24 24">
193 <Path
194 fill={color}
195 d="M16.37 12.73c-.03-2.67 2.18-3.95 2.28-4.02-1.24-1.82-3.18-2.07-3.87-2.1-1.65-.17-3.21.97-4.05.97-.84 0-2.12-.95-3.49-.92-1.8.03-3.45 1.04-4.38 2.65-1.87 3.24-.48 8.03 1.34 10.66.89 1.29 1.95 2.73 3.34 2.68 1.34-.05 1.85-.87 3.47-.87 1.62 0 2.08.87 3.49.84 1.44-.02 2.35-1.31 3.23-2.6 1.02-1.49 1.44-2.94 1.46-3.01-.03-.01-2.8-1.08-2.82-4.28ZM13.71 4.89c.74-.9 1.24-2.14 1.1-3.39-1.07.04-2.36.71-3.12 1.6-.69.79-1.29 2.06-1.13 3.28 1.19.09 2.41-.6 3.15-1.49Z"
196 />
197 </Svg>
198 );
199}
200
201function GoogleLogo() {
202 return (
203 <Svg width={18} height={18} viewBox="0 0 24 24">
204 <Path fill="#4285F4" d="M23.52 12.27c0-.85-.08-1.67-.22-2.45H12v4.64h6.46a5.52 5.52 0 0 1-2.4 3.62v3h3.88c2.27-2.09 3.58-5.17 3.58-8.81Z" />
205 <Path fill="#34A853" d="M12 24c3.24 0 5.96-1.07 7.94-2.91l-3.88-3.01c-1.08.72-2.45 1.15-4.06 1.15-3.12 0-5.77-2.11-6.71-4.95H1.28v3.11A12 12 0 0 0 12 24Z" />
206 <Path fill="#FBBC05" d="M5.29 14.28A7.2 7.2 0 0 1 4.91 12c0-.79.14-1.56.38-2.28V6.61H1.28a12 12 0 0 0 0 10.78l4.01-3.11Z" />
207 <Path fill="#EA4335" d="M12 4.77c1.76 0 3.34.61 4.59 1.8l3.44-3.44C17.95 1.19 15.24 0 12 0A12 12 0 0 0 1.28 6.61l4.01 3.11C6.23 6.88 8.88 4.77 12 4.77Z" />
208 </Svg>
209 );
210}
211
212function Spinner({ color, size = 18 }: { color: string; size?: number }) {
213 const r = useSharedValue(0);
214 useEffect(() => {
215 r.value = withRepeat(withTiming(360, { duration: 800, easing: Easing.linear }), -1);
216 return () => cancelAnimation(r);
217 }, [r]);
218 const style = useAnimatedStyle(() => ({ transform: [{ rotate: `${r.value}deg` }] }));
219 return <Animated.View style={[styles.spinner, { width: size, height: size, borderRadius: size / 2, borderTopColor: color }, style]} />;
220}
221
222// ─── Background: photos cross-fade with a slow Ken Burns zoom ───────────────
223
224type Phase = 'active' | 'prev' | 'idle';
225
226function BackdropPhoto({ slide, phase, first, width, height }: { slide: (typeof SLIDES)[number]; phase: Phase; first: boolean; width: number; height: number }) {
227 const shown = useSharedValue(first ? 1 : 0);
228 const loaded = useSharedValue(0);
229 const zoom = useSharedValue(0);
230
231 useEffect(() => {
232 if (phase === 'active') {
233 // The incoming photo fades in on top; the previous one stays solid underneath until it is covered.
234 shown.value = withTiming(1, { duration: FADE_MS, easing: Easing.inOut(Easing.quad) });
235 zoom.value = 0;
236 zoom.value = withTiming(1, { duration: SLIDE_MS + FADE_MS + 400, easing: Easing.linear });
237 } else if (phase === 'idle') {
238 shown.value = withDelay(FADE_MS, withTiming(0, { duration: 0 }));
239 }
240 }, [phase, shown, zoom]);
241
242 const layer = useAnimatedStyle(() => ({ opacity: shown.value }));
243 const image = useAnimatedStyle(() => ({
244 opacity: loaded.value,
245 transform: [{ scale: interpolate(zoom.value, [0, 1], [1.02, 1.14]) }],
246 }));
247
248 return (
249 <Animated.View
250 pointerEvents="none"
251 style={[styles.backdropLayer, { backgroundColor: slide.tint, zIndex: phase === 'active' ? 2 : phase === 'prev' ? 1 : 0 }, layer]}
252 >
253 <Animated.View style={[styles.fill, image]}>
254 <Image
255 source={{ uri: photo(slide.id, 1200) }}
256 alt={slide.alt}
257 resizeMode="cover"
258 style={{ width, height: height * 1.12, marginTop: -height * slide.lift }}
259 onLoad={() => (loaded.value = withTiming(1, { duration: 400 }))}
260 />
261 </Animated.View>
262 </Animated.View>
263 );
264}
265
266// ─── Headline word: slides up and out, the next one rises in ────────────────
267
268function RotatingWord({ word, active }: { word: string; active: boolean }) {
269 const pos = useSharedValue(active ? 0 : 1);
270 const mounted = useRef(false);
271 useEffect(() => {
272 if (!mounted.current) {
273 mounted.current = true;
274 return;
275 }
276 if (active) {
277 pos.value = 1;
278 pos.value = withDelay(120, withTiming(0, { duration: 520, easing: Easing.out(Easing.cubic) }));
279 } else if (pos.value < 1) {
280 pos.value = withTiming(-1, { duration: 420, easing: Easing.in(Easing.cubic) });
281 }
282 }, [active, pos]);
283 const style = useAnimatedStyle(() => ({
284 opacity: 1 - Math.abs(pos.value),
285 transform: [{ translateY: pos.value * WORD_H }],
286 }));
287 return (
288 <Animated.Text aria-hidden={!active} numberOfLines={1} style={[styles.headline, styles.word, style]}>
289 {word}
290 </Animated.Text>
291 );
292}
293
294// ─── Page dot: the active one widens and fills over the slide's four seconds ─
295
296function PageDot({ active, duration, label, onPress }: { active: boolean; duration: number; label: string; onPress: () => void }) {
297 const open = useSharedValue(active ? 1 : 0);
298 const fill = useSharedValue(0);
299 useEffect(() => {
300 open.value = withTiming(active ? 1 : 0, { duration: 300, easing: Easing.out(Easing.cubic) });
301 fill.value = 0;
302 if (active) fill.value = withTiming(1, { duration, easing: Easing.linear });
303 }, [active, duration, open, fill]);
304 const dot = useAnimatedStyle(() => ({ width: interpolate(open.value, [0, 1], [6, 26]) }));
305 const bar = useAnimatedStyle(() => ({ width: `${fill.value * 100}%`, opacity: open.value }));
306 return (
307 <Pressable role="tab" aria-label={label} aria-selected={active} onPress={onPress} hitSlop={8}>
308 <Animated.View style={[styles.dot, dot]}>
309 <Animated.View style={[styles.dotFill, bar]} />
310 </Animated.View>
311 </Pressable>
312 );
313}
314
315// ─── Sign-in method button: press springs, the icon becomes a spinner ───────
316
317function MethodButton({ label, icon, variant, busy, disabled, onPress }: {
318 label: string;
319 icon: ReactNode;
320 variant: 'solid' | 'soft' | 'outline';
321 busy: boolean;
322 disabled: boolean;
323 onPress: () => void;
324}) {
325 const c = usePalette();
326 const scale = useSharedValue(1);
327 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
328 const fg = variant === 'solid' ? c.onSolid : c.fg;
329 const tone =
330 variant === 'solid'
331 ? { backgroundColor: c.solid, borderColor: c.solid }
332 : variant === 'soft'
333 ? { backgroundColor: c.soft, borderColor: c.soft }
334 : { backgroundColor: c.sheet, borderColor: c.border };
335 return (
336 <Pressable
337 role="button"
338 aria-label={label}
339 aria-busy={busy}
340 disabled={disabled}
341 onPress={onPress}
342 onPressIn={() => (scale.value = withSpring(0.97, SPRING))}
343 onPressOut={() => (scale.value = withSpring(1, SPRING))}
344 >
345 {({ pressed }) => (
346 <Animated.View style={[styles.method, tone, { opacity: pressed ? 0.86 : disabled && !busy ? 0.5 : 1 }, style]}>
347 <View style={styles.methodIcon}>{busy ? <Spinner color={fg} /> : icon}</View>
348 <Text style={[styles.methodLabel, { color: fg }]}>{label}</Text>
349 </Animated.View>
350 )}
351 </Pressable>
352 );
353}
354
355// ─── Bottom sheet: scrim fades, panel slides up; closes on scrim tap ────────
356
357function Sheet({ open, onClose, label, minHeight, children }: { open: boolean; onClose: () => void; label: string; minHeight: number; children: ReactNode }) {
358 const c = usePalette();
359 const insets = useSafeAreaInsets();
360 const { height } = useWindowDimensions();
361 const [mounted, setMounted] = useState(open);
362 const t = useSharedValue(0);
363
364 useEffect(() => {
365 if (open) {
366 setMounted(true);
367 t.value = withTiming(1, { duration: 340, easing: Easing.out(Easing.cubic) });
368 } else {
369 t.value = withTiming(0, { duration: 220, easing: Easing.in(Easing.quad) }, (finished) => {
370 if (finished) runOnJS(setMounted)(false);
371 });
372 }
373 }, [open, t]);
374
375 const scrim = useAnimatedStyle(() => ({ opacity: t.value }));
376 const panel = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - t.value) * height * 0.6 }] }));
377
378 if (!mounted) return null;
379 return (
380 <View pointerEvents={open ? 'auto' : 'none'} style={styles.overlay}>
381 <Animated.View style={[styles.scrim, scrim]}>
382 <Pressable role="button" aria-label="Close" onPress={onClose} style={styles.fill} />
383 </Animated.View>
384 <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} pointerEvents="box-none" style={styles.sheetDock}>
385 <Animated.View role="dialog" aria-label={label} style={[styles.modal, { backgroundColor: c.sheet, borderColor: c.sheetEdge, minHeight, paddingBottom: insets.bottom + 12 }, panel]}>
386 <View style={[styles.grabber, { backgroundColor: c.grabber }]} />
387 {children}
388 </Animated.View>
389 </KeyboardAvoidingView>
390 </View>
391 );
392}
393
394// ─── Email / phone step: one validated field, then a sent state ─────────────
395
396function StepForm({ kind, onDone, onSwitch }: { kind: StepKind; onDone: () => void; onSwitch: () => void }) {
397 const c = usePalette();
398 const step = STEPS[kind];
399 const [value, setValue] = useState('');
400 const [error, setError] = useState(false);
401 const [status, setStatus] = useState<'idle' | 'loading' | 'sent'>('idle');
402 const [focused, setFocused] = useState(false);
403 const input = useRef<ComponentRef<typeof TextInput>>(null);
404 const shake = useSharedValue(0);
405 const press = useSharedValue(1);
406 const shakeStyle = useAnimatedStyle(() => ({ transform: [{ translateX: shake.value }] }));
407 const pressStyle = useAnimatedStyle(() => ({ transform: [{ scale: press.value }] }));
408 const valid = step.valid(value);
409
410 useEffect(() => {
411 const id = setTimeout(() => input.current?.focus(), 380);
412 return () => clearTimeout(id);
413 }, []);
414
415 const submit = () => {
416 if (status !== 'idle') return;
417 if (!valid) {
418 setError(true);
419 shake.value = withSequence(
420 withTiming(-9, { duration: 50 }),
421 withTiming(9, { duration: 60 }),
422 withTiming(-6, { duration: 60 }),
423 withTiming(6, { duration: 60 }),
424 withTiming(0, { duration: 50 })
425 );
426 return;
427 }
428 setStatus('loading');
429 // Replace with your magic link or SMS request.
430 setTimeout(() => setStatus('sent'), 1200);
431 };
432
433 if (status === 'sent') {
434 return (
435 <Animated.View entering={FadeIn.duration(220)} style={[styles.fill, styles.sent]}>
436 <Animated.View entering={ZoomIn.springify().damping(12)} style={[styles.sentBadge, { backgroundColor: c.successSoft }]}>
437 <View style={styles.sentTick}>
438 <Check size={22} color="#fff" strokeWidth={3} />
439 </View>
440 </Animated.View>
441 <Text style={[styles.stepTitle, styles.centered, { color: c.fg }]}>{step.sentTitle}</Text>
442 <Text style={[styles.stepHint, styles.centered, { color: c.muted }]}>{step.sentBody(value)}</Text>
443 <Pressable role="button" aria-label="Done" onPress={onDone} style={({ pressed }) => [styles.sentDone, { backgroundColor: c.solid, opacity: pressed ? 0.85 : 1 }]}>
444 <Text style={[styles.methodLabel, { color: c.onSolid }]}>Done</Text>
445 </Pressable>
446 <Pressable
447 role="button"
448 aria-label={step.again}
449 onPress={() => {
450 setValue('');
451 setStatus('idle');
452 }}
453 style={({ pressed }) => [styles.textButton, { opacity: pressed ? 0.55 : 1 }]}
454 >
455 <Text style={[styles.textButtonLabel, { color: c.fg }]}>{step.again}</Text>
456 </Pressable>
457 </Animated.View>
458 );
459 }
460
461 return (
462 <View style={styles.fill}>
463 <Text style={[styles.stepTitle, { color: c.fg }]}>{step.title}</Text>
464 <Text style={[styles.stepHint, { color: c.muted }]}>{step.hint}</Text>
465
466 <Animated.View style={[styles.field, { backgroundColor: c.field, borderColor: error ? c.error : focused ? ACCENT : c.border }, shakeStyle]}>
467 {kind === 'email' ? (
468 <Mail size={19} color={c.muted} />
469 ) : (
470 <Text style={[styles.prefix, { color: c.fg, borderRightColor: c.border }]}>+1</Text>
471 )}
472 <TextInput
473 ref={input}
474 {...step.input}
475 value={value}
476 onChangeText={(v) => {
477 setValue(v);
478 if (error) setError(false);
479 }}
480 onFocus={() => setFocused(true)}
481 onBlur={() => setFocused(false)}
482 onSubmitEditing={submit}
483 returnKeyType="send"
484 editable={status === 'idle'}
485 aria-label={step.label}
486 placeholder={step.placeholder}
487 placeholderTextColor={c.faint}
488 selectionColor={ACCENT}
489 style={[styles.fieldInput, { color: c.fg }, Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null]}
490 />
491 {valid && (
492 <Animated.View entering={ZoomIn.springify().damping(14)} style={styles.validTick}>
493 <Check size={13} color={ON_ACCENT} strokeWidth={3} />
494 </Animated.View>
495 )}
496 </Animated.View>
497 <View style={styles.errorSlot}>
498 {error && (
499 <Animated.Text entering={FadeInDown.duration(180)} role="alert" style={[styles.fieldError, { color: c.error }]}>
500 {step.error}
501 </Animated.Text>
502 )}
503 </View>
504
505 <Pressable
506 role="button"
507 aria-label={step.cta}
508 aria-busy={status === 'loading'}
509 disabled={status !== 'idle'}
510 onPress={submit}
511 onPressIn={() => (press.value = withSpring(0.97, SPRING))}
512 onPressOut={() => (press.value = withSpring(1, SPRING))}
513 >
514 <Animated.View style={[styles.send, pressStyle]}>
515 {status === 'loading' ? (
516 <Spinner color={ON_ACCENT} size={20} />
517 ) : (
518 <>
519 <Text style={styles.sendLabel}>{step.cta}</Text>
520 <ArrowRight size={18} color={ON_ACCENT} strokeWidth={2.4} />
521 </>
522 )}
523 </Animated.View>
524 </Pressable>
525
526 <View style={styles.fill} />
527 <Pressable role="button" aria-label={step.other} onPress={onSwitch} style={({ pressed }) => [styles.textButton, { opacity: pressed ? 0.55 : 1 }]}>
528 {kind === 'email' ? <Smartphone size={16} color={c.muted} /> : <Mail size={16} color={c.muted} />}
529 <Text style={[styles.textButtonLabel, { color: c.muted }]}>{step.other}</Text>
530 </Pressable>
531 </View>
532 );
533}
534
535// ─── Screen ─────────────────────────────────────────────────────────────────
536
537export default function AuthWelcomeScreen() {
538 const c = usePalette();
539 const insets = useSafeAreaInsets();
540 const { width } = useWindowDimensions();
541 const [slide, setSlide] = useState({ index: 0, prev: -1 });
542 const [heroH, setHeroH] = useState(520);
543 const [panelH, setPanelH] = useState(430);
544 const [busy, setBusy] = useState<Method | null>(null);
545 const [toast, setToast] = useState<{ id: number; text: string; done: boolean } | null>(null);
546 const [step, setStep] = useState<{ kind: StepKind; open: boolean }>({ kind: 'email', open: false });
547 const [langOpen, setLangOpen] = useState(false);
548 const [lang, setLang] = useState('EN');
549 const toastTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
550 const hold = slide.prev === -1 ? SLIDE_MS + FIRST_HOLD_MS : SLIDE_MS;
551
552 // Advance the photo and the headline word together.
553 useEffect(() => {
554 const id = setTimeout(() => setSlide((s) => ({ index: (s.index + 1) % SLIDES.length, prev: s.index })), hold);
555 return () => clearTimeout(id);
556 }, [slide.index, hold]);
557
558 useEffect(() => () => {
559 if (toastTimer.current) clearTimeout(toastTimer.current);
560 }, []);
561
562 const notify = (text: string, done = true) => {
563 if (toastTimer.current) clearTimeout(toastTimer.current);
564 setToast({ id: Date.now(), text, done });
565 toastTimer.current = setTimeout(() => setToast(null), 2400);
566 };
567
568 const start = (method: Method) => {
569 if (busy) return;
570 setBusy(method);
571 // Replace with your auth provider call.
572 setTimeout(
573 () => {
574 setBusy(null);
575 if (method === 'apple') notify('Signed in with Apple');
576 else if (method === 'google') notify('Signed in with Google');
577 else setStep({ kind: method, open: true });
578 },
579 method === 'apple' || method === 'google' ? 1300 : 550
580 );
581 };
582
583 const enter = (i: number) => FadeInDown.delay(160 + i * 60).duration(460);
584
585 return (
586 <View style={[styles.screen, { backgroundColor: c.sheet }]}>
587 {/* Photo stage: runs under the status bar and tucks behind the sheet's rounded top */}
588 <View style={styles.hero} onLayout={(e) => setHeroH(e.nativeEvent.layout.height)}>
589 <View style={styles.backdrop}>
590 {SLIDES.map((s, i) => (
591 <BackdropPhoto
592 key={s.id}
593 slide={s}
594 first={i === 0}
595 phase={i === slide.index ? 'active' : i === slide.prev ? 'prev' : 'idle'}
596 width={width}
597 height={heroH + SHEET_OVERLAP}
598 />
599 ))}
600 <LinearGradient
601 pointerEvents="none"
602 colors={['rgba(0,0,0,0.5)', 'rgba(0,0,0,0)', 'rgba(0,0,0,0.25)', 'rgba(0,0,0,0.82)']}
603 locations={[0, 0.26, 0.5, 1]}
604 style={styles.shade}
605 />
606 </View>
607
608 {/* Brand and language */}
609 <Animated.View entering={FadeIn.duration(500)} style={[styles.header, { marginTop: insets.top + 6 }]}>
610 <View style={styles.brand}>
611 <View style={styles.logo}>
612 <Star size={15} color={ACCENT} />
613 </View>
614 <Text style={styles.appName}>{APP_NAME}</Text>
615 </View>
616 <Pressable
617 role="button"
618 aria-label={`Language, ${LANGUAGES.find((l) => l.code === lang)?.note}`}
619 aria-expanded={langOpen}
620 onPress={() => setLangOpen(true)}
621 hitSlop={8}
622 style={({ pressed }) => [styles.langChip, { opacity: pressed ? 0.7 : 1 }]}
623 >
624 <Globe size={14} color="#fff" strokeWidth={2.2} />
625 <Text style={styles.langCode}>{lang}</Text>
626 <ChevronDown size={14} color="rgba(255,255,255,0.8)" strokeWidth={2.4} />
627 </Pressable>
628 </Animated.View>
629
630 <View style={styles.fill} />
631
632 {/* Headline: the last word follows the photo */}
633 <Animated.View entering={FadeInDown.delay(80).duration(520)} style={styles.copy}>
634 <Text role="heading" aria-label={`Plan your next ${SLIDES[slide.index].word}`} style={styles.headline}>
635 Plan your next
636 </Text>
637 <View style={styles.wordSlot}>
638 {SLIDES.map((s, i) => (
639 <RotatingWord key={s.word} word={s.word} active={i === slide.index} />
640 ))}
641 </View>
642 <Text style={styles.subhead}>Routes, stays and friends, all in one place.</Text>
643
644 <View style={styles.proofRow}>
645 <View style={styles.faces}>
646 {MEMBERS.map((m, i) => (
647 <Image key={m.id} source={{ uri: photo(m.id, 96) }} alt={m.alt} style={[styles.face, i > 0 && styles.faceOverlap]} />
648 ))}
649 </View>
650 <Text style={styles.proof}>
651 Join <Text style={styles.proofStrong}>2M+ people</Text>
652 </Text>
653 <View style={styles.fill} />
654 <View role="tablist" aria-label="Background photos" style={styles.dots}>
655 {SLIDES.map((s, i) => (
656 <PageDot
657 key={s.id}
658 active={i === slide.index}
659 duration={hold}
660 label={`Photo ${i + 1} of ${SLIDES.length}`}
661 onPress={() => i !== slide.index && setSlide((cur) => ({ index: i, prev: cur.index }))}
662 />
663 ))}
664 </View>
665 </View>
666 </Animated.View>
667 </View>
668
669 {/* Sign-in methods */}
670 <Animated.View
671 entering={FadeInDown.delay(120).duration(480)}
672 onLayout={(e) => setPanelH(e.nativeEvent.layout.height)}
673 style={[styles.panel, { backgroundColor: c.sheet, borderColor: c.sheetEdge, paddingBottom: insets.bottom + 10 }]}
674 >
675 <Animated.View entering={enter(0)}>
676 <MethodButton label="Continue with Apple" variant="solid" icon={<AppleLogo color={c.onSolid} />} busy={busy === 'apple'} disabled={busy !== null} onPress={() => start('apple')} />
677 </Animated.View>
678 <Animated.View entering={enter(1)}>
679 <MethodButton label="Continue with Google" variant="soft" icon={<GoogleLogo />} busy={busy === 'google'} disabled={busy !== null} onPress={() => start('google')} />
680 </Animated.View>
681 <Animated.View entering={enter(2)}>
682 <MethodButton label="Continue with email" variant="outline" icon={<Mail size={19} color={c.fg} />} busy={busy === 'email'} disabled={busy !== null} onPress={() => start('email')} />
683 </Animated.View>
684
685 <Animated.View entering={enter(3)}>
686 <Pressable
687 role="button"
688 aria-label="Continue with phone"
689 aria-busy={busy === 'phone'}
690 disabled={busy !== null}
691 onPress={() => start('phone')}
692 style={({ pressed }) => [styles.textButton, { opacity: pressed ? 0.55 : 1 }]}
693 >
694 <View style={styles.methodIcon}>{busy === 'phone' ? <Spinner color={c.fg} size={16} /> : <Smartphone size={17} color={c.fg} />}</View>
695 <Text style={[styles.textButtonLabel, { color: c.fg }]}>Continue with phone</Text>
696 </Pressable>
697 </Animated.View>
698
699 <Animated.View entering={enter(4)} style={styles.footer}>
700 <View style={styles.signInRow}>
701 <Text style={[styles.signInText, { color: c.muted }]}>Already have an account?</Text>
702 <Pressable role="link" aria-label="Sign in" hitSlop={8} style={({ pressed }) => ({ opacity: pressed ? 0.45 : 1 })}>
703 <Text style={[styles.signInLink, { color: c.link }]}>Sign in</Text>
704 </Pressable>
705 </View>
706 <Text style={[styles.legal, { color: c.faint }]}>
707 By continuing you agree to our{' '}
708 <Text role="link" onPress={() => notify('Opening Terms of Service', false)} style={[styles.legalLink, { color: c.muted }]}>
709 Terms
710 </Text>{' '}
711 and{' '}
712 <Text role="link" onPress={() => notify('Opening Privacy Policy', false)} style={[styles.legalLink, { color: c.muted }]}>
713 {'Privacy\u00A0Policy'}
714 </Text>
715 .
716 </Text>
717 </Animated.View>
718 </Animated.View>
719
720 {/* Email or phone step. Sheets rise just past the panel so no button peeks out above them. */}
721 <Sheet open={step.open} onClose={() => setStep((s) => ({ ...s, open: false }))} label={STEPS[step.kind].title} minHeight={panelH + 14}>
722 <StepForm
723 key={step.kind}
724 kind={step.kind}
725 onDone={() => setStep((s) => ({ ...s, open: false }))}
726 onSwitch={() => setStep((s) => ({ kind: s.kind === 'email' ? 'phone' : 'email', open: true }))}
727 />
728 </Sheet>
729
730 {/* Language picker */}
731 <Sheet open={langOpen} onClose={() => setLangOpen(false)} label="Choose a language" minHeight={panelH + 14}>
732 <Text style={[styles.stepTitle, { color: c.fg }]}>Language</Text>
733 <View role="radiogroup" style={styles.langList}>
734 {LANGUAGES.map((l) => {
735 const on = l.code === lang;
736 return (
737 <Pressable
738 key={l.code}
739 role="radio"
740 aria-label={l.note}
741 aria-checked={on}
742 onPress={() => {
743 setLang(l.code);
744 setTimeout(() => setLangOpen(false), 180);
745 }}
746 style={({ pressed }) => [styles.langRow, pressed && { backgroundColor: c.rowPressed }]}
747 >
748 <Text style={[styles.langBadge, { color: c.muted, backgroundColor: c.soft }]}>{l.code}</Text>
749 <Text style={[styles.langName, { color: c.fg }]}>{l.name}</Text>
750 <Text style={[styles.langNote, { color: c.muted }]}>{l.note}</Text>
751 <View style={styles.fill} />
752 {on && (
753 <Animated.View entering={ZoomIn.springify().damping(14)} style={styles.validTick}>
754 <Check size={13} color={ON_ACCENT} strokeWidth={3} />
755 </Animated.View>
756 )}
757 </Pressable>
758 );
759 })}
760 </View>
761 </Sheet>
762
763 {/* Toast */}
764 {toast && (
765 <View pointerEvents="none" style={[styles.toastDock, { top: insets.top + 58 }]}>
766 <Animated.View key={toast.id} entering={FadeInDown.springify().damping(16)} exiting={FadeOutUp.duration(200)} role="status" style={[styles.toast, { backgroundColor: c.toast }]}>
767 {toast.done ? (
768 <View style={styles.toastTick}>
769 <Check size={12} color="#fff" strokeWidth={3.2} />
770 </View>
771 ) : (
772 <ArrowUpRight size={18} color={c.onToast} strokeWidth={2.4} />
773 )}
774 <Text style={[styles.toastText, { color: c.onToast }]}>{toast.text}</Text>
775 </Animated.View>
776 </View>
777 )}
778 </View>
779 );
780}
781
782// ─── Styles ─────────────────────────────────────────────────────────────────
783
784const styles = StyleSheet.create({
785 screen: { flex: 1, overflow: 'hidden' },
786 fill: { flex: 1 },
787 centered: { textAlign: 'center' },
788
789 // Photo stage
790 hero: { flex: 1 },
791 backdrop: { position: 'absolute', top: 0, left: 0, right: 0, bottom: -SHEET_OVERLAP, overflow: 'hidden', backgroundColor: '#1D2530' },
792 backdropLayer: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, overflow: 'hidden' },
793 shade: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 3 },
794
795 header: { height: 44, paddingHorizontal: 24, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
796 brand: { flexDirection: 'row', alignItems: 'center', gap: 9 },
797 logo: { width: 30, height: 30, borderRadius: 10, alignItems: 'center', justifyContent: 'center', backgroundColor: '#fff' },
798 appName: { fontSize: 18, fontWeight: '800', letterSpacing: -0.4, color: '#fff' },
799 langChip: {
800 height: 34,
801 paddingHorizontal: 11,
802 borderRadius: 17,
803 flexDirection: 'row',
804 alignItems: 'center',
805 gap: 5,
806 backgroundColor: 'rgba(20,20,22,0.42)',
807 borderWidth: 1,
808 borderColor: 'rgba(255,255,255,0.28)',
809 },
810 langCode: { fontSize: 13, fontWeight: '700', letterSpacing: 0.4, color: '#fff' },
811
812 copy: { paddingHorizontal: 24, paddingBottom: 22 },
813 headline: { fontSize: 42, lineHeight: WORD_H, fontWeight: '800', letterSpacing: -1.4, color: '#fff' },
814 wordSlot: { height: WORD_H + 4, overflow: 'hidden' },
815 word: { position: 'absolute', left: 0, top: 0, color: ON_PHOTO_ACCENT },
816 subhead: { marginTop: 6, fontSize: 16, lineHeight: 22, color: 'rgba(255,255,255,0.86)' },
817 proofRow: { marginTop: 18, height: 32, flexDirection: 'row', alignItems: 'center' },
818 faces: { flexDirection: 'row' },
819 face: { width: 30, height: 30, borderRadius: 15, borderWidth: 2, borderColor: '#fff', backgroundColor: '#5B6470' },
820 faceOverlap: { marginLeft: -10 },
821 proof: { marginLeft: 10, fontSize: 14, color: 'rgba(255,255,255,0.86)' },
822 proofStrong: { fontWeight: '700', color: '#fff' },
823 dots: { flexDirection: 'row', alignItems: 'center', gap: 6 },
824 dot: { height: 6, borderRadius: 3, overflow: 'hidden', backgroundColor: 'rgba(255,255,255,0.42)' },
825 dotFill: { height: 6, borderRadius: 3, backgroundColor: '#fff' },
826
827 // Sign-in panel
828 panel: { paddingTop: 22, paddingHorizontal: 20, gap: 10, borderTopLeftRadius: 32, borderTopRightRadius: 32, borderTopWidth: 1 },
829 method: { height: 54, borderRadius: 16, borderWidth: 1.5, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 10 },
830 methodIcon: { width: 20, height: 20, alignItems: 'center', justifyContent: 'center' },
831 methodLabel: { fontSize: 16, fontWeight: '600', letterSpacing: -0.2 },
832 spinner: { borderWidth: 2.2, borderColor: 'rgba(140,140,150,0.35)' },
833 textButton: { height: 44, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 },
834 textButtonLabel: { fontSize: 15, fontWeight: '600' },
835 footer: { alignItems: 'center', gap: 10, marginTop: 2 },
836 signInRow: { flexDirection: 'row', alignItems: 'center', gap: 5 },
837 signInText: { fontSize: 15 },
838 signInLink: { fontSize: 15, fontWeight: '700' },
839 legal: { fontSize: 12, lineHeight: 17, textAlign: 'center' },
840 legalLink: { fontWeight: '600', textDecorationLine: 'underline' },
841
842 // Sheets
843 overlay: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: 10 },
844 scrim: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, backgroundColor: 'rgba(0,0,0,0.55)' },
845 sheetDock: { flex: 1, justifyContent: 'flex-end' },
846 modal: { paddingTop: 10, paddingHorizontal: 20, borderTopLeftRadius: 28, borderTopRightRadius: 28, borderTopWidth: 1 },
847 grabber: { alignSelf: 'center', width: 38, height: 5, borderRadius: 3, marginBottom: 18 },
848 stepTitle: { fontSize: 24, fontWeight: '700', letterSpacing: -0.6 },
849 stepHint: { marginTop: 6, fontSize: 15, lineHeight: 21 },
850 field: { marginTop: 20, height: 56, borderRadius: 16, borderWidth: 1.5, paddingHorizontal: 16, flexDirection: 'row', alignItems: 'center', gap: 12 },
851 prefix: { fontSize: 16, fontWeight: '600', paddingRight: 12, borderRightWidth: 1 },
852 fieldInput: { flex: 1, height: '100%', fontSize: 16 },
853 validTick: { width: 22, height: 22, borderRadius: 11, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },
854 errorSlot: { height: 28, justifyContent: 'center' },
855 fieldError: { fontSize: 13, marginLeft: 4 },
856 send: {
857 height: 56,
858 borderRadius: 16,
859 flexDirection: 'row',
860 alignItems: 'center',
861 justifyContent: 'center',
862 gap: 8,
863 backgroundColor: ACCENT,
864 shadowColor: ACCENT,
865 shadowOpacity: 0.32,
866 shadowRadius: 16,
867 shadowOffset: { width: 0, height: 8 },
868 },
869 sendLabel: { fontSize: 16, fontWeight: '600', color: ON_ACCENT },
870 sent: { alignItems: 'center', paddingTop: 4 },
871 sentBadge: { width: 76, height: 76, borderRadius: 38, alignItems: 'center', justifyContent: 'center', marginBottom: 16 },
872 sentTick: { width: 48, height: 48, borderRadius: 24, alignItems: 'center', justifyContent: 'center', backgroundColor: SUCCESS },
873 sentDone: { alignSelf: 'stretch', marginTop: 22, height: 54, borderRadius: 16, alignItems: 'center', justifyContent: 'center' },
874
875 langList: { marginTop: 12, marginHorizontal: -8 },
876 langRow: { height: 52, paddingHorizontal: 8, borderRadius: 14, flexDirection: 'row', alignItems: 'center', gap: 12 },
877 langBadge: { width: 36, height: 26, borderRadius: 8, overflow: 'hidden', textAlign: 'center', lineHeight: 26, fontSize: 12, fontWeight: '700', letterSpacing: 0.4 },
878 langName: { fontSize: 16, fontWeight: '600' },
879 langNote: { fontSize: 14 },
880
881 // Toast
882 toastDock: { position: 'absolute', left: 0, right: 0, alignItems: 'center', zIndex: 20 },
883 toast: {
884 height: 44,
885 paddingLeft: 12,
886 paddingRight: 18,
887 borderRadius: 22,
888 flexDirection: 'row',
889 alignItems: 'center',
890 gap: 9,
891 shadowColor: '#000',
892 shadowOpacity: 0.3,
893 shadowRadius: 18,
894 shadowOffset: { width: 0, height: 8 },
895 },
896 toastTick: { width: 22, height: 22, borderRadius: 11, alignItems: 'center', justifyContent: 'center', backgroundColor: SUCCESS },
897 toastText: { fontSize: 14, fontWeight: '600' },
898});

More screens like this.

All Authentication