Profile setup

The first-run profile step with motion: tap the avatar for a draggable sheet of photos, drawn avatars and initials on a colour you cycle, each swap cross-fading in with a pop and a ripple. The username check is debounced (spinner, then Available, or Taken with three suggestions that fill the field), bad characters shake the row with an inline error, the bio ring fills and turns amber near the limit, a live preview card flashes each line as you type, and Continue sweeps in its colour once ready, then celebrates with a confetti burst while the step dots advance.

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

Details

File
components/patterns/profile-setup.tsx
Lines
1554
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/profile-setup.tsx
1import { useEffect, useMemo, useRef, useState, type ComponentRef, type ReactNode } from 'react';
2import {
3 Image,
4 KeyboardAvoidingView,
5 PanResponder,
6 Platform,
7 Pressable,
8 StyleSheet,
9 Text,
10 TextInput,
11 View,
12 useColorScheme,
13 useWindowDimensions,
14 type LayoutChangeEvent,
15 type StyleProp,
16 type ViewStyle,
17} from 'react-native';
18import Animated, {
19 cancelAnimation,
20 Easing,
21 FadeIn,
22 FadeInDown,
23 interpolate,
24 interpolateColor,
25 runOnJS,
26 useAnimatedProps,
27 useAnimatedScrollHandler,
28 useAnimatedStyle,
29 useSharedValue,
30 withDelay,
31 withRepeat,
32 withSequence,
33 withSpring,
34 withTiming,
35 ZoomIn,
36 type SharedValue,
37} from 'react-native-reanimated';
38import { LinearGradient } from 'expo-linear-gradient';
39import { useSafeAreaInsets } from 'react-native-safe-area-context';
40import Svg, { Circle, Defs, Ellipse, LinearGradient as SvgGradient, Path, Rect, Stop } from 'react-native-svg';
41import { ArrowRight, AtSign, Camera, Check, ChevronLeft, CircleAlert, Eye, Hand, ImagePlus, Shuffle, X } from 'lucide-react-native';
42
43// ─── Brand ──────────────────────────────────────────────────────────────────
44// The screen's accent and name. Every accent colour below derives from these, so changing them rebrands the screen.
45
46const ACCENT = '#12B886';
47const ACCENT_DARK = '#38D9A9'; // the accent as text on dark backgrounds
48const ON_ACCENT = '#032B1E'; // text and icons on an accent fill
49const APP_NAME = 'Kinlo';
50
51/** `hex` at `alpha` opacity, as rgba(). */
52function tint(hex: string, alpha: number) {
53 const n = parseInt(hex.slice(1), 16);
54 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;
55}
56
57/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */
58function shade(hex: string, amount: number) {
59 const n = parseInt(hex.slice(1), 16);
60 const target = amount < 0 ? 255 : 0;
61 const p = Math.abs(amount);
62 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');
63 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();
64}
65
66/** `hex` with its hue turned by `deg` degrees and its HSL lightness and saturation moved by `light` / `sat` (-1 to 1).
67 * For accent-related colours of a different hue (an amber-to-coral gradient from one accent). */
68function spin(hex: string, deg: number, light = 0, sat = 0) {
69 const n = parseInt(hex.slice(1), 16);
70 const r = ((n >> 16) & 255) / 255;
71 const g = ((n >> 8) & 255) / 255;
72 const b = (n & 255) / 255;
73 const max = Math.max(r, g, b);
74 const min = Math.min(r, g, b);
75 const d = max - min;
76 const s = Math.min(1, Math.max(0, (d === 0 ? 0 : d / (1 - Math.abs(max + min - 1))) + sat));
77 const l = Math.min(1, Math.max(0, (max + min) / 2 + light));
78 const h0 = d === 0 ? 0 : max === r ? ((g - b) / d + 6) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
79 const h = (((h0 * 60 + deg) % 360) + 360) % 360;
80 const a = s * Math.min(l, 1 - l);
81 const f = (m: number) => {
82 const k = (m + h / 30) % 12;
83 return Math.round(255 * (l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1)))).toString(16).padStart(2, '0');
84 };
85 return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();
86}
87
88// ─── Sample data ────────────────────────────────────────────────────────────
89
90// Step 2 opens part filled (the name comes from sign-up), so the preview card has something to show.
91const PREFILL = {
92 name: 'Maya Brennan',
93 username: 'maya.brennan',
94 bio: 'Film photographer and weekend hiker. Up for slow coffee and long walks.',
95 pronouns: 'she/her',
96};
97
98// What the availability check answers "taken" for. Replace with your API.
99const TAKEN = ['maya', 'mayab', 'maya.b', 'brennan', 'mayabrennan', 'admin', 'support', 'hello', APP_NAME.toLowerCase()];
100
101const PRONOUNS = ['she/her', 'he/him', 'they/them', 'she/they', 'he/they'];
102
103const photo = (id: string) => `https://images.unsplash.com/photo-${id}?w=240&q=80&fit=crop`;
104
105type Portrait = { id: string; uri: string; alt: string; base: string };
106
107// One size for every place a photo shows, so each loads once and the swap is instant.
108const PORTRAITS: Portrait[] = [
109 { id: 'smile', uri: photo('1580489944761-15a19d654956'), alt: 'Smiling, hair up, against a pale wall', base: '#D8D3CE' },
110 { id: 'collar', uri: photo('1531123897727-8f129e1688ce'), alt: 'Short hair and a white collar, warm backdrop', base: '#5B3A2E' },
111 { id: 'dusk', uri: photo('1544005313-94ddf0286df2'), alt: 'Long hair and a striped shirt at dusk', base: '#4E4034' },
112 { id: 'denim', uri: photo('1488426862026-3ee34a7d66df'), alt: 'Denim jacket against a pink wall', base: '#E7B9B2' },
113];
114
115type ArtId = 'sunny' | 'tide' | 'sprout' | 'moon' | 'kit' | 'peaks';
116type Art = { id: ArtId; name: string; from: string; to: string };
117
118// Drawn avatars. Their colours are part of each drawing, not the app's brand.
119const ARTS: Art[] = [
120 { id: 'sunny', name: 'Sunny face', from: '#FFC46B', to: '#FF7A59' },
121 { id: 'tide', name: 'Tide', from: '#7FD3FF', to: '#2F6FE0' },
122 { id: 'sprout', name: 'Sprout', from: '#DDF57A', to: '#38B26B' },
123 { id: 'moon', name: 'Night moon', from: '#22406B', to: '#0F7A72' },
124 { id: 'kit', name: 'Black cat', from: '#FFDD75', to: '#F5953A' },
125 { id: 'peaks', name: 'Peaks', from: '#FFB8C6', to: '#FF5F7E' },
126];
127
128// Colours the initials avatar cycles through.
129const INITIAL_COLORS = [
130 { name: 'Coral', bg: '#FF6B57', ink: '#FFFFFF' },
131 { name: 'Marigold', bg: '#FFB020', ink: '#3A2600' },
132 { name: 'Sea', bg: '#0E9F8E', ink: '#FFFFFF' },
133 { name: 'Sky', bg: '#2F80ED', ink: '#FFFFFF' },
134 { name: 'Rose', bg: '#E8508A', ink: '#FFFFFF' },
135 { name: 'Graphite', bg: '#2B2D31', ink: '#FFFFFF' },
136];
137
138const NAME_MAX = 32;
139const HANDLE_MAX = 24;
140const HANDLE_RE = /^[a-z0-9._]+$/;
141const BIO_LIMIT = 120;
142const BIO_NEAR = 20; // the ring warns and shows the count when this many are left
143const CHECK_DELAY = 600; // debounce before the availability call
144
145// ─── Palette ────────────────────────────────────────────────────────────────
146
147const POP = { damping: 14, stiffness: 300, mass: 0.6 };
148const PRESS = { damping: 16, stiffness: 320, mass: 0.6 };
149const TABULAR = { fontVariant: ['tabular-nums' as const] };
150const NO_OUTLINE = Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null;
151
152const AVATAR = 104;
153const HEADER_ROW = 52;
154const BUTTON_H = 56;
155const COLUMN = 520;
156
157// The avatar ring runs from a greener to a bluer take on the accent.
158const RING_COLORS = [spin(ACCENT, -30, 0.06), ACCENT, spin(ACCENT, 36, -0.02)] as const;
159const FLASH_ON = tint(ACCENT, 0.22);
160const FLASH_OFF = tint(ACCENT, 0);
161const CONFETTI_TONES = [ACCENT, spin(ACCENT, 40, 0.1), '#FFB020', '#FF6B57', '#2F80ED'];
162
163function usePalette() {
164 const dark = useColorScheme() === 'dark';
165 return {
166 dark,
167 bg: dark ? '#0A0A0B' : '#F6F6F7',
168 surface: dark ? '#161618' : '#FFFFFF',
169 surfaceClear: dark ? 'rgba(22, 22, 24, 0)' : 'rgba(255, 255, 255, 0)',
170 sheet: dark ? '#19191C' : '#FFFFFF',
171 fg: dark ? '#F5F5F6' : '#0B0B0C',
172 muted: dark ? '#8D8D95' : '#6B6B73',
173 faint: dark ? '#56565E' : '#A6A6AE',
174 line: dark ? '#26262A' : '#ECECEF',
175 chip: dark ? '#242428' : '#F0F0F2',
176 track: dark ? '#2E2E33' : '#E3E3E7',
177 dotIdle: dark ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.14)',
178 accentText: dark ? ACCENT_DARK : shade(ACCENT, 0.32),
179 accentSoft: dark ? tint(ACCENT, 0.16) : tint(ACCENT, 0.12),
180 focusOn: dark ? tint(ACCENT, 0.08) : tint(ACCENT, 0.05),
181 focusOff: tint(ACCENT, 0),
182 bloom: dark ? tint(ACCENT, 0.2) : tint(ACCENT, 0.2),
183 bloomEnd: tint(ACCENT, 0),
184 success: dark ? '#3DD68C' : '#16A34A',
185 successSoft: dark ? 'rgba(61, 214, 140, 0.14)' : 'rgba(22, 163, 74, 0.10)',
186 onSuccess: dark ? '#05210F' : '#FFFFFF',
187 warn: dark ? '#FFB547' : '#D97706',
188 error: dark ? '#FF6B6B' : '#E5484D',
189 cardShadow: dark ? '0px 0px 0px 1px rgba(255, 255, 255, 0.06)' : '0px 1px 2px rgba(0, 0, 0, 0.04), 0px 8px 24px rgba(0, 0, 0, 0.05)',
190 swatchEdge: dark ? 'rgba(255, 255, 255, 0.16)' : 'rgba(0, 0, 0, 0.06)',
191 scrim: dark ? 'rgba(0, 0, 0, 0.62)' : 'rgba(10, 10, 12, 0.38)',
192 };
193}
194type Palette = ReturnType<typeof usePalette>;
195
196// ─── Profile rules ──────────────────────────────────────────────────────────
197
198type Avail = 'empty' | 'short' | 'invalid' | 'checking' | 'available' | 'taken';
199type Choice = { kind: 'photo'; id: string } | { kind: 'art'; id: ArtId } | { kind: 'initials' };
200type Status = 'idle' | 'saving' | 'done';
201type FieldId = 'name' | 'username' | 'bio';
202
203const firstName = (name: string) => name.trim().split(/\s+/)[0] || 'friend';
204const initialsOf = (name: string) =>
205 name
206 .trim()
207 .split(/\s+/)
208 .slice(0, 2)
209 .map((w) => w.charAt(0).toUpperCase())
210 .join('') || '?';
211const keyOf = (choice: Choice, hue: number) => (choice.kind === 'initials' ? `initials-${hue}` : `${choice.kind}-${choice.id}`);
212
213/** Three free handles built from the name and the one that was taken. */
214function suggestionsFor(handle: string, name: string) {
215 const words = name.toLowerCase().replace(/[^a-z\s]/g, '').trim().split(/\s+/).filter(Boolean);
216 const first = words[0] ?? handle;
217 const last = words[1] ?? '';
218 const n = 10 + ([...handle].reduce((sum, ch) => sum + ch.charCodeAt(0), 0) % 89);
219 const ideas = [last ? `${first}.${last}` : `${handle}.hq`, `${handle}_${n}`, `hey.${handle}`, last ? `${first}_${last}` : `the.${handle}`, `${handle}.${APP_NAME.toLowerCase()}`];
220 return ideas.filter((s, i) => s !== handle && s.length <= HANDLE_MAX && HANDLE_RE.test(s) && !TAKEN.includes(s) && ideas.indexOf(s) === i).slice(0, 3);
221}
222
223// ─── Small pieces ───────────────────────────────────────────────────────────
224
225function Tap({ children, label, onPress, to = 0.94, style }: { children: ReactNode; label: string; onPress?: () => void; to?: number; style?: StyleProp<ViewStyle> }) {
226 const scale = useSharedValue(1);
227 const pressed = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
228 return (
229 <Pressable role="button" aria-label={label} onPress={onPress} hitSlop={6} onPressIn={() => (scale.value = withSpring(to, PRESS))} onPressOut={() => (scale.value = withSpring(1, PRESS))} style={style}>
230 <Animated.View style={pressed}>{children}</Animated.View>
231 </Pressable>
232 );
233}
234
235function Spinner({ size = 16, color, track }: { size?: number; color: string; track: string }) {
236 const turn = useSharedValue(0);
237 useEffect(() => {
238 turn.value = withRepeat(withTiming(360, { duration: 720, easing: Easing.linear }), -1);
239 return () => cancelAnimation(turn);
240 }, [turn]);
241 const style = useAnimatedStyle(() => ({ transform: [{ rotate: `${turn.value}deg` }] }));
242 return <Animated.View style={[styles.spinner, { width: size, height: size, borderRadius: size / 2, borderColor: track, borderTopColor: color }, style]} />;
243}
244
245/** Keeps an overlay mounted while it animates out. `p` runs 0 (hidden) to 1 (open). */
246function useReveal(open: boolean, duration = 300) {
247 const [mounted, setMounted] = useState(open);
248 const p = useSharedValue(open ? 1 : 0);
249 useEffect(() => {
250 if (open) {
251 setMounted(true);
252 p.value = withTiming(1, { duration, easing: Easing.out(Easing.cubic) });
253 } else {
254 p.value = withTiming(0, { duration: 220, easing: Easing.in(Easing.quad) }, (done) => {
255 if (done) runOnJS(setMounted)(false);
256 });
257 }
258 }, [open, duration, p]);
259 return { mounted, p };
260}
261
262/** Animates its height to fit what is inside, and keeps the last content while it closes. */
263function Collapse({ open, children }: { open: boolean; children: ReactNode }) {
264 const kept = useRef<ReactNode>(null);
265 if (open) kept.current = children;
266 const [inner, setInner] = useState(0);
267 const height = useSharedValue(0);
268 const shown = useSharedValue(0);
269 useEffect(() => {
270 height.value = withTiming(open ? inner : 0, { duration: 260, easing: Easing.out(Easing.cubic) });
271 shown.value = withTiming(open ? 1 : 0, { duration: open ? 280 : 160 });
272 }, [open, inner, height, shown]);
273 const style = useAnimatedStyle(() => ({ height: height.value, opacity: shown.value }));
274 return (
275 <Animated.View style={[styles.collapse, style]}>
276 <View style={styles.collapseInner} onLayout={(e: LayoutChangeEvent) => setInner(e.nativeEvent.layout.height)}>
277 {kept.current}
278 </View>
279 </Animated.View>
280 );
281}
282
283/** A round photo that shimmers on its own tint, then fades in once loaded. */
284function Photo({ item, size }: { item: Portrait; size: number }) {
285 const shown = useSharedValue(0);
286 const pulse = useSharedValue(0);
287 useEffect(() => {
288 pulse.value = withRepeat(withSequence(withTiming(1, { duration: 700 }), withTiming(0, { duration: 700 })), -1);
289 return () => cancelAnimation(pulse);
290 }, [pulse]);
291 const image = useAnimatedStyle(() => ({ opacity: shown.value }));
292 const sheen = useAnimatedStyle(() => ({ opacity: (1 - shown.value) * pulse.value * 0.25 }));
293 return (
294 <View style={[styles.round, { width: size, height: size, borderRadius: size / 2, backgroundColor: item.base }]}>
295 <Animated.View style={[StyleSheet.absoluteFill, styles.sheen, sheen]} />
296 <Animated.View style={[StyleSheet.absoluteFill, image]}>
297 <Image
298 source={{ uri: item.uri }}
299 alt={item.alt}
300 resizeMode="cover"
301 style={styles.fillImage}
302 onLoad={() => {
303 cancelAnimation(pulse);
304 shown.value = withTiming(1, { duration: 280 });
305 }}
306 />
307 </Animated.View>
308 </View>
309 );
310}
311
312/** A gradient ring with a gap, drawn around an avatar. */
313function Ring({ size, gap, width, bg, children }: { size: number; gap: number; width: number; bg: string; children: ReactNode }) {
314 const outer = size + (gap + width) * 2;
315 const innerSize = size + gap * 2;
316 return (
317 <LinearGradient colors={RING_COLORS} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={[styles.center, { width: outer, height: outer, borderRadius: outer / 2 }]}>
318 <View style={[styles.center, { width: innerSize, height: innerSize, borderRadius: innerSize / 2, backgroundColor: bg }]}>{children}</View>
319 </LinearGradient>
320 );
321}
322
323// ─── Avatars: photos, drawn art and initials ────────────────────────────────
324
325function ArtMotif({ id }: { id: ArtId }) {
326 switch (id) {
327 case 'sunny':
328 return (
329 <>
330 <Path d="M50 31 C47 24 41 21 35 22 C38 28 43 31 50 31 Z" fill="#3C9A4E" />
331 <Path d="M50 31 C53 25 58 23 63 24 C60 29 56 31 50 31 Z" fill="#53B862" />
332 <Circle cx="50" cy="58" r="27" fill="#FFF0D6" />
333 <Circle cx="41" cy="55" r="3.4" fill="#3B2A20" />
334 <Circle cx="59" cy="55" r="3.4" fill="#3B2A20" />
335 <Ellipse cx="35" cy="64" rx="5" ry="3.2" fill="#FF9F8A" opacity={0.8} />
336 <Ellipse cx="65" cy="64" rx="5" ry="3.2" fill="#FF9F8A" opacity={0.8} />
337 <Path d="M43 65 Q50 72 57 65" stroke="#3B2A20" strokeWidth={3} strokeLinecap="round" fill="none" />
338 </>
339 );
340 case 'tide':
341 return (
342 <>
343 <Circle cx="68" cy="32" r="11" fill="#FFE99A" />
344 <Path d="M0 56 Q12.5 48 25 56 T50 56 T75 56 T100 56 V100 H0 Z" fill="#FFFFFF" opacity={0.3} />
345 <Path d="M0 68 Q12.5 60 25 68 T50 68 T75 68 T100 68 V100 H0 Z" fill="#FFFFFF" opacity={0.5} />
346 <Path d="M0 80 Q12.5 72 25 80 T50 80 T75 80 T100 80 V100 H0 Z" fill="#FFFFFF" opacity={0.88} />
347 </>
348 );
349 case 'sprout':
350 return (
351 <>
352 <Ellipse cx="50" cy="80" rx="20" ry="5" fill="#1D5C38" opacity={0.3} />
353 <Path d="M50 80 V48" stroke="#1D5C38" strokeWidth={4} strokeLinecap="round" />
354 <Path d="M50 62 C37 62 28 52 28 40 C41 40 50 49 50 62 Z" fill="#1F7A46" />
355 <Path d="M50 54 C63 54 72 44 72 32 C59 32 50 41 50 54 Z" fill="#2A9A58" />
356 </>
357 );
358 case 'moon':
359 return (
360 <>
361 <Circle cx="24" cy="26" r="1.6" fill="#FFFFFF" opacity={0.9} />
362 <Circle cx="80" cy="20" r="1.2" fill="#FFFFFF" opacity={0.8} />
363 <Circle cx="16" cy="52" r="1.2" fill="#FFFFFF" opacity={0.7} />
364 <Circle cx="84" cy="56" r="1.6" fill="#FFFFFF" opacity={0.8} />
365 <Circle cx="54" cy="44" r="19" fill="#FFF2CC" />
366 <Circle cx="47" cy="39" r="4" fill="#EEDCA6" />
367 <Circle cx="60" cy="50" r="5.5" fill="#EEDCA6" />
368 <Circle cx="59" cy="35" r="2.5" fill="#EEDCA6" />
369 <Path d="M0 82 Q25 68 50 80 T100 76 V100 H0 Z" fill="#0B3B4A" opacity={0.85} />
370 </>
371 );
372 case 'kit':
373 return (
374 <>
375 <Path d="M30 50 L32 26 L48 38 Z" fill="#2E211B" />
376 <Path d="M70 50 L68 26 L52 38 Z" fill="#2E211B" />
377 <Path d="M34 44 L35 32 L43 39 Z" fill="#FF9F8A" opacity={0.6} />
378 <Path d="M66 44 L65 32 L57 39 Z" fill="#FF9F8A" opacity={0.6} />
379 <Circle cx="50" cy="57" r="24" fill="#2E211B" />
380 <Ellipse cx="41" cy="54" rx="4" ry="5" fill="#FFD86B" />
381 <Ellipse cx="59" cy="54" rx="4" ry="5" fill="#FFD86B" />
382 <Ellipse cx="41" cy="54.5" rx="1.4" ry="3.4" fill="#2E211B" />
383 <Ellipse cx="59" cy="54.5" rx="1.4" ry="3.4" fill="#2E211B" />
384 <Path d="M46.5 63 H53.5 L50 67 Z" fill="#FF9F8A" />
385 <Path d="M28 63 L40 65 M28 69 L40 67 M72 63 L60 65 M72 69 L60 67" stroke="#FFE7B0" strokeWidth={1.4} strokeLinecap="round" opacity={0.7} />
386 </>
387 );
388 case 'peaks':
389 return (
390 <>
391 <Circle cx="68" cy="32" r="9" fill="#FFF3D1" />
392 <Path d="M0 86 L30 46 L48 68 L64 50 L100 86 V100 H0 Z" fill="#FFFFFF" opacity={0.55} />
393 <Path d="M0 96 L24 66 L40 82 L62 58 L100 96 V100 H0 Z" fill="#FFFFFF" opacity={0.95} />
394 </>
395 );
396 }
397}
398
399function ArtAvatar({ art, size }: { art: Art; size: number }) {
400 return (
401 <View aria-label={art.name} style={[styles.round, { width: size, height: size, borderRadius: size / 2 }]}>
402 <Svg width={size} height={size} viewBox="0 0 100 100">
403 <Defs>
404 <SvgGradient id={`art-${art.id}`} x1="0" y1="0" x2="1" y2="1">
405 <Stop offset="0" stopColor={art.from} />
406 <Stop offset="1" stopColor={art.to} />
407 </SvgGradient>
408 </Defs>
409 <Rect x="0" y="0" width="100" height="100" fill={`url(#art-${art.id})`} />
410 <ArtMotif id={art.id} />
411 </Svg>
412 </View>
413 );
414}
415
416function InitialsAvatar({ text, hue, size }: { text: string; hue: number; size: number }) {
417 const color = INITIAL_COLORS[hue];
418 return (
419 <View aria-label={`Initials ${text} on ${color.name}`} style={[styles.round, styles.center, { width: size, height: size, borderRadius: size / 2, backgroundColor: color.bg }]}>
420 <Text style={[styles.initials, { color: color.ink, fontSize: size * 0.37, letterSpacing: size * -0.01 }]}>{text}</Text>
421 </View>
422 );
423}
424
425function AvatarView({ choice, hue, initials, size }: { choice: Choice; hue: number; initials: string; size: number }) {
426 if (choice.kind === 'photo') return <Photo item={PORTRAITS.find((p) => p.id === choice.id) ?? PORTRAITS[0]} size={size} />;
427 if (choice.kind === 'art') return <ArtAvatar art={ARTS.find((a) => a.id === choice.id) ?? ARTS[0]} size={size} />;
428 return <InitialsAvatar text={initials} hue={hue} size={size} />;
429}
430
431function SwapLayer({ fresh, children }: { fresh: boolean; children: ReactNode }) {
432 const t = useSharedValue(fresh ? 0 : 1);
433 useEffect(() => {
434 if (fresh) t.value = withTiming(1, { duration: 420, easing: Easing.out(Easing.back(2.2)) });
435 // eslint-disable-next-line react-hooks/exhaustive-deps
436 }, []);
437 const style = useAnimatedStyle(() => ({ opacity: Math.min(1, t.value * 1.8), transform: [{ scale: 0.72 + t.value * 0.28 }] }));
438 return <Animated.View style={[StyleSheet.absoluteFill, styles.center, style]}>{children}</Animated.View>;
439}
440
441/** The new avatar pops in over the old one, which stays underneath until the cross-fade ends. */
442function AvatarSwap({ choice, hue, initials, size }: { choice: Choice; hue: number; initials: string; size: number }) {
443 const key = keyOf(choice, hue);
444 const serial = useRef(0);
445 const [layers, setLayers] = useState([{ id: 0, key, choice, hue, fresh: false }]);
446 const top = layers[layers.length - 1];
447 if (top.key !== key) {
448 serial.current += 1;
449 setLayers([...layers.slice(-1), { id: serial.current, key, choice, hue, fresh: true }]);
450 }
451 useEffect(() => {
452 if (layers.length < 2) return;
453 const id = setTimeout(() => setLayers((l) => l.slice(-1)), 460);
454 return () => clearTimeout(id);
455 }, [layers]);
456 return (
457 <View style={{ width: size, height: size }}>
458 {layers.map((l) => (
459 <SwapLayer key={l.id} fresh={l.fresh}>
460 <AvatarView choice={l.choice} hue={l.hue} initials={initials} size={size} />
461 </SwapLayer>
462 ))}
463 </View>
464 );
465}
466
467// ─── Header: step dots ──────────────────────────────────────────────────────
468
469function Dot({ index, step, pal }: { index: number; step: SharedValue<number>; pal: Palette }) {
470 const style = useAnimatedStyle(() => {
471 const away = Math.min(1, Math.abs(step.value - index));
472 const reached = Math.max(0, Math.min(1, step.value - index + 1));
473 return { width: 8 + (1 - away) * 20, backgroundColor: interpolateColor(reached, [0, 1], [pal.dotIdle, ACCENT]) };
474 });
475 return <Animated.View style={[styles.dot, style]} />;
476}
477
478function StepDots({ step, current, total, pal }: { step: SharedValue<number>; current: number; total: number; pal: Palette }) {
479 return (
480 <View role="progressbar" aria-label={`Step ${current} of ${total}`} aria-valuenow={current} aria-valuemin={1} aria-valuemax={total} style={styles.dots}>
481 {Array.from({ length: total }, (_, i) => (
482 <Dot key={i} index={i + 1} step={step} pal={pal} />
483 ))}
484 </View>
485 );
486}
487
488// ─── Hero avatar: tap to change, pops and ripples on every swap ─────────────
489
490function HeroAvatar({ choice, hue, initials, onPress, pal }: { choice: Choice; hue: number; initials: string; onPress: () => void; pal: Palette }) {
491 const key = keyOf(choice, hue);
492 const pop = useSharedValue(0.55);
493 const ripple = useSharedValue(0);
494 const press = useSharedValue(1);
495 const booted = useRef(false);
496 useEffect(() => {
497 if (!booted.current) {
498 booted.current = true;
499 pop.value = withDelay(60, withSpring(1, { damping: 11, stiffness: 150, mass: 0.7 }));
500 return;
501 }
502 pop.value = withSequence(withTiming(1.09, { duration: 140, easing: Easing.out(Easing.cubic) }), withTiming(1, { duration: 280, easing: Easing.out(Easing.back(2.6)) }));
503 ripple.value = 0;
504 ripple.value = withTiming(1, { duration: 760, easing: Easing.out(Easing.cubic) });
505 }, [key, pop, ripple]);
506 const body = useAnimatedStyle(() => ({ opacity: Math.min(1, (pop.value - 0.55) * 4), transform: [{ scale: pop.value * press.value }] }));
507 const ring = useAnimatedStyle(() => ({ opacity: interpolate(ripple.value, [0, 0.08, 1], [0, 0.6, 0]), transform: [{ scale: 1 + ripple.value * 0.5 }] }));
508 const outer = AVATAR + 14;
509 return (
510 <Pressable
511 role="button"
512 aria-label="Change profile picture"
513 onPress={onPress}
514 onPressIn={() => (press.value = withSpring(0.95, PRESS))}
515 onPressOut={() => (press.value = withSpring(1, PRESS))}
516 style={styles.heroPress}
517 >
518 <Animated.View style={[styles.heroRipple, { width: outer, height: outer, borderRadius: outer / 2 }, ring]} />
519 <Animated.View style={[styles.heroGlow, body]}>
520 <Ring size={AVATAR} gap={4} width={3} bg={pal.bg}>
521 <AvatarSwap choice={choice} hue={hue} initials={initials} size={AVATAR} />
522 </Ring>
523 <Animated.View entering={ZoomIn.delay(380).duration(260)} style={[styles.cameraBadge, { borderColor: pal.bg }]}>
524 <Camera size={16} color={ON_ACCENT} strokeWidth={2.4} />
525 </Animated.View>
526 </Animated.View>
527 </Pressable>
528 );
529}
530
531// ─── Form rows ──────────────────────────────────────────────────────────────
532
533/** A field row: the label in a column on the left, or above the value when `stacked`. The row washes with the accent while focused. */
534function Row({
535 label,
536 hint,
537 focused,
538 stacked,
539 flush,
540 accessory,
541 onPress,
542 children,
543 pal,
544}: {
545 label: string;
546 hint?: string;
547 focused: boolean;
548 stacked?: boolean;
549 flush?: boolean;
550 accessory?: ReactNode;
551 onPress?: () => void;
552 children: ReactNode;
553 pal: Palette;
554}) {
555 const f = useSharedValue(0);
556 useEffect(() => {
557 f.value = withTiming(focused ? 1 : 0, { duration: 180 });
558 }, [focused, f]);
559 const wash = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(f.value, [0, 1], [pal.focusOff, pal.focusOn]) }));
560 const labelText = <Text style={[styles.rowLabel, { color: focused ? pal.accentText : pal.muted }]}>{label}</Text>;
561 return (
562 <Pressable focusable={false} onPress={onPress}>
563 {stacked ? (
564 <Animated.View style={[styles.rowStacked, wash]}>
565 <View style={styles.rowStackedHead}>
566 {labelText}
567 {accessory}
568 </View>
569 {children}
570 </Animated.View>
571 ) : (
572 <Animated.View style={[styles.row, flush && styles.rowFlush, wash]}>
573 <View style={styles.rowLabelCol}>
574 {labelText}
575 {hint ? <Text style={[styles.rowHint, { color: pal.faint }]}>{hint}</Text> : null}
576 </View>
577 <View style={styles.rowValue}>{children}</View>
578 </Animated.View>
579 )}
580 </Pressable>
581 );
582}
583
584function Availability({ state, pal }: { state: Avail; pal: Palette }) {
585 if (state === 'checking') {
586 return (
587 <Animated.View key="checking" entering={FadeIn.duration(140)} role="status" aria-label="Checking availability" style={styles.availSpin}>
588 <Spinner size={17} color={ACCENT} track={pal.track} />
589 </Animated.View>
590 );
591 }
592 if (state === 'available' || state === 'taken') {
593 const good = state === 'available';
594 const tone = good ? pal.success : pal.error;
595 const Mark = good ? Check : X;
596 return (
597 <Animated.View key={state} entering={ZoomIn.duration(240)} role="status" style={[styles.availPill, { backgroundColor: good ? pal.successSoft : tint(tone, 0.12) }]}>
598 <View style={[styles.availMark, { backgroundColor: tone }]}>
599 <Mark size={10} color={pal.onSuccess} strokeWidth={3.8} />
600 </View>
601 <Text style={[styles.availText, { color: tone }]}>{good ? 'Available' : 'Taken'}</Text>
602 </Animated.View>
603 );
604 }
605 if (state === 'invalid') {
606 return (
607 <Animated.View key="invalid" entering={ZoomIn.duration(200)} style={styles.availSpin}>
608 <CircleAlert size={19} color={pal.error} strokeWidth={2.3} />
609 </Animated.View>
610 );
611 }
612 return null;
613}
614
615// ─── Bio counter: a ring that fills, then warns near the limit ──────────────
616
617const RING = 24;
618const RING_R = 9.5;
619const RING_LEN = 2 * Math.PI * RING_R;
620const AnimatedCircle = Animated.createAnimatedComponent(Circle);
621
622function CountRing({ count, pal }: { count: number; pal: Palette }) {
623 const share = Math.min(1, count / BIO_LIMIT);
624 const left = BIO_LIMIT - count;
625 const near = left <= BIO_NEAR;
626 const full = left <= 0;
627 const fill = useSharedValue(0);
628 const grow = useSharedValue(near ? 1 : 0);
629 const bump = useSharedValue(1);
630 const booted = useRef(false);
631 useEffect(() => {
632 // Sweeps in once on load, then follows each keystroke.
633 fill.value = booted.current ? withTiming(share, { duration: 200, easing: Easing.out(Easing.cubic) }) : withDelay(420, withTiming(share, { duration: 640, easing: Easing.out(Easing.cubic) }));
634 booted.current = true;
635 }, [share, fill]);
636 useEffect(() => {
637 grow.value = withSpring(near ? 1 : 0, POP);
638 }, [near, grow]);
639 useEffect(() => {
640 if (full) bump.value = withSequence(withTiming(1.25, { duration: 110 }), withTiming(1, { duration: 240, easing: Easing.out(Easing.back(2.4)) }));
641 }, [full, bump]);
642 const arc = useAnimatedProps(() => ({ strokeDashoffset: RING_LEN * (1 - fill.value) }));
643 const ring = useAnimatedStyle(() => ({ transform: [{ scale: (1 + grow.value * 0.22) * bump.value }, { rotate: '-90deg' }] }));
644 const tone = full ? pal.error : near ? pal.warn : ACCENT;
645 return (
646 <View role="status" aria-label={`${left} characters left`} style={styles.counter}>
647 {near ? (
648 <Animated.Text entering={FadeIn.duration(160)} style={[styles.counterLeft, { color: tone }, TABULAR]}>
649 {left}
650 </Animated.Text>
651 ) : null}
652 <Animated.View style={ring}>
653 <Svg width={RING} height={RING} viewBox={`0 0 ${RING} ${RING}`}>
654 <Circle cx={RING / 2} cy={RING / 2} r={RING_R} stroke={pal.track} strokeWidth={2.6} fill="none" />
655 <AnimatedCircle cx={RING / 2} cy={RING / 2} r={RING_R} stroke={tone} strokeWidth={2.6} strokeLinecap="round" strokeDasharray={`${RING_LEN} ${RING_LEN}`} animatedProps={arc} fill="none" />
656 </Svg>
657 </Animated.View>
658 </View>
659 );
660}
661
662// ─── Pronoun chips ──────────────────────────────────────────────────────────
663
664function Chip({ label, on, onPress, pal }: { label: string; on: boolean; onPress: () => void; pal: Palette }) {
665 const t = useSharedValue(on ? 1 : 0);
666 const scale = useSharedValue(1);
667 const booted = useRef(false);
668 useEffect(() => {
669 t.value = withTiming(on ? 1 : 0, { duration: 200 });
670 if (booted.current && on) scale.value = withSequence(withTiming(1.08, { duration: 110 }), withSpring(1, POP));
671 booted.current = true;
672 }, [on, t, scale]);
673 const body = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(t.value, [0, 1], [pal.chip, ACCENT]), transform: [{ scale: scale.value }] }));
674 const text = useAnimatedStyle(() => ({ color: interpolateColor(t.value, [0, 1], [pal.fg, ON_ACCENT]) }));
675 return (
676 <Pressable role="radio" aria-checked={on} aria-label={label} onPress={onPress} onPressIn={() => (scale.value = withSpring(0.92, PRESS))} onPressOut={() => (scale.value = withSpring(1, PRESS))}>
677 <Animated.View style={[styles.chip, body]}>
678 {on ? (
679 <Animated.View entering={ZoomIn.duration(200)}>
680 <Check size={13} color={ON_ACCENT} strokeWidth={3.2} />
681 </Animated.View>
682 ) : null}
683 <Animated.Text style={[styles.chipLabel, text]}>{label}</Animated.Text>
684 </Animated.View>
685 </Pressable>
686 );
687}
688
689/** A sideways chip row whose left edge fades in once it has scrolled, so chips never cut hard against the label. */
690function ChipScroller({ label, children, pal }: { label: string; children: ReactNode; pal: Palette }) {
691 const x = useSharedValue(0);
692 const onScroll = useAnimatedScrollHandler((e) => {
693 x.value = e.contentOffset.x;
694 });
695 const fade = useAnimatedStyle(() => ({ opacity: interpolate(x.value, [0, 16], [0, 1], 'clamp') }));
696 return (
697 <View style={styles.fill}>
698 <Animated.ScrollView horizontal onScroll={onScroll} scrollEventThrottle={16} showsHorizontalScrollIndicator={false} role="radiogroup" aria-label={label} contentContainerStyle={styles.chips}>
699 {children}
700 </Animated.ScrollView>
701 <Animated.View style={[styles.chipFade, fade]}>
702 <LinearGradient colors={[pal.surface, pal.surfaceClear]} start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }} style={styles.fill} />
703 </Animated.View>
704 </View>
705 );
706}
707
708// ─── Live preview card ──────────────────────────────────────────────────────
709
710/** A mint wash that flashes behind a line of the preview each time its value changes. */
711function useFlash(value: string) {
712 const f = useSharedValue(0);
713 const booted = useRef(false);
714 useEffect(() => {
715 if (!booted.current) {
716 booted.current = true;
717 return;
718 }
719 f.value = withSequence(withTiming(1, { duration: 80 }), withTiming(0, { duration: 720, easing: Easing.out(Easing.quad) }));
720 }, [value, f]);
721 return useAnimatedStyle(() => ({ backgroundColor: interpolateColor(f.value, [0, 1], [FLASH_OFF, FLASH_ON]) }));
722}
723
724function LiveDot({ signal, pal }: { signal: string; pal: Palette }) {
725 const ping = useSharedValue(0);
726 const booted = useRef(false);
727 useEffect(() => {
728 if (!booted.current) {
729 booted.current = true;
730 return;
731 }
732 ping.value = 0;
733 ping.value = withTiming(1, { duration: 700, easing: Easing.out(Easing.cubic) });
734 }, [signal, ping]);
735 const halo = useAnimatedStyle(() => ({ opacity: interpolate(ping.value, [0, 0.1, 1], [0, 0.55, 0]), transform: [{ scale: 1 + ping.value * 1.8 }] }));
736 return (
737 <View style={styles.live}>
738 <View style={styles.liveDotSlot}>
739 <Animated.View style={[styles.liveHalo, halo]} />
740 <View style={styles.liveDot} />
741 </View>
742 <Text style={[styles.liveText, { color: pal.accentText }]}>Live</Text>
743 </View>
744 );
745}
746
747function PreviewCard({ name, username, bio, pronouns, choice, hue, pal }: { name: string; username: string; bio: string; pronouns: string | null; choice: Choice; hue: number; pal: Palette }) {
748 const nameFlash = useFlash(name);
749 const handleFlash = useFlash(username);
750 const bioFlash = useFlash(bio);
751 const shownName = name.trim();
752 const shownBio = bio.trim();
753 return (
754 <View>
755 <View style={styles.previewHead}>
756 <Eye size={15} color={pal.muted} strokeWidth={2.2} />
757 <Text style={[styles.previewLabel, { color: pal.muted }]}>{`How people on ${APP_NAME} see you`}</Text>
758 <View style={styles.fill} />
759 <LiveDot signal={`${name}|${username}|${bio}|${pronouns}|${keyOf(choice, hue)}`} pal={pal} />
760 </View>
761 <View aria-label="Profile preview" style={[styles.previewCard, { backgroundColor: pal.surface, boxShadow: pal.cardShadow }]}>
762 <AvatarSwap choice={choice} hue={hue} initials={initialsOf(name)} size={52} />
763 <View style={styles.previewBody}>
764 <View style={styles.previewTop}>
765 <View style={styles.previewIdentity}>
766 <Animated.View style={[styles.flashLine, styles.selfStart, nameFlash]}>
767 <Text numberOfLines={1} style={[styles.previewName, { color: shownName ? pal.fg : pal.faint }]}>
768 {shownName || 'Your name'}
769 </Text>
770 </Animated.View>
771 <View style={styles.previewHandleRow}>
772 <Animated.View style={[styles.flashLine, styles.shrink, handleFlash]}>
773 <Text numberOfLines={1} style={[styles.previewHandle, { color: username ? pal.muted : pal.faint }]}>
774 @{username || 'username'}
775 </Text>
776 </Animated.View>
777 {pronouns ? (
778 <Animated.View key={pronouns} entering={ZoomIn.duration(220)} style={[styles.previewPronouns, { backgroundColor: pal.chip }]}>
779 <Text style={[styles.previewPronounsText, { color: pal.muted }]}>{pronouns}</Text>
780 </Animated.View>
781 ) : null}
782 </View>
783 </View>
784 <Tap label={`Say hi to ${firstName(name)}`} to={0.92}>
785 <View style={[styles.sayHi, { backgroundColor: pal.accentSoft }]}>
786 <Hand size={14} color={pal.accentText} strokeWidth={2.3} />
787 <Text style={[styles.sayHiText, { color: pal.accentText }]}>Say hi</Text>
788 </View>
789 </Tap>
790 </View>
791 <Animated.View style={[styles.flashLine, styles.selfStart, bioFlash]}>
792 <Text numberOfLines={2} style={[styles.previewBio, { color: shownBio ? pal.fg : pal.faint }]}>
793 {shownBio || 'Your bio shows up here.'}
794 </Text>
795 </Animated.View>
796 </View>
797 </View>
798 </View>
799 );
800}
801
802// ─── Continue: the accent sweeps in once the step is complete ───────────────
803
804function ContinueButton({ ready, status, width, nudge, onPress, pal }: { ready: boolean; status: Status; width: number; nudge: SharedValue<number>; onPress: () => void; pal: Palette }) {
805 const lit = ready || status !== 'idle';
806 const fill = useSharedValue(0);
807 const busy = useSharedValue(0);
808 const press = useSharedValue(1);
809 useEffect(() => {
810 fill.value = withTiming(lit ? 1 : 0, { duration: lit ? 480 : 280, easing: Easing.inOut(Easing.cubic) });
811 }, [lit, fill]);
812 useEffect(() => {
813 busy.value = withTiming(status === 'idle' ? 0 : 1, { duration: 200 });
814 }, [status, busy]);
815 const body = useAnimatedStyle(() => ({ transform: [{ translateX: nudge.value }, { scale: press.value }] }));
816 const sweep = useAnimatedStyle(() => ({ transform: [{ translateX: (fill.value - 1) * (width + 20) }] }));
817 const glow = useAnimatedStyle(() => ({ opacity: fill.value * 0.9 }));
818 const label = useAnimatedStyle(() => ({ color: interpolateColor(fill.value, [0.3, 0.8], [pal.muted, ON_ACCENT]), opacity: 1 - busy.value }));
819 const arrow = useAnimatedStyle(() => ({ opacity: fill.value * (1 - busy.value), transform: [{ translateX: (1 - fill.value) * -10 }] }));
820 return (
821 <Pressable
822 role="button"
823 aria-label={status === 'saving' ? 'Saving profile' : status === 'done' ? 'Profile saved' : 'Continue'}
824 aria-disabled={!ready}
825 aria-busy={status === 'saving'}
826 onPress={onPress}
827 onPressIn={() => (press.value = withSpring(0.97, PRESS))}
828 onPressOut={() => (press.value = withSpring(1, PRESS))}
829 >
830 <Animated.View style={[styles.cta, body]}>
831 <Animated.View style={[StyleSheet.absoluteFill, styles.ctaGlow, glow]} />
832 <View style={[StyleSheet.absoluteFill, styles.ctaClip, { backgroundColor: pal.track }]}>
833 <Animated.View style={[styles.ctaFill, { width: width + 20 }, sweep]}>
834 <LinearGradient colors={[tint('#FFFFFF', 0.28), tint('#FFFFFF', 0)]} start={{ x: 0, y: 0 }} end={{ x: 0, y: 1 }} style={styles.ctaSheen} />
835 </Animated.View>
836 </View>
837 {status === 'idle' ? (
838 <View style={styles.ctaRow}>
839 <Animated.Text style={[styles.ctaLabel, label]}>Continue</Animated.Text>
840 <Animated.View style={arrow}>
841 <ArrowRight size={19} color={ON_ACCENT} strokeWidth={2.5} />
842 </Animated.View>
843 </View>
844 ) : status === 'saving' ? (
845 <Animated.View key="saving" entering={FadeIn.delay(80).duration(160)}>
846 <Spinner size={22} color={ON_ACCENT} track={tint(ON_ACCENT, 0.2)} />
847 </Animated.View>
848 ) : (
849 <Animated.View key="done" entering={ZoomIn.duration(260)} style={styles.ctaRow}>
850 <Check size={20} color={ON_ACCENT} strokeWidth={3} />
851 <Text style={[styles.ctaLabel, styles.ctaOn]}>Profile saved</Text>
852 </Animated.View>
853 )}
854 </Animated.View>
855 </Pressable>
856 );
857}
858
859// ─── Avatar picker sheet: drag down or tap outside to close ─────────────────
860
861function Option({ size, selected, label, onPress, children }: { size: number; selected: boolean; label: string; onPress: () => void; children: ReactNode }) {
862 const on = useSharedValue(selected ? 1 : 0);
863 const press = useSharedValue(1);
864 useEffect(() => {
865 on.value = withSpring(selected ? 1 : 0, { damping: 14, stiffness: 240, mass: 0.7 });
866 }, [selected, on]);
867 const ring = useAnimatedStyle(() => ({ opacity: Math.min(1, on.value * 1.4), transform: [{ scale: interpolate(on.value, [0, 1], [1.22, 1]) }] }));
868 const face = useAnimatedStyle(() => ({ transform: [{ scale: press.value }] }));
869 const box = size + 10;
870 return (
871 <Pressable role="radio" aria-checked={selected} aria-label={label} onPress={onPress} onPressIn={() => (press.value = withSpring(0.9, PRESS))} onPressOut={() => (press.value = withSpring(1, PRESS))}>
872 <Animated.View style={[styles.center, { width: box, height: box }, face]}>
873 <Animated.View style={[StyleSheet.absoluteFill, styles.optionRing, { borderRadius: box / 2 }, ring]} />
874 {children}
875 {selected ? (
876 <Animated.View entering={ZoomIn.duration(220)} style={styles.optionCheck}>
877 <Check size={10} color={ON_ACCENT} strokeWidth={3.8} />
878 </Animated.View>
879 ) : null}
880 </Animated.View>
881 </Pressable>
882 );
883}
884
885function AvatarSheet({
886 open,
887 choice,
888 hue,
889 initials,
890 width,
891 onClose,
892 onPhoto,
893 onArt,
894 onInitials,
895 onSwatch,
896 pal,
897}: {
898 open: boolean;
899 choice: Choice;
900 hue: number;
901 initials: string;
902 width: number;
903 onClose: () => void;
904 onPhoto: (id: string) => void;
905 onArt: (id: ArtId) => void;
906 onInitials: () => void;
907 onSwatch: (i: number) => void;
908 pal: Palette;
909}) {
910 const insets = useSafeAreaInsets();
911 const { mounted, p } = useReveal(open, 340);
912 const drag = useSharedValue(0);
913 const closeRef = useRef(onClose);
914 useEffect(() => {
915 closeRef.current = onClose;
916 }, [onClose]);
917 useEffect(() => {
918 if (open) drag.value = 0;
919 }, [open, drag]);
920
921 // Dragging the top of the sheet follows the finger; a long or quick pull closes it.
922 const pan = useMemo(
923 () =>
924 PanResponder.create({
925 onStartShouldSetPanResponder: () => true,
926 onMoveShouldSetPanResponder: (_e, g) => Math.abs(g.dy) > 4,
927 onPanResponderMove: (_e, g) => {
928 drag.value = g.dy > 0 ? g.dy : g.dy / 5;
929 },
930 onPanResponderRelease: (_e, g) => {
931 if (g.dy > 110 || g.vy > 0.9) closeRef.current();
932 else drag.value = withSpring(0, { damping: 18, stiffness: 260 });
933 },
934 onPanResponderTerminate: () => {
935 drag.value = withSpring(0, { damping: 18, stiffness: 260 });
936 },
937 }),
938 [drag]
939 );
940
941 const backdrop = useAnimatedStyle(() => ({ opacity: p.value * (1 - Math.min(0.6, Math.max(0, drag.value) / 500)) }));
942 const sheet = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - p.value) * 560 + drag.value }] }));
943 if (!mounted) return null;
944 const isPhoto = (id: string) => choice.kind === 'photo' && choice.id === id;
945 const isArt = (id: ArtId) => choice.kind === 'art' && choice.id === id;
946 const isInitials = choice.kind === 'initials';
947
948 return (
949 <View style={[StyleSheet.absoluteFill, styles.sheetLayer, { pointerEvents: open ? 'auto' : 'none' }]}>
950 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: pal.scrim }, backdrop]}>
951 <Pressable role="button" aria-label="Close picture options" onPress={onClose} style={styles.fill} />
952 </Animated.View>
953 <Animated.View role="dialog" aria-label="Profile picture" style={[styles.sheet, { width, backgroundColor: pal.sheet, paddingBottom: insets.bottom + 14 }, sheet]}>
954 <View {...pan.panHandlers} style={styles.sheetHandle}>
955 <View style={[styles.grabber, { backgroundColor: pal.track }]} />
956 <View style={styles.sheetTitleRow}>
957 <View style={styles.fill}>
958 <Text role="heading" style={[styles.sheetTitle, { color: pal.fg }]}>
959 Profile picture
960 </Text>
961 <Text style={[styles.sheetSub, { color: pal.muted }]}>A photo, an avatar or your initials.</Text>
962 </View>
963 <Tap label="Close" onPress={onClose} to={0.88}>
964 <View style={[styles.sheetClose, { backgroundColor: pal.chip }]}>
965 <X size={17} color={pal.fg} strokeWidth={2.4} />
966 </View>
967 </Tap>
968 </View>
969 </View>
970
971 <Text style={[styles.sheetSection, { color: pal.muted }]}>PHOTOS</Text>
972 <View role="radiogroup" aria-label="Photos" style={styles.optionRow}>
973 <Tap label="Choose from library" to={0.9}>
974 <View style={[styles.libraryTile, { borderColor: pal.faint }]}>
975 <ImagePlus size={22} color={pal.fg} strokeWidth={1.9} />
976 </View>
977 </Tap>
978 {PORTRAITS.map((item, i) => (
979 <Option key={item.id} size={56} selected={isPhoto(item.id)} label={`Photo ${i + 1}`} onPress={() => onPhoto(item.id)}>
980 <Photo item={item} size={56} />
981 </Option>
982 ))}
983 </View>
984
985 <Text style={[styles.sheetSection, { color: pal.muted }]}>AVATARS</Text>
986 <View role="radiogroup" aria-label="Avatars" style={styles.optionRow}>
987 {ARTS.map((art) => (
988 <Option key={art.id} size={46} selected={isArt(art.id)} label={art.name} onPress={() => onArt(art.id)}>
989 <ArtAvatar art={art} size={46} />
990 </Option>
991 ))}
992 </View>
993
994 <Text style={[styles.sheetSection, { color: pal.muted }]}>INITIALS</Text>
995 <View style={styles.initialsRow}>
996 <Option size={56} selected={isInitials} label={isInitials ? 'Next colour for your initials' : 'Use your initials'} onPress={onInitials}>
997 <AvatarSwap choice={{ kind: 'initials' }} hue={hue} initials={initials} size={56} />
998 <View style={[styles.shuffleBadge, { backgroundColor: pal.sheet }]}>
999 <Shuffle size={11} color={pal.fg} strokeWidth={2.6} />
1000 </View>
1001 </Option>
1002 <View role="radiogroup" aria-label="Initials colour" style={styles.swatches}>
1003 {INITIAL_COLORS.map((col, i) => {
1004 const on = isInitials && hue === i;
1005 return (
1006 <Pressable key={col.name} role="radio" aria-checked={on} aria-label={col.name} hitSlop={4} onPress={() => onSwatch(i)}>
1007 <View style={[styles.swatchRing, { borderColor: on ? pal.fg : 'transparent' }]}>
1008 <View style={[styles.swatch, { backgroundColor: col.bg, borderColor: pal.swatchEdge }]} />
1009 </View>
1010 </Pressable>
1011 );
1012 })}
1013 </View>
1014 </View>
1015
1016 <Tap label="Done" onPress={onClose} to={0.97} style={styles.sheetDoneSlot}>
1017 <View style={styles.sheetDone}>
1018 <Text style={styles.sheetDoneText}>Done</Text>
1019 </View>
1020 </Tap>
1021 </Animated.View>
1022 </View>
1023 );
1024}
1025
1026// ─── Success: the avatar pops with a burst, then the next step ──────────────
1027
1028const CONFETTI = Array.from({ length: 24 }, (_, i) => {
1029 const angle = (i / 24) * Math.PI * 2 + (i % 2) * 0.13;
1030 const reach = 96 + ((i * 29) % 4) * 18;
1031 return { x: Math.cos(angle) * reach, y: Math.sin(angle) * reach, size: 7 + (i % 3) * 3, long: i % 3 === 0, tone: i % CONFETTI_TONES.length };
1032});
1033
1034function Confetti({ bit, t }: { bit: (typeof CONFETTI)[number]; t: SharedValue<number> }) {
1035 const style = useAnimatedStyle(() => ({
1036 opacity: interpolate(t.value, [0, 0.08, 0.65, 1], [0, 1, 1, 0]),
1037 transform: [{ translateX: bit.x * t.value }, { translateY: bit.y * t.value + 26 * t.value * t.value }, { rotate: `${t.value * 200}deg` }, { scale: 1 - t.value * 0.3 }],
1038 }));
1039 return <Animated.View style={[styles.confetti, { width: bit.size, height: bit.long ? bit.size * 1.9 : bit.size, borderRadius: bit.long ? 2 : bit.size / 2, backgroundColor: CONFETTI_TONES[bit.tone] }, style]} />;
1040}
1041
1042function Success({ open, choice, hue, name, username, headerH, pal }: { open: boolean; choice: Choice; hue: number; name: string; username: string; headerH: number; pal: Palette }) {
1043 const { mounted, p } = useReveal(open, 320);
1044 const burst = useSharedValue(0);
1045 const pop = useSharedValue(0);
1046 useEffect(() => {
1047 if (!open) return;
1048 pop.value = 0;
1049 pop.value = withSpring(1, { damping: 10, stiffness: 170, mass: 0.7 });
1050 burst.value = 0;
1051 burst.value = withDelay(140, withTiming(1, { duration: 1000, easing: Easing.out(Easing.cubic) }));
1052 }, [open, pop, burst]);
1053 const panel = useAnimatedStyle(() => ({ opacity: p.value }));
1054 const avatar = useAnimatedStyle(() => ({ transform: [{ scale: 0.4 + pop.value * 0.6 }] }));
1055 const ripple = useAnimatedStyle(() => ({ opacity: interpolate(burst.value, [0, 0.05, 1], [0, 0.5, 0]), transform: [{ scale: 1 + burst.value * 0.9 }] }));
1056 if (!mounted) return null;
1057 return (
1058 <Animated.View role="status" aria-label={`Looking good, ${firstName(name)}`} style={[StyleSheet.absoluteFill, styles.success, { backgroundColor: pal.bg, pointerEvents: open ? 'auto' : 'none' }, panel]}>
1059 <LinearGradient colors={[pal.bloom, pal.bloomEnd]} style={[styles.bloom, { top: -headerH }]} />
1060 <View style={styles.successStage}>
1061 <Animated.View style={[styles.successRipple, ripple]} />
1062 {CONFETTI.map((bit, i) => (
1063 <Confetti key={i} bit={bit} t={burst} />
1064 ))}
1065 <Animated.View style={avatar}>
1066 <Ring size={120} gap={5} width={3.5} bg={pal.bg}>
1067 <AvatarView choice={choice} hue={hue} initials={initialsOf(name)} size={120} />
1068 </Ring>
1069 <Animated.View entering={ZoomIn.delay(320).duration(260)} style={[styles.successTick, { backgroundColor: pal.success, borderColor: pal.bg }]}>
1070 <Check size={18} color={pal.onSuccess} strokeWidth={3.4} />
1071 </Animated.View>
1072 </Animated.View>
1073 </View>
1074 <Animated.Text entering={FadeInDown.delay(200).duration(380)} role="heading" style={[styles.successTitle, { color: pal.fg }]}>
1075 Looking good, {firstName(name)}
1076 </Animated.Text>
1077 <Animated.Text entering={FadeInDown.delay(280).duration(380)} style={[styles.successSub, { color: pal.muted }]}>
1078 Your profile is ready. Next, pick a few circles to join on {APP_NAME}.
1079 </Animated.Text>
1080 <Animated.View entering={FadeInDown.delay(360).duration(380)} style={[styles.successHandle, { backgroundColor: pal.surface, boxShadow: pal.cardShadow }]}>
1081 <AtSign size={15} color={pal.accentText} strokeWidth={2.4} />
1082 <Text style={[styles.successHandleText, { color: pal.fg }]}>{username}</Text>
1083 </Animated.View>
1084 </Animated.View>
1085 );
1086}
1087
1088// ─── Screen ─────────────────────────────────────────────────────────────────
1089
1090export default function ProfileSetupScreen() {
1091 const c = usePalette();
1092 const insets = useSafeAreaInsets();
1093 const { width } = useWindowDimensions();
1094 const colW = Math.min(width, COLUMN);
1095 const headerH = insets.top + HEADER_ROW;
1096
1097 const [name, setName] = useState(PREFILL.name);
1098 const [username, setUsername] = useState(PREFILL.username);
1099 const [avail, setAvail] = useState<Avail>('checking');
1100 const [bio, setBio] = useState(PREFILL.bio);
1101 const [pronouns, setPronouns] = useState<string | null>(PREFILL.pronouns);
1102 const [choice, setChoice] = useState<Choice>({ kind: 'photo', id: PORTRAITS[0].id });
1103 const [hue, setHue] = useState(0);
1104 const [focus, setFocus] = useState<FieldId | null>(null);
1105 const [picking, setPicking] = useState(false);
1106 const [status, setStatus] = useState<Status>('idle');
1107
1108 const nameRef = useRef<ComponentRef<typeof TextInput>>(null);
1109 const userRef = useRef<ComponentRef<typeof TextInput>>(null);
1110 const bioRef = useRef<ComponentRef<typeof TextInput>>(null);
1111 const checkTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
1112 const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
1113
1114 const step = useSharedValue(1);
1115 const shake = useSharedValue(0);
1116 const nudge = useSharedValue(0);
1117 const scrollY = useSharedValue(0);
1118
1119 const ready = name.trim().length > 0 && avail === 'available';
1120 const initials = initialsOf(name);
1121 const suggestions = useMemo(() => (avail === 'taken' ? suggestionsFor(username, name) : []), [avail, username, name]);
1122
1123 useEffect(() => {
1124 // On load: the dots step forward from 1 to 2, and the prefilled handle gets its first check.
1125 step.value = withDelay(220, withTiming(2, { duration: 520, easing: Easing.out(Easing.cubic) }));
1126 checkTimer.current = setTimeout(() => setAvail(TAKEN.includes(PREFILL.username) ? 'taken' : 'available'), 640);
1127 const pending = timers.current;
1128 return () => {
1129 if (checkTimer.current) clearTimeout(checkTimer.current);
1130 pending.forEach(clearTimeout);
1131 };
1132 }, [step]);
1133
1134 const jolt = (sv: SharedValue<number>, by: number) => {
1135 sv.value = withSequence(
1136 withTiming(-by, { duration: 45 }),
1137 withTiming(by, { duration: 60 }),
1138 withTiming(-by * 0.6, { duration: 60 }),
1139 withTiming(by * 0.5, { duration: 60 }),
1140 withTiming(0, { duration: 50 })
1141 );
1142 };
1143
1144 // Debounced availability: a spinner while typing, then the answer. Replace the timer with your API call.
1145 const changeUsername = (raw: string) => {
1146 const next = raw.toLowerCase().slice(0, HANDLE_MAX);
1147 const grew = next.length > username.length;
1148 setUsername(next);
1149 if (checkTimer.current) clearTimeout(checkTimer.current);
1150 if (!next) return setAvail('empty');
1151 if (!HANDLE_RE.test(next)) {
1152 if (grew || avail !== 'invalid') jolt(shake, 8);
1153 return setAvail('invalid');
1154 }
1155 if (next.length < 3) return setAvail('short');
1156 setAvail('checking');
1157 checkTimer.current = setTimeout(() => setAvail(TAKEN.includes(next) ? 'taken' : 'available'), CHECK_DELAY);
1158 };
1159
1160 const later = (fn: () => void, ms: number) => timers.current.push(setTimeout(fn, ms));
1161 const submit = () => {
1162 if (status !== 'idle') return;
1163 if (!ready) {
1164 jolt(nudge, 7);
1165 (name.trim() ? userRef : nameRef).current?.focus();
1166 return;
1167 }
1168 nameRef.current?.blur();
1169 userRef.current?.blur();
1170 bioRef.current?.blur();
1171 setStatus('saving');
1172 // Replace with your save call and navigate to step 3; the reset is here so the preview can replay.
1173 later(() => {
1174 setStatus('done');
1175 step.value = withDelay(120, withTiming(3, { duration: 520, easing: Easing.out(Easing.cubic) }));
1176 }, 800);
1177 later(() => {
1178 setStatus('idle');
1179 step.value = withTiming(2, { duration: 420, easing: Easing.out(Easing.cubic) });
1180 }, 4000);
1181 };
1182
1183 const pickInitials = () => {
1184 if (choice.kind === 'initials') setHue((h) => (h + 1) % INITIAL_COLORS.length);
1185 else setChoice({ kind: 'initials' });
1186 };
1187
1188 const onScroll = useAnimatedScrollHandler((e) => {
1189 scrollY.value = e.contentOffset.y;
1190 });
1191 const hairline = useAnimatedStyle(() => ({ opacity: interpolate(scrollY.value, [0, 16], [0, 1], 'clamp') }));
1192 const shakeStyle = useAnimatedStyle(() => ({ transform: [{ translateX: shake.value }] }));
1193
1194 const enter = (i: number) => FadeInDown.delay(140 + i * 70).duration(420);
1195 const atColor = avail === 'invalid' || avail === 'taken' ? c.error : avail === 'available' ? c.accentText : c.muted;
1196
1197 return (
1198 <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={[styles.screen, { backgroundColor: c.bg }]}>
1199 {/* Header: opaque, with the same bloom as the page so the seam never shows */}
1200 <View style={[styles.header, { height: headerH, paddingTop: insets.top, backgroundColor: c.bg }]}>
1201 <LinearGradient colors={[c.bloom, c.bloomEnd]} style={[styles.bloom, styles.bloomTop]} />
1202 <Animated.View entering={FadeIn.duration(320)} style={[styles.headerRow, { width: colW }]}>
1203 <Tap label="Back" to={0.9}>
1204 <View style={[styles.back, { backgroundColor: c.surface }]}>
1205 <ChevronLeft size={22} color={c.fg} strokeWidth={2.2} />
1206 </View>
1207 </Tap>
1208 <StepDots step={step} current={status === 'done' ? 3 : 2} total={3} pal={c} />
1209 <Pressable role="button" aria-label="Skip for now" hitSlop={10} style={({ pressed }) => [styles.skip, { opacity: pressed ? 0.45 : 1 }]}>
1210 <Text style={[styles.skipText, { color: c.muted }]}>Skip</Text>
1211 </Pressable>
1212 </Animated.View>
1213 <Animated.View style={[styles.hairline, { backgroundColor: c.line }, hairline]} />
1214 </View>
1215
1216 <View style={styles.body}>
1217 <Animated.ScrollView onScroll={onScroll} scrollEventThrottle={16} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false} contentContainerStyle={styles.scroll}>
1218 <LinearGradient colors={[c.bloom, c.bloomEnd]} style={[styles.bloom, { top: -headerH }]} />
1219 <View style={[styles.column, { width: colW }]}>
1220 {/* Avatar and heading */}
1221 <View style={styles.hero}>
1222 <HeroAvatar choice={choice} hue={hue} initials={initials} onPress={() => setPicking(true)} pal={c} />
1223 </View>
1224 <Animated.Text entering={enter(0)} role="heading" style={[styles.title, { color: c.fg }]}>
1225 Set up your profile
1226 </Animated.Text>
1227
1228 {/* Name and username */}
1229 <Animated.View entering={enter(1)} style={[styles.card, { backgroundColor: c.surface, boxShadow: c.cardShadow }]}>
1230 <Row label="Name" focused={focus === 'name'} onPress={() => nameRef.current?.focus()} pal={c}>
1231 <TextInput
1232 ref={nameRef}
1233 value={name}
1234 onChangeText={(v) => setName(v.replace(/\s{2,}/g, ' ').slice(0, NAME_MAX))}
1235 onFocus={() => setFocus('name')}
1236 onBlur={() => setFocus(null)}
1237 placeholder="Your name"
1238 placeholderTextColor={c.faint}
1239 selectionColor={ACCENT}
1240 autoCapitalize="words"
1241 autoComplete="name"
1242 returnKeyType="next"
1243 onSubmitEditing={() => userRef.current?.focus()}
1244 aria-label="Display name"
1245 style={[styles.input, { color: c.fg }, NO_OUTLINE]}
1246 />
1247 </Row>
1248 <View style={[styles.divider, { backgroundColor: c.line }]} />
1249 <Animated.View style={shakeStyle}>
1250 <Row label="Username" focused={focus === 'username'} onPress={() => userRef.current?.focus()} pal={c}>
1251 <Text style={[styles.at, { color: atColor }]}>@</Text>
1252 <TextInput
1253 ref={userRef}
1254 value={username}
1255 onChangeText={changeUsername}
1256 onFocus={() => setFocus('username')}
1257 onBlur={() => setFocus(null)}
1258 placeholder="username"
1259 placeholderTextColor={c.faint}
1260 selectionColor={ACCENT}
1261 autoCapitalize="none"
1262 autoCorrect={false}
1263 autoComplete="username"
1264 maxLength={HANDLE_MAX}
1265 returnKeyType="next"
1266 onSubmitEditing={() => bioRef.current?.focus()}
1267 aria-label="Username"
1268 style={[styles.input, styles.handleInput, { color: c.fg }, NO_OUTLINE]}
1269 />
1270 <Availability state={avail} pal={c} />
1271 </Row>
1272 </Animated.View>
1273 </Animated.View>
1274
1275 {/* Under the username: the inline error, a length hint, or free alternatives */}
1276 <Collapse open={avail === 'invalid' || avail === 'taken' || avail === 'short'}>
1277 {avail === 'invalid' ? (
1278 <View role="alert" style={styles.feedbackRow}>
1279 <CircleAlert size={15} color={c.error} strokeWidth={2.4} />
1280 <Text style={[styles.feedbackText, { color: c.error }]}>Use only letters, numbers, dots and underscores.</Text>
1281 </View>
1282 ) : avail === 'short' ? (
1283 <View style={styles.feedbackRow}>
1284 <Text style={[styles.feedbackText, { color: c.muted }]}>At least 3 characters.</Text>
1285 </View>
1286 ) : (
1287 <View style={styles.feedback}>
1288 <Text style={[styles.feedbackText, { color: c.muted }]}>
1289 <Text style={[styles.feedbackStrong, { color: c.error }]}>@{username}</Text> is taken. Try one of these:
1290 </Text>
1291 <View style={styles.suggestions}>
1292 {suggestions.map((s, i) => (
1293 <Animated.View key={s} entering={FadeInDown.delay(60 + i * 60).duration(280)}>
1294 <Tap label={`Use @${s}`} onPress={() => changeUsername(s)} to={0.93}>
1295 <View style={[styles.suggestion, { backgroundColor: c.accentSoft }]}>
1296 <Text style={[styles.suggestionText, { color: c.accentText }]}>@{s}</Text>
1297 </View>
1298 </Tap>
1299 </Animated.View>
1300 ))}
1301 </View>
1302 </View>
1303 )}
1304 </Collapse>
1305
1306 {/* Bio and pronouns */}
1307 <Animated.View entering={enter(2)} style={[styles.card, styles.cardGap, { backgroundColor: c.surface, boxShadow: c.cardShadow }]}>
1308 <Row label="Bio" stacked focused={focus === 'bio'} onPress={() => bioRef.current?.focus()} accessory={<CountRing count={bio.length} pal={c} />} pal={c}>
1309 <View style={styles.bioWrap}>
1310 {/* An invisible copy of the text sets the height; the input stretches over it, so the row grows as you type. */}
1311 <Text aria-hidden style={[styles.bioText, styles.bioSizer]}>
1312 {bio + '​'}
1313 </Text>
1314 <TextInput
1315 ref={bioRef}
1316 value={bio}
1317 onChangeText={(v) => setBio(v.replace(/\n/g, ' ').slice(0, BIO_LIMIT))}
1318 onFocus={() => setFocus('bio')}
1319 onBlur={() => setFocus(null)}
1320 multiline
1321 maxLength={BIO_LIMIT}
1322 textAlignVertical="top"
1323 placeholder="A line or two about you"
1324 placeholderTextColor={c.faint}
1325 selectionColor={ACCENT}
1326 aria-label="Bio"
1327 style={[StyleSheet.absoluteFill, styles.bioText, styles.bioInput, { color: c.fg }, NO_OUTLINE]}
1328 />
1329 </View>
1330 </Row>
1331 <View style={[styles.divider, { backgroundColor: c.line }]} />
1332 <Row label="Pronouns" hint="Optional" flush focused={false} pal={c}>
1333 <ChipScroller label="Pronouns" pal={c}>
1334 {PRONOUNS.map((p) => (
1335 <Chip key={p} label={p} on={pronouns === p} onPress={() => setPronouns((cur) => (cur === p ? null : p))} pal={c} />
1336 ))}
1337 </ChipScroller>
1338 </Row>
1339 </Animated.View>
1340
1341 {/* What other members will see */}
1342 <Animated.View entering={enter(3)} style={styles.previewSlot}>
1343 <PreviewCard name={name} username={username} bio={bio} pronouns={pronouns} choice={choice} hue={hue} pal={c} />
1344 </Animated.View>
1345 </View>
1346 </Animated.ScrollView>
1347
1348 <Success open={status === 'done'} choice={choice} hue={hue} name={name} username={username} headerH={headerH} pal={c} />
1349 </View>
1350
1351 {/* Opaque bar above the home indicator */}
1352 <Animated.View entering={FadeInDown.delay(420).duration(380)} style={[styles.bar, { paddingBottom: insets.bottom + 8, backgroundColor: c.bg, borderTopColor: c.line }]}>
1353 <View style={[styles.barInner, { width: colW }]}>
1354 <ContinueButton ready={ready} status={status} width={colW - 40} nudge={nudge} onPress={submit} pal={c} />
1355 </View>
1356 </Animated.View>
1357
1358 <AvatarSheet
1359 open={picking}
1360 choice={choice}
1361 hue={hue}
1362 initials={initials}
1363 width={colW}
1364 onClose={() => setPicking(false)}
1365 onPhoto={(id) => setChoice({ kind: 'photo', id })}
1366 onArt={(id) => setChoice({ kind: 'art', id })}
1367 onInitials={pickInitials}
1368 onSwatch={(i) => {
1369 setHue(i);
1370 setChoice({ kind: 'initials' });
1371 }}
1372 pal={c}
1373 />
1374 </KeyboardAvoidingView>
1375 );
1376}
1377
1378// ─── Styles ─────────────────────────────────────────────────────────────────
1379
1380const styles = StyleSheet.create({
1381 screen: { flex: 1, overflow: 'hidden' },
1382 fill: { flex: 1 },
1383 center: { alignItems: 'center', justifyContent: 'center' },
1384 shrink: { flexShrink: 1 },
1385 selfStart: { alignSelf: 'flex-start' },
1386
1387 // Small pieces
1388 round: { overflow: 'hidden' },
1389 sheen: { backgroundColor: '#FFFFFF' },
1390 fillImage: { width: '100%', height: '100%' },
1391 spinner: { borderWidth: 2.4 },
1392 collapse: { overflow: 'hidden' },
1393 collapseInner: { position: 'absolute', top: 0, left: 0, right: 0 },
1394 initials: { fontWeight: '800' },
1395
1396 // Header
1397 header: { overflow: 'hidden', zIndex: 2 },
1398 bloom: { position: 'absolute', left: 0, right: 0, height: 380, pointerEvents: 'none' },
1399 bloomTop: { top: 0 },
1400 headerRow: { height: HEADER_ROW, alignSelf: 'center', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 16 },
1401 back: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },
1402 dots: { flexDirection: 'row', alignItems: 'center', gap: 6 },
1403 dot: { height: 8, borderRadius: 4 },
1404 skip: { width: 56, height: 40, alignItems: 'flex-end', justifyContent: 'center', paddingRight: 4 },
1405 skipText: { fontSize: 16, fontWeight: '600' },
1406 hairline: { position: 'absolute', left: 0, right: 0, bottom: 0, height: StyleSheet.hairlineWidth },
1407
1408 // Body
1409 body: { flex: 1 },
1410 scroll: { paddingBottom: 20 },
1411 column: { alignSelf: 'center', paddingHorizontal: 20 },
1412
1413 // Hero
1414 hero: { alignItems: 'center', paddingTop: 4 },
1415 heroPress: { alignItems: 'center', justifyContent: 'center' },
1416 heroGlow: { borderRadius: 999, boxShadow: `0px 14px 36px ${tint(ACCENT, 0.3)}` },
1417 heroRipple: { position: 'absolute', borderWidth: 2, borderColor: ACCENT, pointerEvents: 'none' },
1418 cameraBadge: {
1419 position: 'absolute',
1420 right: 2,
1421 bottom: 2,
1422 width: 36,
1423 height: 36,
1424 borderRadius: 18,
1425 borderWidth: 3,
1426 backgroundColor: ACCENT,
1427 alignItems: 'center',
1428 justifyContent: 'center',
1429 },
1430 title: { marginTop: 12, fontSize: 26, lineHeight: 32, fontWeight: '800', letterSpacing: -0.8, textAlign: 'center' },
1431
1432 // Form
1433 card: { marginTop: 18, borderRadius: 20, overflow: 'hidden' },
1434 cardGap: { marginTop: 12 },
1435 row: { minHeight: 54, flexDirection: 'row', alignItems: 'center', paddingLeft: 16, paddingRight: 12 },
1436 rowFlush: { paddingRight: 0 },
1437 rowStacked: { paddingLeft: 16, paddingRight: 12, paddingTop: 10, paddingBottom: 12 },
1438 rowStackedHead: { height: 28, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 2 },
1439 rowLabelCol: { width: 92 },
1440 rowLabel: { fontSize: 15, fontWeight: '500' },
1441 rowHint: { marginTop: 1, fontSize: 11.5, fontWeight: '500' },
1442 rowValue: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center' },
1443 divider: { height: StyleSheet.hairlineWidth, marginLeft: 16 },
1444 input: { flex: 1, minWidth: 0, height: 54, paddingVertical: 0, paddingHorizontal: 0, fontSize: 16, fontWeight: '500' },
1445 handleInput: { marginLeft: 1 },
1446 at: { fontSize: 16, fontWeight: '600' },
1447 availSpin: { width: 28, height: 28, alignItems: 'center', justifyContent: 'center' },
1448 availPill: { flexDirection: 'row', alignItems: 'center', gap: 5, height: 26, paddingLeft: 5, paddingRight: 9, borderRadius: 13 },
1449 availMark: { width: 16, height: 16, borderRadius: 8, alignItems: 'center', justifyContent: 'center' },
1450 availText: { fontSize: 13, fontWeight: '700' },
1451
1452 // Username feedback
1453 feedback: { paddingTop: 10, paddingHorizontal: 4 },
1454 feedbackRow: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingTop: 10, paddingHorizontal: 4 },
1455 feedbackText: { flexShrink: 1, fontSize: 13.5, lineHeight: 18 },
1456 feedbackStrong: { fontWeight: '700' },
1457 suggestions: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, marginTop: 9 },
1458 suggestion: { height: 32, paddingHorizontal: 12, borderRadius: 16, justifyContent: 'center' },
1459 suggestionText: { fontSize: 14, fontWeight: '600' },
1460
1461 // Bio
1462 bioWrap: { paddingRight: 4 },
1463 bioText: { fontSize: 16, lineHeight: 22 },
1464 bioSizer: { minHeight: 44, opacity: 0 },
1465 bioInput: { paddingTop: 0, paddingBottom: 0, paddingHorizontal: 0 },
1466 counter: { flexDirection: 'row', alignItems: 'center', gap: 6, pointerEvents: 'none' },
1467 counterLeft: { fontSize: 13, fontWeight: '700' },
1468
1469 // Pronouns
1470 chips: { gap: 6, paddingVertical: 11, paddingRight: 14 },
1471 chip: { height: 32, paddingHorizontal: 12, borderRadius: 16, flexDirection: 'row', alignItems: 'center', gap: 4 },
1472 chipLabel: { fontSize: 14, fontWeight: '600' },
1473 chipFade: { position: 'absolute', left: 0, top: 0, bottom: 0, width: 18, pointerEvents: 'none' },
1474
1475 // Preview card
1476 previewSlot: { marginTop: 18 },
1477 previewHead: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingHorizontal: 4, marginBottom: 8 },
1478 previewLabel: { fontSize: 13, fontWeight: '600', letterSpacing: 0.1 },
1479 live: { flexDirection: 'row', alignItems: 'center', gap: 6 },
1480 liveDotSlot: { width: 8, height: 8, alignItems: 'center', justifyContent: 'center' },
1481 liveHalo: { position: 'absolute', width: 8, height: 8, borderRadius: 4, backgroundColor: ACCENT },
1482 liveDot: { width: 7, height: 7, borderRadius: 3.5, backgroundColor: ACCENT },
1483 liveText: { fontSize: 12, fontWeight: '700', letterSpacing: 0.3 },
1484 previewCard: { flexDirection: 'row', alignItems: 'flex-start', gap: 12, padding: 14, borderRadius: 20 },
1485 previewBody: { flex: 1, minWidth: 0 },
1486 previewTop: { flexDirection: 'row', alignItems: 'flex-start', gap: 8 },
1487 previewIdentity: { flex: 1, minWidth: 0 },
1488 previewHandleRow: { flexDirection: 'row', alignItems: 'center', gap: 6, marginTop: 1 },
1489 flashLine: { borderRadius: 6, marginHorizontal: -4, paddingHorizontal: 4 },
1490 previewName: { fontSize: 16.5, lineHeight: 22, fontWeight: '700', letterSpacing: -0.3 },
1491 previewPronouns: { height: 20, paddingHorizontal: 7, borderRadius: 10, justifyContent: 'center' },
1492 previewPronounsText: { fontSize: 11.5, fontWeight: '600' },
1493 previewHandle: { fontSize: 14, lineHeight: 19 },
1494 previewBio: { marginTop: 6, fontSize: 14.5, lineHeight: 20 },
1495 sayHi: { height: 30, paddingHorizontal: 11, borderRadius: 15, flexDirection: 'row', alignItems: 'center', gap: 5 },
1496 sayHiText: { fontSize: 13, fontWeight: '700' },
1497
1498 // Continue
1499 bar: { paddingTop: 10, borderTopWidth: StyleSheet.hairlineWidth },
1500 barInner: { alignSelf: 'center', paddingHorizontal: 20 },
1501 cta: { height: BUTTON_H, borderRadius: BUTTON_H / 2, alignItems: 'center', justifyContent: 'center' },
1502 ctaGlow: { borderRadius: BUTTON_H / 2, boxShadow: `0px 10px 26px ${tint(ACCENT, 0.36)}` },
1503 ctaClip: { borderRadius: BUTTON_H / 2, overflow: 'hidden' },
1504 ctaFill: { position: 'absolute', top: 0, bottom: 0, left: 0, borderRadius: BUTTON_H / 2, overflow: 'hidden', backgroundColor: ACCENT },
1505 ctaSheen: { position: 'absolute', top: 0, left: 0, right: 0, height: BUTTON_H / 2 },
1506 ctaRow: { flexDirection: 'row', alignItems: 'center', gap: 8 },
1507 ctaLabel: { fontSize: 17, fontWeight: '700', letterSpacing: -0.2 },
1508 ctaOn: { color: ON_ACCENT },
1509
1510 // Sheet
1511 sheetLayer: { zIndex: 10, justifyContent: 'flex-end', alignItems: 'center' },
1512 sheet: { borderTopLeftRadius: 28, borderTopRightRadius: 28, paddingHorizontal: 20 },
1513 sheetHandle: { paddingTop: 8, paddingBottom: 4 },
1514 grabber: { alignSelf: 'center', width: 40, height: 5, borderRadius: 3 },
1515 sheetTitleRow: { flexDirection: 'row', alignItems: 'center', marginTop: 14, gap: 12 },
1516 sheetTitle: { fontSize: 20, fontWeight: '800', letterSpacing: -0.4 },
1517 sheetSub: { marginTop: 2, fontSize: 14 },
1518 sheetClose: { width: 34, height: 34, borderRadius: 17, alignItems: 'center', justifyContent: 'center' },
1519 sheetSection: { marginTop: 18, marginBottom: 6, fontSize: 12, fontWeight: '700', letterSpacing: 0.8 },
1520 optionRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
1521 optionRing: { borderWidth: 2.5, borderColor: ACCENT },
1522 optionCheck: {
1523 position: 'absolute',
1524 right: 0,
1525 bottom: 0,
1526 width: 18,
1527 height: 18,
1528 borderRadius: 9,
1529 backgroundColor: ACCENT,
1530 alignItems: 'center',
1531 justifyContent: 'center',
1532 },
1533 libraryTile: { width: 62, height: 62, borderRadius: 31, borderWidth: 1.5, borderStyle: 'dashed', alignItems: 'center', justifyContent: 'center' },
1534 initialsRow: { flexDirection: 'row', alignItems: 'center', gap: 14 },
1535 shuffleBadge: { position: 'absolute', left: 1, bottom: 1, width: 20, height: 20, borderRadius: 10, alignItems: 'center', justifyContent: 'center' },
1536 swatches: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
1537 swatchRing: { width: 36, height: 36, borderRadius: 18, borderWidth: 2, alignItems: 'center', justifyContent: 'center' },
1538 swatch: { width: 26, height: 26, borderRadius: 13, borderWidth: 1 },
1539 sheetDoneSlot: { marginTop: 22 },
1540 sheetDone: { height: 52, borderRadius: 26, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },
1541 sheetDoneText: { fontSize: 16.5, fontWeight: '700', color: ON_ACCENT },
1542
1543 // Success
1544 success: { alignItems: 'center', justifyContent: 'center', paddingHorizontal: 32, paddingBottom: 40, zIndex: 3 },
1545 successStage: { width: 140, height: 140, alignItems: 'center', justifyContent: 'center' },
1546 successRipple: { position: 'absolute', width: 140, height: 140, borderRadius: 70, borderWidth: 2, borderColor: ACCENT },
1547 confetti: { position: 'absolute', pointerEvents: 'none' },
1548 successTick: { position: 'absolute', right: 2, bottom: 2, width: 36, height: 36, borderRadius: 18, borderWidth: 3, alignItems: 'center', justifyContent: 'center' },
1549 successTitle: { marginTop: 26, fontSize: 28, lineHeight: 34, fontWeight: '800', letterSpacing: -0.8, textAlign: 'center' },
1550 successSub: { marginTop: 8, fontSize: 15.5, lineHeight: 22, textAlign: 'center', maxWidth: 300 },
1551 successHandle: { marginTop: 20, height: 38, paddingHorizontal: 14, borderRadius: 19, flexDirection: 'row', alignItems: 'center', gap: 6 },
1552 successHandleText: { fontSize: 15, fontWeight: '600' },
1553});

More screens like this.

All Onboarding