Edit profile

A profile editor that knows what changed: Save stays muted until a field differs from the saved values, then pops to accent, spins, ticks and slides in a "Profile saved" toast, while Cancel asks before discarding. Floating-label fields in grouped cards with a live username availability check, a bio counter ring that fills and turns amber then red, a slide-up photo sheet that swaps the avatar, and a custom animated switch.

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

Details

File
components/patterns/edit-profile.tsx
Lines
927
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/edit-profile.tsx
1import { useEffect, useRef, useState, type ReactNode } from 'react';
2import { Image, KeyboardAvoidingView, Platform, Pressable, StyleSheet, Text, TextInput, View, useColorScheme, useWindowDimensions, type StyleProp, type TextInputProps, type ViewStyle } from 'react-native';
3import Animated, {
4 cancelAnimation,
5 Easing,
6 FadeIn,
7 FadeInDown,
8 interpolate,
9 interpolateColor,
10 runOnJS,
11 useAnimatedProps,
12 useAnimatedScrollHandler,
13 useAnimatedStyle,
14 useSharedValue,
15 withDelay,
16 withRepeat,
17 withSequence,
18 withSpring,
19 withTiming,
20 ZoomIn,
21 type SharedValue,
22} from 'react-native-reanimated';
23import { LinearGradient } from 'expo-linear-gradient';
24import { useSafeAreaInsets } from 'react-native-safe-area-context';
25import Svg, { Circle } from 'react-native-svg';
26import { AlignLeft, Camera, Check, Globe, IdCard, Images, Lock, MapPin, Trash2, UserRound, X, type LucideIcon } from 'lucide-react-native';
27
28// ─── Brand ──────────────────────────────────────────────────────────────────
29// The screen's accent. Every accent colour below derives from these, so changing them rebrands the screen.
30
31const ACCENT = '#1064FF';
32const ACCENT_DARK = '#5B97FF'; // the accent on dark backgrounds
33const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill
34
35/** `hex` at `alpha` opacity, as rgba(). */
36function tint(hex: string, alpha: number) {
37 const n = parseInt(hex.slice(1), 16);
38 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;
39}
40
41/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */
42function shade(hex: string, amount: number) {
43 const n = parseInt(hex.slice(1), 16);
44 const target = amount < 0 ? 255 : 0;
45 const p = Math.abs(amount);
46 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');
47 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();
48}
49
50// ─── Sample data ────────────────────────────────────────────────────────────
51
52const photo = (id: string, w: number) => `https://images.unsplash.com/photo-${id}?w=${w}&q=80&fit=crop`;
53
54// `sofia` is the saved photo; `lake` is what the library hands back in this demo.
55const PORTRAITS = {
56 sofia: { id: '1494790108377-be9c29b29330', alt: 'Sofia laughing in a red jumper', tint: '#8E6E66' },
57 lake: { id: '1438761681033-6461ffad8d80', alt: 'Portrait in front of a mountain lake', tint: '#7E8FA3' },
58} as const;
59type PortraitKey = keyof typeof PORTRAITS;
60
61const COVER = { id: '1506905925346-21bda4d32df4', alt: 'Peaks above a sea of cloud at dusk', tint: '#5B6788' };
62
63type Profile = {
64 name: string;
65 username: string;
66 bio: string;
67 location: string;
68 website: string;
69 isPrivate: boolean;
70 avatar: PortraitKey | null;
71};
72
73// What the server has. Save is compared against this, field by field.
74const SAVED: Profile = {
75 name: 'Sofia Martinez',
76 username: 'sofiaoutdoors',
77 bio: 'Chasing first light across the Alps. Spring workshops are now open at sofiamartinez.photo',
78 location: 'Lisbon, Portugal',
79 website: 'sofiamartinez.photo',
80 isPrivate: false,
81 avatar: 'sofia',
82};
83
84// The screen opens mid-edit, so Save is live and the counter has something to show.
85const DRAFT_BIO = 'Chasing first light across the Alps. Spring workshops are now open, with two new autumn dates in the Dolomites.';
86
87const TAKEN = ['sofia', 'sofiam', 'alps', 'admin'];
88const BIO_LIMIT = 160;
89const BIO_WARN = 130;
90const BIO_DANGER = 150;
91const SITE_RE = /^(https?:\/\/)?([a-z0-9-]+\.)+[a-z]{2,}(\/\S*)?$/i;
92
93// ─── Palette ────────────────────────────────────────────────────────────────
94
95const POP = { damping: 14, stiffness: 300, mass: 0.6 };
96const SOFT = { duration: 220, easing: Easing.out(Easing.cubic) };
97const TABULAR = { fontVariant: ['tabular-nums' as const] };
98const WEB_INPUT = Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null;
99
100const BAR = 48;
101const COVER_H = 106;
102const AVATAR = 92;
103const ROW = 60;
104
105function usePalette() {
106 const dark = useColorScheme() === 'dark';
107 return {
108 dark,
109 bg: dark ? '#000000' : '#F3F3F6',
110 card: dark ? '#131316' : '#FFFFFF',
111 cardEdge: dark ? '#1F1F24' : '#ECECF0',
112 sheet: dark ? '#1A1A1E' : '#FFFFFF',
113 fg: dark ? '#FAFAFA' : '#0A0A0A',
114 muted: dark ? '#8E8E93' : '#6E6E76',
115 faint: dark ? '#5E5E66' : '#A1A1AA',
116 line: dark ? '#26262B' : '#EAEAEE',
117 chip: dark ? '#1F1F24' : '#E7E7EC',
118 track: dark ? '#3A3A41' : '#D6D6DC',
119 link: dark ? ACCENT_DARK : ACCENT,
120 good: dark ? '#34D17A' : '#149C4A',
121 warn: dark ? '#F5B13D' : '#D97706',
122 bad: dark ? '#FF6B6B' : '#E5484D',
123 // Marks drawn on a coloured status dot (the Save tick, the username check).
124 onGood: dark ? '#04240F' : '#FFFFFF',
125 onStatus: dark ? '#0B0B0D' : '#FFFFFF',
126 // Photo sheet: the grouped rows and the round icon behind each one.
127 sheetGroup: dark ? '#222227' : '#F3F3F6',
128 sheetIcon: dark ? '#33333A' : '#FFFFFF',
129 // The toast is inverted against the screen.
130 toast: dark ? '#F4F4F6' : '#17171A',
131 toastFg: dark ? '#0A0A0A' : '#FAFAFA',
132 toastMark: dark ? '#149C4A' : '#34D17A',
133 toastTick: dark ? '#FFFFFF' : '#06280F',
134 };
135}
136
137const tidy = (p: Profile): Profile => ({ ...p, name: p.name.trim(), bio: p.bio.trim(), location: p.location.trim(), website: p.website.trim() });
138const initials = (name: string) =>
139 name
140 .trim()
141 .split(/\s+/)
142 .slice(0, 2)
143 .map((w) => w.charAt(0).toUpperCase())
144 .join('') || '?';
145
146// ─── Small pieces ───────────────────────────────────────────────────────────
147
148function Tap({ children, label, onPress, to = 0.94, style }: { children: ReactNode; label: string; onPress?: () => void; to?: number; style?: StyleProp<ViewStyle> }) {
149 const scale = useSharedValue(1);
150 const pressed = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
151 return (
152 <Pressable role="button" aria-label={label} onPress={onPress} hitSlop={6} onPressIn={() => (scale.value = withSpring(to, POP))} onPressOut={() => (scale.value = withSpring(1, POP))} style={style}>
153 <Animated.View style={pressed}>{children}</Animated.View>
154 </Pressable>
155 );
156}
157
158/** A photo that fades in over its own tint, which shimmers until the image arrives. */
159function Photo({ id, alt, tint, w, style }: { id: string; alt: string; tint: string; w: number; style?: StyleProp<ViewStyle> }) {
160 const shown = useSharedValue(0);
161 const pulse = useSharedValue(0);
162 useEffect(() => {
163 pulse.value = withRepeat(withSequence(withTiming(1, { duration: 700 }), withTiming(0, { duration: 700 })), -1);
164 return () => cancelAnimation(pulse);
165 }, [pulse]);
166 const image = useAnimatedStyle(() => ({ opacity: shown.value }));
167 const sheen = useAnimatedStyle(() => ({ opacity: (1 - shown.value) * pulse.value * 0.2 }));
168 return (
169 <View style={[styles.photo, { backgroundColor: tint }, style]}>
170 <Animated.View style={[StyleSheet.absoluteFill, styles.photoSheen, sheen]} />
171 <Animated.View style={[StyleSheet.absoluteFill, image]}>
172 <Image
173 source={{ uri: photo(id, w) }}
174 alt={alt}
175 resizeMode="cover"
176 style={styles.photoImage}
177 onLoad={() => {
178 cancelAnimation(pulse);
179 shown.value = withTiming(1, { duration: 320 });
180 }}
181 />
182 </Animated.View>
183 </View>
184 );
185}
186
187function Spinner({ size = 18, color, track }: { size?: number; color: string; track: string }) {
188 const turn = useSharedValue(0);
189 useEffect(() => {
190 turn.value = withRepeat(withTiming(360, { duration: 760, easing: Easing.linear }), -1);
191 return () => cancelAnimation(turn);
192 }, [turn]);
193 const style = useAnimatedStyle(() => ({ transform: [{ rotate: `${turn.value}deg` }] }));
194 return <Animated.View style={[styles.spinner, { width: size, height: size, borderRadius: size / 2, borderColor: track, borderTopColor: color }, style]} />;
195}
196
197/** Keeps an overlay mounted while it animates out. `p` runs 0 (hidden) to 1 (open). */
198function useReveal(open: boolean, duration = 280) {
199 const [mounted, setMounted] = useState(open);
200 const p = useSharedValue(open ? 1 : 0);
201 useEffect(() => {
202 if (open) {
203 setMounted(true);
204 p.value = withTiming(1, { duration, easing: Easing.out(Easing.cubic) });
205 } else {
206 p.value = withTiming(0, { duration: 200, easing: Easing.in(Easing.quad) }, (done) => {
207 if (done) runOnJS(setMounted)(false);
208 });
209 }
210 }, [open, duration, p]);
211 return { mounted, p };
212}
213
214// ─── Save: muted until something differs, then spinner and tick ─────────────
215
216type SaveState = 'idle' | 'saving' | 'saved';
217
218function SaveButton({ ready, dirty, state, nudge, onPress }: { ready: boolean; dirty: boolean; state: SaveState; nudge: SharedValue<number>; onPress: () => void }) {
219 const c = usePalette();
220 const lit = state === 'saving' || (state === 'idle' && ready);
221 const on = useSharedValue(0);
222 const done = useSharedValue(0);
223 const pop = useSharedValue(1);
224 const press = useSharedValue(1);
225 useEffect(() => {
226 on.value = withTiming(lit ? 1 : 0, { duration: 260 });
227 // A small pop tells you the button just woke up.
228 if (lit) pop.value = withSequence(withTiming(1.12, { duration: 140, easing: Easing.out(Easing.cubic) }), withTiming(1, { duration: 220, easing: Easing.out(Easing.back(2)) }));
229 }, [lit, on, pop]);
230 useEffect(() => {
231 done.value = withTiming(state === 'saved' ? 1 : 0, { duration: 240 });
232 }, [state, done]);
233 const pill = useAnimatedStyle(() => ({
234 backgroundColor: interpolateColor(on.value, [0, 1], [c.chip, ACCENT]),
235 transform: [{ translateX: nudge.value }, { scale: pop.value * press.value }],
236 }));
237 const text = useAnimatedStyle(() => ({ color: interpolateColor(on.value, [0, 1], [c.faint, ON_ACCENT]) }));
238 const green = useAnimatedStyle(() => ({ opacity: done.value }));
239 return (
240 <Pressable
241 role="button"
242 aria-label={state === 'saving' ? 'Saving' : state === 'saved' ? 'Saved' : 'Save'}
243 aria-busy={state === 'saving'}
244 disabled={!dirty || state !== 'idle'}
245 hitSlop={8}
246 onPress={onPress}
247 onPressIn={() => (press.value = withSpring(0.93, POP))}
248 onPressOut={() => (press.value = withSpring(1, POP))}
249 >
250 <Animated.View style={[styles.save, pill]}>
251 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: c.good }, green]} />
252 {state === 'idle' ? (
253 <Animated.Text key="label" entering={FadeIn.duration(160)} style={[styles.saveLabel, text]}>
254 Save
255 </Animated.Text>
256 ) : state === 'saving' ? (
257 <Animated.View key="spin" entering={FadeIn.duration(160)}>
258 <Spinner size={17} color={ON_ACCENT} track={tint(ON_ACCENT, 0.35)} />
259 </Animated.View>
260 ) : (
261 <Animated.View key="tick" entering={ZoomIn.duration(260)}>
262 <Check size={19} color={c.onGood} strokeWidth={3.2} />
263 </Animated.View>
264 )}
265 </Animated.View>
266 </Pressable>
267 );
268}
269
270// ─── A field row: leading icon, floating label, optional status and footer ──
271
272type FieldProps = {
273 icon: LucideIcon;
274 label: string;
275 value: string;
276 onChangeText: (v: string) => void;
277 prefix?: string;
278 trailing?: ReactNode;
279 footer?: ReactNode;
280 error?: string | null;
281 changed?: boolean;
282 grow?: boolean;
283 divider?: boolean;
284 onBlurred?: () => void;
285} & Omit<TextInputProps, 'value' | 'onChangeText' | 'style' | 'onFocus' | 'onBlur'>;
286
287function Field({ icon: Icon, label, value, onChangeText, prefix, trailing, footer, error, changed, grow, divider = true, onBlurred, ...input }: FieldProps) {
288 const c = usePalette();
289 const [focused, setFocused] = useState(false);
290 const lifted = focused || value.length > 0;
291 const lift = useSharedValue(lifted ? 1 : 0);
292 const glow = useSharedValue(0);
293 useEffect(() => {
294 lift.value = withTiming(lifted ? 1 : 0, { duration: 180, easing: Easing.out(Easing.cubic) });
295 glow.value = withTiming(focused ? 1 : 0, { duration: 200 });
296 }, [lifted, focused, lift, glow]);
297 const labelStyle = useAnimatedStyle(() => ({
298 transform: [{ translateY: interpolate(lift.value, [0, 1], [0, -13]) }, { scale: interpolate(lift.value, [0, 1], [1, 0.78]) }],
299 }));
300 const bar = useAnimatedStyle(() => ({ opacity: glow.value, transform: [{ scaleY: interpolate(glow.value, [0, 1], [0.3, 1]) }] }));
301 const tone = error ? c.bad : focused ? c.link : c.muted;
302 const shared = {
303 ...input,
304 value,
305 onChangeText,
306 onFocus: () => setFocused(true),
307 onBlur: () => {
308 setFocused(false);
309 onBlurred?.();
310 },
311 'aria-label': label,
312 'aria-invalid': !!error,
313 selectionColor: ACCENT,
314 };
315
316 return (
317 <View>
318 <View style={styles.field}>
319 {/* Focus marker on the card's edge. */}
320 <Animated.View pointerEvents="none" style={[styles.focusBar, { backgroundColor: c.link }, bar]} />
321 <View style={styles.fieldIcon}>
322 <Icon size={20} color={tone} strokeWidth={2} />
323 </View>
324 <View style={styles.fieldBody}>
325 {grow ? (
326 // An invisible copy of the text sets the height; the input stretches over it, so the row grows as you type.
327 <View>
328 <Text aria-hidden style={[styles.bioText, styles.bioSizer]}>
329 {value + '​'}
330 </Text>
331 <TextInput {...shared} multiline textAlignVertical="top" style={[StyleSheet.absoluteFill, styles.bioText, styles.bioInput, { color: c.fg }, WEB_INPUT]} />
332 </View>
333 ) : (
334 <View style={styles.row}>
335 {prefix && lifted ? <Text style={[styles.prefix, { color: c.muted }]}>{prefix}</Text> : null}
336 <TextInput {...shared} style={[styles.input, { color: c.fg }, WEB_INPUT]} />
337 {trailing}
338 </View>
339 )}
340 {/* Drawn after the input so it sits on top; it never takes touches. */}
341 <Animated.View pointerEvents="none" style={[styles.fieldLabel, labelStyle]}>
342 <Text style={[styles.fieldLabelText, { color: tone }]}>{label}</Text>
343 {changed ? <Animated.View entering={ZoomIn.duration(220)} aria-label="Edited" style={[styles.editedDot, { backgroundColor: c.link }]} /> : null}
344 </Animated.View>
345 {error ? (
346 <Animated.Text entering={FadeInDown.duration(180)} role="alert" style={[styles.fieldError, { color: c.bad }]}>
347 {error}
348 </Animated.Text>
349 ) : null}
350 {footer}
351 </View>
352 </View>
353 {divider ? <View style={[styles.fieldDivider, { backgroundColor: c.line }]} /> : null}
354 </View>
355 );
356}
357
358// ─── Username availability ──────────────────────────────────────────────────
359
360type Check = 'same' | 'short' | 'checking' | 'available' | 'taken';
361
362function Availability({ check }: { check: Check }) {
363 const c = usePalette();
364 if (check === 'same') return null;
365 if (check === 'checking') {
366 return (
367 <Animated.View key="checking" entering={FadeIn.duration(150)} role="status" aria-label="Checking username" style={styles.availabilitySpin}>
368 <Spinner size={16} color={c.link} track={c.line} />
369 </Animated.View>
370 );
371 }
372 const good = check === 'available';
373 const tone = good ? c.good : c.bad;
374 const Mark = good ? Check : X;
375 return (
376 <Animated.View key={check} entering={ZoomIn.duration(220)} role="status" style={styles.availability}>
377 <View style={[styles.availabilityMark, { backgroundColor: tone }]}>
378 <Mark size={11} color={c.onStatus} strokeWidth={3.6} />
379 </View>
380 <Text style={[styles.availabilityText, { color: tone }]}>{good ? 'Available' : check === 'taken' ? 'Taken' : 'Too short'}</Text>
381 </Animated.View>
382 );
383}
384
385// ─── Bio counter: a ring that fills, then warns ─────────────────────────────
386
387const RING_R = 8.5;
388const RING_LEN = 2 * Math.PI * RING_R;
389const AnimatedCircle = Animated.createAnimatedComponent(Circle);
390
391function CountRing({ count }: { count: number }) {
392 const c = usePalette();
393 const fill = useSharedValue(0);
394 const bump = useSharedValue(1);
395 const first = useRef(true);
396 const share = Math.min(1, count / BIO_LIMIT);
397 const full = count >= BIO_LIMIT;
398 useEffect(() => {
399 // Sweeps in once on load, then follows each keystroke.
400 fill.value = first.current ? withDelay(320, withTiming(share, { duration: 620, easing: Easing.out(Easing.cubic) })) : withTiming(share, SOFT);
401 first.current = false;
402 }, [share, fill]);
403 useEffect(() => {
404 if (full) bump.value = withSequence(withTiming(1.3, { duration: 110 }), withTiming(1, { duration: 200, easing: Easing.out(Easing.back(2)) }));
405 }, [full, bump]);
406 const arc = useAnimatedProps(() => ({ strokeDashoffset: RING_LEN * (1 - fill.value) }));
407 const ring = useAnimatedStyle(() => ({ transform: [{ scale: bump.value }, { rotate: '-90deg' }] }));
408 const tone = count >= BIO_DANGER ? c.bad : count >= BIO_WARN ? c.warn : c.link;
409 const left = BIO_LIMIT - count;
410 return (
411 <View pointerEvents="none" role="status" aria-label={`${count} of ${BIO_LIMIT} characters`} style={styles.counter}>
412 {count >= BIO_WARN ? (
413 <Animated.Text entering={FadeIn.duration(180)} style={[styles.counterLeft, { color: tone }]}>
414 {full ? 'Limit reached' : `${left} left`}
415 </Animated.Text>
416 ) : null}
417 <Text style={[styles.counterValue, { color: count >= BIO_WARN ? tone : c.muted }, TABULAR]}>
418 {count}/{BIO_LIMIT}
419 </Text>
420 <Animated.View style={ring}>
421 <Svg width={22} height={22} viewBox="0 0 22 22">
422 <Circle cx={11} cy={11} r={RING_R} stroke={c.track} strokeWidth={2.6} fill="none" />
423 <AnimatedCircle cx={11} cy={11} r={RING_R} stroke={tone} strokeWidth={2.6} strokeLinecap="round" strokeDasharray={`${RING_LEN} ${RING_LEN}`} animatedProps={arc} fill="none" />
424 </Svg>
425 </Animated.View>
426 </View>
427 );
428}
429
430// ─── Switch ─────────────────────────────────────────────────────────────────
431
432function Switch({ on }: { on: boolean }) {
433 const c = usePalette();
434 const p = useSharedValue(on ? 1 : 0);
435 const stretch = useSharedValue(0);
436 useEffect(() => {
437 p.value = withTiming(on ? 1 : 0, { duration: 240, easing: Easing.out(Easing.cubic) });
438 // The thumb stretches as it leaves and settles as it lands.
439 stretch.value = withSequence(withTiming(1, { duration: 110 }), withTiming(0, { duration: 200, easing: Easing.out(Easing.back(2)) }));
440 }, [on, p, stretch]);
441 const track = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(p.value, [0, 1], [c.track, ACCENT]) }));
442 const thumb = useAnimatedStyle(() => {
443 const w = 26 + stretch.value * 7;
444 return { width: w, transform: [{ translateX: p.value * (50 - 4 - w) }] };
445 });
446 return (
447 <Animated.View style={[styles.switchTrack, track]}>
448 <Animated.View style={[styles.switchThumb, thumb]} />
449 </Animated.View>
450 );
451}
452
453// ─── Photo sheet ────────────────────────────────────────────────────────────
454
455function SheetRow({ icon: Icon, label, hint, tone, disabled, onPress }: { icon: LucideIcon; label: string; hint?: string; tone?: string; disabled?: boolean; onPress: () => void }) {
456 const c = usePalette();
457 const color = tone ?? c.fg;
458 return (
459 <Pressable role="button" aria-label={label} aria-disabled={disabled} disabled={disabled} onPress={onPress} style={({ pressed }) => [styles.sheetRow, { opacity: disabled ? 0.35 : 1, backgroundColor: pressed ? c.line : 'transparent' }]}>
460 <View style={[styles.sheetRowIcon, { backgroundColor: tone ? `${tone}22` : c.sheetIcon }]}>
461 <Icon size={19} color={color} strokeWidth={2.1} />
462 </View>
463 <View style={styles.fill}>
464 <Text style={[styles.sheetRowLabel, { color }]}>{label}</Text>
465 {hint ? <Text style={[styles.sheetRowHint, { color: c.muted }]}>{hint}</Text> : null}
466 </View>
467 </Pressable>
468 );
469}
470
471function PhotoSheet({ open, hasPhoto, onClose, onTake, onLibrary, onRemove }: { open: boolean; hasPhoto: boolean; onClose: () => void; onTake: () => void; onLibrary: () => void; onRemove: () => void }) {
472 const c = usePalette();
473 const insets = useSafeAreaInsets();
474 const { mounted, p } = useReveal(open, 320);
475 const backdrop = useAnimatedStyle(() => ({ opacity: p.value }));
476 const sheet = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - p.value) * 400 }] }));
477 if (!mounted) return null;
478 return (
479 <View style={[StyleSheet.absoluteFill, styles.sheetLayer]}>
480 <Animated.View style={[StyleSheet.absoluteFill, styles.scrim, backdrop]}>
481 <Pressable role="button" aria-label="Close photo options" onPress={onClose} style={styles.fill} />
482 </Animated.View>
483 <Animated.View role="dialog" aria-label="Profile photo" style={[styles.sheet, { backgroundColor: c.sheet, paddingBottom: insets.bottom + 12 }, sheet]}>
484 <View style={[styles.grabber, { backgroundColor: c.track }]} />
485 <Text role="heading" style={[styles.sheetTitle, { color: c.fg }]}>
486 Profile photo
487 </Text>
488 <Text style={[styles.sheetHint, { color: c.muted }]}>A clear photo of your face helps friends find you.</Text>
489 <View style={[styles.sheetGroup, { backgroundColor: c.sheetGroup }]}>
490 <SheetRow icon={Camera} label="Take photo" onPress={onTake} />
491 <View style={[styles.sheetDivider, { backgroundColor: c.line }]} />
492 <SheetRow icon={Images} label="Choose from library" onPress={onLibrary} />
493 <View style={[styles.sheetDivider, { backgroundColor: c.line }]} />
494 <SheetRow icon={Trash2} label="Remove photo" tone={c.bad} disabled={!hasPhoto} onPress={onRemove} />
495 </View>
496 </Animated.View>
497 </View>
498 );
499}
500
501// ─── Discard confirm ────────────────────────────────────────────────────────
502
503function DiscardDialog({ open, count, onKeep, onDiscard }: { open: boolean; count: number; onKeep: () => void; onDiscard: () => void }) {
504 const c = usePalette();
505 const { width } = useWindowDimensions();
506 const { mounted, p } = useReveal(open, 220);
507 // Hold the last count so the copy does not change while the card fades out.
508 const shownCount = useRef(count);
509 if (open && count > 0) shownCount.current = count;
510 const n = shownCount.current;
511 const backdrop = useAnimatedStyle(() => ({ opacity: p.value }));
512 const card = useAnimatedStyle(() => ({ opacity: p.value, transform: [{ scale: interpolate(p.value, [0, 1], [0.9, 1]) }, { translateY: interpolate(p.value, [0, 1], [10, 0]) }] }));
513 if (!mounted) return null;
514 return (
515 <View style={[StyleSheet.absoluteFill, styles.dialogLayer]}>
516 <Animated.View style={[StyleSheet.absoluteFill, styles.scrim, backdrop]}>
517 <Pressable role="button" aria-label="Keep editing" onPress={onKeep} style={styles.fill} />
518 </Animated.View>
519 <Animated.View role="alertdialog" aria-label="Discard changes?" style={[styles.dialog, { width: Math.min(width - 56, 330), backgroundColor: c.sheet }, card]}>
520 <Text role="heading" style={[styles.dialogTitle, { color: c.fg }]}>
521 Discard changes?
522 </Text>
523 <Text style={[styles.dialogBody, { color: c.muted }]}>
524 You have {n} unsaved {n === 1 ? 'change' : 'changes'}. {n === 1 ? 'It' : 'They'} will be lost if you leave now.
525 </Text>
526 <View style={styles.dialogActions}>
527 <Tap label="Keep editing" onPress={onKeep} to={0.96} style={styles.fill}>
528 <View style={[styles.dialogButton, { backgroundColor: c.chip }]}>
529 <Text style={[styles.dialogButtonLabel, { color: c.fg }]}>Keep editing</Text>
530 </View>
531 </Tap>
532 <Tap label="Discard" onPress={onDiscard} to={0.96} style={styles.fill}>
533 <View style={[styles.dialogButton, styles.discardButton]}>
534 <Text style={[styles.dialogButtonLabel, styles.discardLabel]}>Discard</Text>
535 </View>
536 </Tap>
537 </View>
538 </Animated.View>
539 </View>
540 );
541}
542
543// ─── Toast ──────────────────────────────────────────────────────────────────
544
545function Toast({ open, top }: { open: boolean; top: number }) {
546 const c = usePalette();
547 const { mounted, p } = useReveal(open, 320);
548 const style = useAnimatedStyle(() => ({ opacity: p.value, transform: [{ translateY: interpolate(p.value, [0, 1], [-28, 0]) }] }));
549 if (!mounted) return null;
550 return (
551 <View pointerEvents="none" style={[styles.toastSlot, { top }]}>
552 <Animated.View role="status" style={[styles.toast, { backgroundColor: c.toast }, style]}>
553 <View style={[styles.toastMark, { backgroundColor: c.toastMark }]}>
554 <Check size={13} color={c.toastTick} strokeWidth={3.6} />
555 </View>
556 <Text style={[styles.toastText, { color: c.toastFg }]}>Profile saved</Text>
557 </Animated.View>
558 </View>
559 );
560}
561
562// ─── Screen ─────────────────────────────────────────────────────────────────
563
564const enter = (delay: number) => FadeInDown.delay(delay).duration(420);
565
566export default function EditProfileScreen() {
567 const c = usePalette();
568 const insets = useSafeAreaInsets();
569 const { width } = useWindowDimensions();
570 const navH = insets.top + BAR;
571
572 // Replace SAVED with your user query. `saved` is the baseline, `draft` is what is on screen.
573 const [saved, setSaved] = useState<Profile>(SAVED);
574 const [draft, setDraft] = useState<Profile>({ ...SAVED, bio: DRAFT_BIO });
575 const [saveState, setSaveState] = useState<SaveState>('idle');
576 const [toast, setToast] = useState(false);
577 const [sheet, setSheet] = useState(false);
578 const [confirm, setConfirm] = useState(false);
579 const [verdict, setVerdict] = useState<{ name: string; free: boolean } | null>(null);
580 const [touched, setTouched] = useState<{ name?: boolean; website?: boolean }>({});
581 const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
582 const later = (fn: () => void, ms: number) => timers.current.push(setTimeout(fn, ms));
583 useEffect(() => () => timers.current.forEach(clearTimeout), []);
584
585 const set = <K extends keyof Profile>(key: K, value: Profile[K]) => setDraft((d) => ({ ...d, [key]: value }));
586 const now = tidy(draft);
587 const changed = (Object.keys(saved) as (keyof Profile)[]).filter((k) => now[k] !== saved[k]);
588 const dirty = changed.length > 0;
589 const isChanged = (k: keyof Profile) => changed.includes(k);
590
591 // Username: your own is always fine; anything else is checked after a pause in typing.
592 const username = draft.username;
593 const check: Check = username === saved.username ? 'same' : username.length < 3 ? 'short' : verdict?.name === username ? (verdict.free ? 'available' : 'taken') : 'checking';
594 useEffect(() => {
595 if (check !== 'checking') return;
596 // Replace with a debounced call to your availability endpoint.
597 const t = setTimeout(() => setVerdict({ name: username, free: !TAKEN.includes(username) }), 750);
598 return () => clearTimeout(t);
599 }, [check, username]);
600
601 const nameProblem = now.name ? null : 'Add a name so people can find you.';
602 const siteProblem = !now.website || SITE_RE.test(now.website) ? null : 'Enter a full address, like sofiamartinez.photo';
603 const valid = !nameProblem && !siteProblem && (check === 'same' || check === 'available');
604 const ready = dirty && valid;
605
606 const nudge = useSharedValue(0);
607 const save = () => {
608 if (!dirty || saveState !== 'idle') return;
609 if (!valid) {
610 // Point at what is wrong instead of saving.
611 setTouched({ name: true, website: true });
612 nudge.value = withSequence(withTiming(-6, { duration: 50 }), withTiming(6, { duration: 60 }), withTiming(-4, { duration: 60 }), withTiming(0, { duration: 50 }));
613 return;
614 }
615 const snapshot = now;
616 setSaveState('saving');
617 // Replace the timer with your update call; on success the draft becomes the new baseline.
618 later(() => {
619 setSaved(snapshot);
620 setSaveState('saved');
621 setToast(true);
622 later(() => setSaveState('idle'), 1500);
623 later(() => setToast(false), 2400);
624 }, 1000);
625 };
626 const cancel = () => {
627 // With nothing to lose, go straight back with your router.
628 if (dirty) setConfirm(true);
629 };
630 const discard = () => {
631 setDraft(saved);
632 setTouched({});
633 setConfirm(false);
634 };
635
636 const scrollY = useSharedValue(0);
637 const onScroll = useAnimatedScrollHandler((e) => {
638 scrollY.value = e.contentOffset.y;
639 });
640 const hairline = useAnimatedStyle(() => ({ opacity: interpolate(scrollY.value, [0, 16], [0, 1], 'clamp') }));
641
642 const portrait = draft.avatar ? PORTRAITS[draft.avatar] : null;
643 const card = [styles.card, { borderColor: c.cardEdge, backgroundColor: c.card }];
644
645 return (
646 <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={[styles.screen, { backgroundColor: c.bg }]}>
647 <Animated.ScrollView onScroll={onScroll} scrollEventThrottle={16} showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled" contentContainerStyle={{ paddingTop: navH, paddingBottom: insets.bottom + 26 }}>
648 {/* Cover and avatar */}
649 <Animated.View entering={FadeIn.duration(360)}>
650 <View style={styles.cover}>
651 <Photo id={COVER.id} alt={COVER.alt} tint={COVER.tint} w={900} style={StyleSheet.absoluteFill} />
652 <LinearGradient pointerEvents="none" colors={['rgba(0,0,0,0)', 'rgba(0,0,0,0.38)']} style={styles.coverShade} />
653 {/* Open your image picker for the cover from onPress. */}
654 <Tap label="Change cover photo" style={styles.coverButtonSlot}>
655 <View style={styles.coverButton}>
656 <Camera size={15} color="#FFFFFF" strokeWidth={2.3} />
657 <Text style={styles.coverButtonLabel}>Edit cover</Text>
658 </View>
659 </Tap>
660 </View>
661 <View style={styles.avatarRow}>
662 <Tap label="Change profile photo" onPress={() => setSheet(true)} to={0.95}>
663 <View style={[styles.avatar, { backgroundColor: c.bg }]}>
664 <Animated.View key={draft.avatar ?? 'initials'} entering={ZoomIn.duration(280)}>
665 {portrait ? (
666 <Photo id={portrait.id} alt={portrait.alt} tint={portrait.tint} w={300} style={styles.avatarInner} />
667 ) : (
668 <LinearGradient colors={[shade(ACCENT, -0.32), shade(ACCENT, 0.17)]} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={[styles.avatarInner, styles.initials]}>
669 <Text style={styles.initialsText}>{initials(draft.name)}</Text>
670 </LinearGradient>
671 )}
672 </Animated.View>
673 <View style={[styles.cameraBadge, { backgroundColor: c.bg }]}>
674 <View style={styles.cameraBadgeInner}>
675 <Camera size={15} color={ON_ACCENT} strokeWidth={2.4} />
676 </View>
677 </View>
678 </View>
679 </Tap>
680 {/* Live preview of how the name and handle will read on the profile. */}
681 <View style={styles.identity}>
682 <Text numberOfLines={1} style={[styles.identityName, { color: now.name ? c.fg : c.faint }]}>
683 {now.name || 'Your name'}
684 </Text>
685 <Text numberOfLines={1} style={[styles.identityHandle, { color: c.muted }]}>
686 @{username || 'username'}
687 </Text>
688 </View>
689 </View>
690 </Animated.View>
691
692 {/* About */}
693 <Animated.View entering={enter(60)} style={[card, styles.cardFirst]}>
694 <Field
695 icon={UserRound}
696 label="Name"
697 value={draft.name}
698 onChangeText={(v) => set('name', v.slice(0, 40))}
699 changed={isChanged('name')}
700 error={touched.name ? nameProblem : null}
701 onBlurred={() => setTouched((t) => ({ ...t, name: true }))}
702 autoCapitalize="words"
703 autoComplete="name"
704 />
705 <Field
706 icon={IdCard}
707 label="Username"
708 prefix="@"
709 value={username}
710 // Handles are lower case letters, numbers, dots and underscores.
711 onChangeText={(v) => set('username', v.toLowerCase().replace(/[^a-z0-9._]/g, '').slice(0, 20))}
712 changed={isChanged('username')}
713 trailing={<Availability check={check} />}
714 autoCapitalize="none"
715 autoCorrect={false}
716 autoComplete="username"
717 />
718 <Field
719 icon={AlignLeft}
720 label="Bio"
721 grow
722 divider={false}
723 value={draft.bio}
724 onChangeText={(v) => set('bio', v.slice(0, BIO_LIMIT))}
725 maxLength={BIO_LIMIT}
726 changed={isChanged('bio')}
727 footer={<CountRing count={draft.bio.length} />}
728 />
729 </Animated.View>
730
731 {/* Links */}
732 <Animated.View entering={enter(120)} style={[card, styles.cardNext]}>
733 <Field icon={MapPin} label="Location" value={draft.location} onChangeText={(v) => set('location', v)} changed={isChanged('location')} autoCapitalize="words" />
734 <Field
735 icon={Globe}
736 label="Website"
737 divider={false}
738 value={draft.website}
739 onChangeText={(v) => {
740 set('website', v.replace(/\s/g, ''));
741 setTouched((t) => ({ ...t, website: false }));
742 }}
743 changed={isChanged('website')}
744 error={touched.website ? siteProblem : null}
745 onBlurred={() => setTouched((t) => ({ ...t, website: true }))}
746 keyboardType="url"
747 autoCapitalize="none"
748 autoCorrect={false}
749 />
750 </Animated.View>
751
752 {/* Privacy */}
753 <Animated.View entering={enter(180)} style={[card, styles.cardNext]}>
754 <Pressable role="switch" aria-checked={draft.isPrivate} aria-label="Private account" onPress={() => set('isPrivate', !draft.isPrivate)} style={styles.privacy}>
755 <View style={styles.privacyIcon}>
756 <Lock size={20} color={draft.isPrivate ? c.link : c.muted} strokeWidth={2} />
757 </View>
758 <View style={styles.privacyBody}>
759 <View style={styles.row}>
760 <Text style={[styles.privacyTitle, { color: c.fg }]}>Private account</Text>
761 {isChanged('isPrivate') ? <Animated.View entering={ZoomIn.duration(220)} aria-label="Edited" style={[styles.privacyDot, { backgroundColor: c.link }]} /> : null}
762 </View>
763 <Text style={[styles.privacyHint, { color: c.muted }]}>New followers need your approval.</Text>
764 </View>
765 <Switch on={draft.isPrivate} />
766 </Pressable>
767 </Animated.View>
768
769 {/* Send this to your deactivation flow. */}
770 <Animated.View entering={enter(240)} style={styles.deactivate}>
771 <Pressable role="button" aria-label="Deactivate account" hitSlop={8} style={({ pressed }) => [styles.deactivateButton, { opacity: pressed ? 0.5 : 1 }]}>
772 <Text style={[styles.deactivateLabel, { color: c.bad }]}>Deactivate account</Text>
773 </Pressable>
774 <Text style={[styles.deactivateNote, { color: c.faint, maxWidth: width - 96 }]}>Your profile is hidden until you sign in again.</Text>
775 </Animated.View>
776 </Animated.ScrollView>
777
778 <Toast open={toast} top={navH + 10} />
779
780 {/* Header: opaque, under the status bar */}
781 <View style={[styles.header, { paddingTop: insets.top, backgroundColor: c.bg }]}>
782 <View style={styles.headerBar}>
783 <View pointerEvents="none" style={[StyleSheet.absoluteFill, styles.headerTitleSlot]}>
784 <Text role="heading" style={[styles.headerTitle, { color: c.fg }]}>
785 Edit profile
786 </Text>
787 </View>
788 <Pressable role="button" aria-label="Cancel" hitSlop={10} onPress={cancel} style={({ pressed }) => [styles.cancel, { opacity: pressed ? 0.5 : 1 }]}>
789 <Text style={[styles.cancelLabel, { color: c.fg }]}>Cancel</Text>
790 </Pressable>
791 <SaveButton ready={ready} dirty={dirty} state={saveState} nudge={nudge} onPress={save} />
792 </View>
793 <Animated.View style={[styles.headerRule, { backgroundColor: c.line }, hairline]} />
794 </View>
795
796 <PhotoSheet
797 open={sheet}
798 hasPhoto={draft.avatar !== null}
799 onClose={() => setSheet(false)}
800 // Launch the camera here; this demo only closes the sheet.
801 onTake={() => setSheet(false)}
802 onLibrary={() => {
803 // Stand-in for the image picker result.
804 set('avatar', draft.avatar === 'lake' ? 'sofia' : 'lake');
805 setSheet(false);
806 }}
807 onRemove={() => {
808 set('avatar', null);
809 setSheet(false);
810 }}
811 />
812 <DiscardDialog open={confirm} count={changed.length} onKeep={() => setConfirm(false)} onDiscard={discard} />
813 </KeyboardAvoidingView>
814 );
815}
816
817// ─── Styles ─────────────────────────────────────────────────────────────────
818
819const styles = StyleSheet.create({
820 screen: { flex: 1 },
821 fill: { flex: 1 },
822
823 // Header
824 header: { position: 'absolute', top: 0, left: 0, right: 0, zIndex: 10 },
825 headerBar: { height: BAR, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 16 },
826 headerTitleSlot: { alignItems: 'center', justifyContent: 'center' },
827 headerTitle: { fontSize: 17, fontWeight: '700', letterSpacing: -0.3 },
828 cancel: { height: 34, justifyContent: 'center' },
829 cancelLabel: { fontSize: 16 },
830 headerRule: { height: 1 },
831 save: { width: 66, height: 34, borderRadius: 17, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' },
832 saveLabel: { fontSize: 15, fontWeight: '700' },
833 spinner: { borderWidth: 2.2 },
834
835 // Cover and avatar
836 photo: { overflow: 'hidden' },
837 photoSheen: { backgroundColor: '#FFFFFF' },
838 photoImage: { width: '100%', height: '100%' },
839 cover: { height: COVER_H },
840 coverShade: { position: 'absolute', left: 0, right: 0, bottom: 0, height: 64 },
841 coverButtonSlot: { position: 'absolute', right: 12, bottom: 12 },
842 coverButton: { height: 32, paddingHorizontal: 12, borderRadius: 16, flexDirection: 'row', alignItems: 'center', gap: 6, backgroundColor: 'rgba(0,0,0,0.55)', borderWidth: 1, borderColor: 'rgba(255,255,255,0.22)' },
843 coverButtonLabel: { color: '#FFFFFF', fontSize: 13, fontWeight: '600' },
844 avatarRow: { flexDirection: 'row', alignItems: 'flex-end', paddingHorizontal: 16, marginTop: -AVATAR / 2 },
845 avatar: { width: AVATAR, height: AVATAR, borderRadius: AVATAR / 2, alignItems: 'center', justifyContent: 'center' },
846 avatarInner: { width: AVATAR - 8, height: AVATAR - 8, borderRadius: (AVATAR - 8) / 2 },
847 initials: { alignItems: 'center', justifyContent: 'center' },
848 initialsText: { color: ON_ACCENT, fontSize: 30, fontWeight: '700', letterSpacing: 0.5 },
849 cameraBadge: { position: 'absolute', right: -2, bottom: 0, width: 34, height: 34, borderRadius: 17, alignItems: 'center', justifyContent: 'center' },
850 cameraBadgeInner: { width: 28, height: 28, borderRadius: 14, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },
851 identity: { flex: 1, marginLeft: 14, paddingBottom: 1 },
852 identityName: { fontSize: 19, lineHeight: 24, fontWeight: '800', letterSpacing: -0.4 },
853 identityHandle: { fontSize: 14 },
854
855 // Cards and fields
856 card: { marginHorizontal: 16, borderRadius: 20, borderWidth: 1, overflow: 'hidden' },
857 cardFirst: { marginTop: 16 },
858 cardNext: { marginTop: 12 },
859 field: { flexDirection: 'row', paddingLeft: 16, paddingRight: 14 },
860 focusBar: { position: 'absolute', left: 0, top: 14, bottom: 14, width: 3, borderTopRightRadius: 2, borderBottomRightRadius: 2 },
861 fieldIcon: { width: 22, height: ROW, alignItems: 'center', justifyContent: 'center' },
862 fieldBody: { flex: 1, marginLeft: 14 },
863 bioText: { fontSize: 16, lineHeight: 22 },
864 bioSizer: { marginTop: 29, minHeight: 44, opacity: 0 },
865 bioInput: { paddingTop: 29, paddingBottom: 0, paddingHorizontal: 0 },
866 row: { flexDirection: 'row', alignItems: 'center' },
867 prefix: { paddingTop: 21, fontSize: 16 },
868 input: { flex: 1, minWidth: 0, height: ROW, paddingTop: 21, paddingBottom: 0, paddingHorizontal: 0, fontSize: 16 },
869 fieldLabel: { position: 'absolute', left: 0, top: 0, height: ROW, flexDirection: 'row', alignItems: 'center', transformOrigin: 'left center' },
870 fieldLabelText: { fontSize: 16 },
871 editedDot: { width: 7, height: 7, borderRadius: 4, marginLeft: 7 },
872 fieldError: { fontSize: 13, marginTop: -3, marginBottom: 11 },
873 fieldDivider: { height: 1, marginLeft: 52 },
874 availabilitySpin: { marginLeft: 10 },
875 availability: { flexDirection: 'row', alignItems: 'center', gap: 6, marginLeft: 10 },
876 availabilityMark: { width: 17, height: 17, borderRadius: 9, alignItems: 'center', justifyContent: 'center' },
877 availabilityText: { fontSize: 13.5, fontWeight: '600' },
878 counter: { flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-end', gap: 8, height: 24, marginTop: 6, marginBottom: 10 },
879 counterLeft: { fontSize: 12.5, fontWeight: '600', marginRight: 2 },
880 counterValue: { fontSize: 12.5, fontWeight: '500' },
881
882 // Privacy
883 privacy: { flexDirection: 'row', alignItems: 'center', paddingLeft: 16, paddingRight: 14, paddingVertical: 13 },
884 privacyIcon: { width: 22, alignItems: 'center' },
885 privacyBody: { flex: 1, marginLeft: 14, marginRight: 12 },
886 privacyTitle: { fontSize: 16, fontWeight: '600' },
887 privacyDot: { width: 6, height: 6, borderRadius: 3, marginLeft: 7 },
888 privacyHint: { fontSize: 13, lineHeight: 18, marginTop: 1 },
889 switchTrack: { width: 50, height: 30, borderRadius: 15, padding: 2 },
890 switchThumb: { height: 26, borderRadius: 13, backgroundColor: '#FFFFFF', shadowColor: '#000', shadowOpacity: 0.22, shadowRadius: 3, shadowOffset: { width: 0, height: 1 } },
891 deactivate: { alignItems: 'center', marginTop: 12 },
892 deactivateButton: { paddingVertical: 6, paddingHorizontal: 12 },
893 deactivateLabel: { fontSize: 15, fontWeight: '600' },
894 deactivateNote: { fontSize: 12.5, marginTop: 2, textAlign: 'center' },
895
896 // Photo sheet
897 scrim: { backgroundColor: 'rgba(0,0,0,0.55)' },
898 sheetLayer: { zIndex: 30, justifyContent: 'flex-end' },
899 sheet: { borderTopLeftRadius: 26, borderTopRightRadius: 26, paddingHorizontal: 16 },
900 grabber: { alignSelf: 'center', width: 38, height: 5, borderRadius: 3, marginTop: 9 },
901 sheetTitle: { fontSize: 19, fontWeight: '800', letterSpacing: -0.4, marginTop: 16 },
902 sheetHint: { fontSize: 14, marginTop: 3 },
903 sheetGroup: { marginTop: 16, borderRadius: 18, overflow: 'hidden' },
904 sheetDivider: { height: 1, marginLeft: 66 },
905 sheetRow: { height: 62, flexDirection: 'row', alignItems: 'center', gap: 14, paddingHorizontal: 14 },
906 sheetRowIcon: { width: 38, height: 38, borderRadius: 19, alignItems: 'center', justifyContent: 'center' },
907 sheetRowLabel: { fontSize: 16, fontWeight: '600' },
908 sheetRowHint: { fontSize: 13, marginTop: 1 },
909
910 // Discard dialog
911 dialogLayer: { zIndex: 40, alignItems: 'center', justifyContent: 'center' },
912 dialog: { borderRadius: 24, padding: 20, paddingTop: 22, shadowColor: '#000', shadowOpacity: 0.3, shadowRadius: 30, shadowOffset: { width: 0, height: 14 } },
913 dialogTitle: { fontSize: 19, fontWeight: '800', letterSpacing: -0.4 },
914 dialogBody: { fontSize: 15, lineHeight: 21, marginTop: 6 },
915 dialogActions: { flexDirection: 'row', gap: 10, marginTop: 20 },
916 dialogButton: { height: 46, borderRadius: 14, alignItems: 'center', justifyContent: 'center' },
917 dialogButtonLabel: { fontSize: 15.5, fontWeight: '700' },
918 discardButton: { backgroundColor: '#E5484D' },
919 discardLabel: { color: '#FFFFFF' },
920
921 // Toast
922 toastSlot: { position: 'absolute', left: 0, right: 0, alignItems: 'center', zIndex: 5 },
923 toast: { flexDirection: 'row', alignItems: 'center', gap: 9, height: 42, paddingLeft: 11, paddingRight: 17, borderRadius: 21, shadowColor: '#000', shadowOpacity: 0.25, shadowRadius: 16, shadowOffset: { width: 0, height: 8 } },
924 toastMark: { width: 22, height: 22, borderRadius: 11, alignItems: 'center', justifyContent: 'center' },
925 toastText: { fontSize: 14.5, fontWeight: '700' },
926});

More screens like this.

All Profile & Settings