Saved delivery addresses under a drawn street map: choosing a row pans the map and drops the pin with a bounce while a check springs onto the row, Use current location pulses a locating ring and then fills in a new address, and Add new address opens a sheet with label chips, floating-label fields and inline validation that shakes on errors. Saved rows spring into the list, edit mode deletes with an undo snackbar, and a sticky Deliver here button spins and confirms with a check.

Details
Using gluestack-ui?
Optional. The screen is plain React Native; these components can stand in for its primitives.
1import { memo, useEffect, useRef, useState, type ComponentRef, type ReactNode } from 'react';2import {3 KeyboardAvoidingView,4 Platform,5 Pressable,6 ScrollView,7 StyleSheet,8 Text,9 TextInput,10 View,11 useColorScheme,12 useWindowDimensions,13 type LayoutChangeEvent,14 type TextInputProps,15} from 'react-native';16import Animated, {17 cancelAnimation,18 Easing,19 FadeIn,20 FadeInDown,21 FadeOut,22 FadeOutDown,23 interpolate,24 interpolateColor,25 LinearTransition,26 useAnimatedStyle,27 useSharedValue,28 withDelay,29 withRepeat,30 withSequence,31 withSpring,32 withTiming,33 ZoomIn,34} from 'react-native-reanimated';35import { useSafeAreaInsets } from 'react-native-safe-area-context';36import Svg, { Circle, Ellipse, Path, Rect, Text as SvgText } from 'react-native-svg';37import {38 Bike,39 Briefcase,40 Check,41 ChevronLeft,42 Dumbbell,43 Heart,44 House,45 LocateFixed,46 MapPin,47 Navigation,48 Plus,49 StickyNote,50 Trash2,51 Users,52 X,53 type LucideIcon,54} from 'lucide-react-native';5556// ─── Brand ──────────────────────────────────────────────────────────────────57// The app's accent and name. Every accent colour below derives from these, so changing them rebrands the screen. The map's own colours (water, parks, the blue "you are here" dot) are not the brand.5859const ACCENT = '#12A150';60const ACCENT_DARK = '#3DDC84'; // the accent as text on dark backgrounds61const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill62const APP_NAME = 'Hopper';6364/** `hex` at `alpha` opacity, as rgba(). */65function tint(hex: string, alpha: number) {66 const n = parseInt(hex.slice(1), 16);67 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;68}6970/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */71function shade(hex: string, amount: number) {72 const n = parseInt(hex.slice(1), 16);73 const target = amount < 0 ? 255 : 0;74 const p = Math.abs(amount);75 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');76 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();77}7879// ─── Sample data ────────────────────────────────────────────────────────────8081type Kind = 'home' | 'work' | 'partner' | 'family' | 'gym' | 'other' | 'here';8283const KINDS: Record<Kind, { title: string; chip: string; Icon: LucideIcon }> = {84 home: { title: 'Home', chip: 'Home', Icon: House },85 work: { title: 'Work', chip: 'Work', Icon: Briefcase },86 partner: { title: "Partner's place", chip: 'Partner', Icon: Heart },87 family: { title: 'Mum and Dad', chip: 'Family', Icon: Users },88 gym: { title: 'Gym', chip: 'Gym', Icon: Dumbbell },89 other: { title: 'Other', chip: 'Other', Icon: MapPin },90 here: { title: 'Current location', chip: 'Here', Icon: Navigation },91};92// The labels offered in the "New address" sheet.93const CHIPS: Kind[] = ['home', 'work', 'partner', 'family', 'gym', 'other'];9495// x and y place the address on the drawn map (see "Drawn map"). With a real map these are latitude and longitude.96type Address = { id: string; kind: Kind; label: string; line1: string; line2: string; notes?: string; eta: string; x: number; y: number };9798const ADDRESSES: Address[] = [99 { id: 'home', kind: 'home', label: 'Home', line1: '14 Alder Street, Apt 5B', line2: 'Riverside, 10027', notes: 'Buzzer 5B, leave with the concierge', eta: '25 to 35 min', x: 386, y: 214 },100 { id: 'work', kind: 'work', label: 'Work', line1: '220 Linden Avenue, Floor 9', line2: 'Midtown, 10018', notes: 'Front desk closes at 6 pm', eta: '15 to 25 min', x: 628, y: 312 },101 { id: 'partner', kind: 'partner', label: "Partner's place", line1: '8 Quay Street, Flat 2', line2: 'Riverside, 10031', eta: '30 to 40 min', x: 500, y: 412 },102 { id: 'family', kind: 'family', label: 'Mum and Dad', line1: '57 Juniper Row', line2: 'Eastfield, 10465', notes: 'Side gate, the dog is friendly', eta: '40 to 50 min', x: 758, y: 214 },103];104const DEFAULT_ID = 'home';105106// Where the simulated "current location" lands, and the address it resolves to.107const HERE: Address = { id: 'here', kind: 'here', label: 'Current location', line1: '31 Mercer Lane', line2: 'Midtown, 10018', eta: '10 to 20 min', x: 622, y: 208 };108// Map points handed to addresses added from the sheet, in turn. A geocoder gives you these.109const SPOTS = [110 { x: 392, y: 410 },111 { x: 748, y: 306 },112 { x: 506, y: 316 },113];114115// ─── Palette ────────────────────────────────────────────────────────────────116117const ACCENT_DEEP = shade(ACCENT, 0.2); // the confirmed state of the main button: the brand, a step deeper, with a check118const LOCATION = '#2F7BFF'; // the "you are here" dot, a map convention rather than the brand119const POP = { damping: 11, stiffness: 260, mass: 0.6 };120const PRESS = { damping: 16, stiffness: 320, mass: 0.6 };121const MOVE = LinearTransition.duration(280);122const COLUMN = 520; // widest the screen gets on tablets and the web123const MAP_BODY = 232; // map height below the status bar124const SHEET_LAP = 24; // how far the list's rounded top rides over the map125const BUTTON_H = 58;126const NO_OUTLINE = Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null;127128const MAP_LIGHT = { land: '#EFF0E8', building: '#E2E4DA', road: '#FFFFFF', casing: '#D9DCD0', water: '#B3DAF0', park: '#C9E7B7', tree: '#A5D28F', path: '#E4F2D6', label: '#8B8F82' };129const MAP_DARK = { land: '#17191C', building: '#1F2226', road: '#30353B', casing: '#30353B', water: '#12324A', park: '#183322', tree: '#21482F', path: '#1F3E2B', label: '#7C828B' };130type MapColors = typeof MAP_LIGHT;131132function usePalette() {133 const dark = useColorScheme() === 'dark';134 return {135 dark,136 bg: dark ? '#0A0A0B' : '#F5F5F2',137 surface: dark ? '#17171A' : '#FFFFFF',138 field: dark ? '#141416' : '#FFFFFF',139 tile: dark ? '#242428' : '#F0F0EC',140 fg: dark ? '#FAFAFA' : '#0A0A0A',141 body: dark ? '#C9C9CE' : '#3F3F46',142 muted: dark ? '#8A8A8F' : '#75757B',143 faint: dark ? '#4A4A50' : '#C2C2C8',144 border: dark ? '#29292D' : '#E6E6E1',145 track: dark ? '#303036' : '#DEDEE2',146 accentText: dark ? ACCENT_DARK : shade(ACCENT, 0.22),147 accentSoft: dark ? tint(ACCENT, 0.2) : tint(ACCENT, 0.13),148 selected: dark ? tint(ACCENT, 0.1) : tint(ACCENT, 0.07),149 halo: dark ? tint(ACCENT, 0.28) : tint(ACCENT, 0.22),150 error: dark ? '#FF6B6B' : '#E5484D',151 errorSoft: dark ? 'rgba(255,107,107,0.14)' : 'rgba(229,72,77,0.1)',152 backdrop: dark ? 'rgba(0,0,0,0.72)' : 'rgba(10,10,10,0.45)',153 snack: dark ? '#F4F4F5' : '#18181B',154 snackText: dark ? '#0A0A0A' : '#FAFAFA',155 snackAction: dark ? shade(ACCENT, 0.22) : ACCENT_DARK,156 map: dark ? MAP_DARK : MAP_LIGHT,157 };158}159type Palette = ReturnType<typeof usePalette>;160161// ─── Drawn map: a small invented city, one static SVG that the screen pans ──162163const WORLD_W = 1040;164const WORLD_H = 620;165const STREETS_X = [50, 150, 330, 440, 560, 690, 820, 940];166const AVENUES_Y = [60, 160, 260, 360, 470, 570];167const RIVER = 'M236 -30 C206 110 282 230 252 370 S210 560 240 650';168// Minor cross streets stop at the river; the wide avenues bridge it.169const MINOR_ROADS = [170 ...STREETS_X.filter((x) => x !== 440 && x !== 820).map((x) => `M${x} 0V${WORLD_H}`),171 'M0 160H150',172 'M330 160H1040',173 'M0 360H150',174 'M330 360H1040',175 `M0 60H${WORLD_W}`,176 `M0 570H${WORLD_W}`,177].join('');178const MAJOR_ROADS = [`M440 0V${WORLD_H}`, `M820 0V${WORLD_H}`, `M0 260H${WORLD_W}`, `M0 470H${WORLD_W}`].join('');179180type Box = { x: number; y: number; w: number; h: number };181182/** Building footprints for every block: halves, quarters or a courtyard, picked by a fixed pattern. */183function footprints() {184 const cols = [0, ...STREETS_X, WORLD_W];185 const rows = [0, ...AVENUES_Y, WORLD_H];186 const out: Box[] = [];187 for (let ci = 0; ci < cols.length - 1; ci++) {188 for (let ri = 0; ri < rows.length - 1; ri++) {189 const x = cols[ci] + 12;190 const y = rows[ri] + 12;191 const w = cols[ci + 1] - cols[ci] - 24;192 const h = rows[ri + 1] - rows[ri] - 24;193 const park = (ci === 4 && ri === 2) || (ci === 6 && ri === 4);194 if (park || w < 20 || h < 20) continue;195 // The river runs through this column: keep one terrace along its east bank.196 if (ci === 2) {197 out.push({ x: 300, y, w: 18, h });198 continue;199 }200 const pick = (ci * 7 + ri * 13) % 6;201 const hw = (w - 6) / 2;202 const hh = (h - 6) / 2;203 if (w < 50 || pick === 0) out.push({ x, y, w, h: hh }, { x, y: y + hh + 6, w, h: hh });204 else if (pick === 1) out.push({ x, y, w: hw, h }, { x: x + hw + 6, y, w: hw, h });205 else if (pick === 2) out.push({ x, y, w, h: hh }, { x, y: y + hh + 6, w: hw, h: hh }, { x: x + hw + 6, y: y + hh + 6, w: hw, h: hh });206 else if (pick === 3) out.push({ x, y, w: hw, h: hh }, { x: x + hw + 6, y, w: hw, h }, { x, y: y + hh + 6, w: hw, h: hh });207 else if (pick === 4) out.push({ x, y, w: hw, h: hh }, { x: x + hw + 6, y, w: hw, h: hh }, { x, y: y + hh + 6, w, h: hh });208 else out.push({ x, y, w: hw, h: hh }, { x: x + hw + 6, y, w: hw, h: hh }, { x, y: y + hh + 6, w: hw, h: hh });209 }210 }211 return out;212}213const BUILDINGS = footprints();214const TREES = [215 [466, 188], [482, 232], [506, 208], [538, 184], [470, 214], [534, 238],216 [718, 388], [740, 410], [772, 386], [792, 426], [722, 440], [760, 444], [790, 398],217];218219const CityMap = memo(function CityMap({ colors }: { colors: MapColors }) {220 return (221 <Svg width={WORLD_W} height={WORLD_H} viewBox={`0 0 ${WORLD_W} ${WORLD_H}`} aria-label="Map of the neighbourhood">222 <Rect width={WORLD_W} height={WORLD_H} fill={colors.land} />223 {BUILDINGS.map((b, i) => (224 <Rect key={i} x={b.x} y={b.y} width={b.w} height={b.h} rx={3} fill={colors.building} />225 ))}226 {/* Parks */}227 <Rect x={452} y={172} width={96} height={76} rx={12} fill={colors.park} />228 <Path d="M452 216C482 200 502 236 548 198" stroke={colors.path} strokeWidth={3} fill="none" />229 <Rect x={702} y={372} width={106} height={86} rx={12} fill={colors.park} />230 <Path d="M702 420C740 436 760 392 808 404" stroke={colors.path} strokeWidth={3} fill="none" />231 {TREES.map(([x, y], i) => (232 <Circle key={i} cx={x} cy={y} r={5.5} fill={colors.tree} />233 ))}234 <Ellipse cx={520} cy={226} rx={13} ry={8} fill={colors.water} />235 {/* River: a bank in the land colour clears the footprints beside it */}236 <Path d={RIVER} stroke={colors.land} strokeWidth={68} fill="none" />237 <Path d={RIVER} stroke={colors.water} strokeWidth={48} fill="none" />238 {/* Streets, casing first */}239 <Path d={MINOR_ROADS} stroke={colors.casing} strokeWidth={11.5} fill="none" />240 <Path d={MAJOR_ROADS} stroke={colors.casing} strokeWidth={19.5} fill="none" />241 <Path d={MINOR_ROADS} stroke={colors.road} strokeWidth={10} fill="none" />242 <Path d={MAJOR_ROADS} stroke={colors.road} strokeWidth={18} fill="none" />243 <SvgText x={610} y={263} fontSize={8} fontWeight="700" letterSpacing={1} textAnchor="middle" fill={colors.label}>244 LINDEN AVE245 </SvgText>246 <SvgText x={640} y={473} fontSize={8} fontWeight="700" letterSpacing={1} textAnchor="middle" fill={colors.label}>247 QUAY ST248 </SvgText>249 <SvgText x={440} y={123} fontSize={8} fontWeight="700" letterSpacing={1} textAnchor="middle" fill={colors.label} transform="rotate(-90 440 120)">250 MARKET ST251 </SvgText>252 <SvgText x={500} y={190} fontSize={8.5} fontWeight="600" textAnchor="middle" fill={colors.label}>253 Wren Park254 </SvgText>255 </Svg>256 );257});258259// ─── Map view: pans the city under a fixed pin, which lifts and drops ───────260261const PIN_W = 46;262const PIN_H = 58;263const clamp = (v: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, v));264265type MapProps = {266 width: number;267 height: number;268 anchorY: number; // where the pin's tip rests, from the top of the map269 focus: { x: number; y: number };270 pinKey: string; // changes whenever the pin should drop again271 pinned: boolean;272 locating: boolean;273 Icon: LucideIcon;274 others: Address[];275 onPick: (id: string) => void;276 eta: string | null;277 pal: Palette;278};279280function MapView({ width, height, anchorY, focus, pinKey, pinned, locating, Icon, others, onPick, eta, pal }: MapProps) {281 const targetX = clamp(width / 2 - focus.x, width - WORLD_W, 0);282 const targetY = clamp(anchorY - focus.y, height - WORLD_H, 0);283 const tx = useSharedValue(targetX);284 const ty = useSharedValue(targetY);285 const lift = useSharedValue(1); // 1 = pin held in the air, 0 = planted286 const show = useSharedValue(0);287 const ripple = useSharedValue(1);288 const pulse = useSharedValue(0);289 const seeking = useSharedValue(0);290 const booted = useRef(false);291292 useEffect(() => {293 const first = !booted.current;294 booted.current = true;295 const pan = { duration: first ? 0 : 620, easing: Easing.inOut(Easing.cubic) };296 tx.value = withTiming(targetX, pan);297 ty.value = withTiming(targetY, pan);298 seeking.value = withTiming(locating ? 1 : 0, { duration: 220 });299 if (!pinned) {300 // Nothing to pin (locating, or the list is empty): the pin leaves upward.301 lift.value = withTiming(1, { duration: 180, easing: Easing.out(Easing.quad) });302 show.value = withTiming(0, { duration: 160 });303 return;304 }305 // Lift, wait for the map to travel, then drop with a bounce and send a ring out from the tip.306 const wait = first ? 260 : 400;307 lift.value = withSequence(withTiming(1, { duration: 170, easing: Easing.out(Easing.quad) }), withDelay(wait, withTiming(0, { duration: 620, easing: Easing.bounce })));308 show.value = withDelay(first ? 300 : 0, withTiming(1, { duration: 160 }));309 ripple.value = 0;310 ripple.value = withDelay(170 + wait + 230, withTiming(1, { duration: 720, easing: Easing.out(Easing.cubic) }));311 }, [targetX, targetY, pinKey, pinned, locating, tx, ty, lift, show, ripple, seeking]);312313 useEffect(() => {314 if (!locating) return;315 pulse.value = 0;316 pulse.value = withRepeat(withTiming(1, { duration: 1300, easing: Easing.out(Easing.quad) }), -1);317 return () => cancelAnimation(pulse);318 }, [locating, pulse]);319320 const world = useAnimatedStyle(() => ({ transform: [{ translateX: tx.value }, { translateY: ty.value }] }));321 const pin = useAnimatedStyle(() => ({322 opacity: show.value,323 transform: [{ translateY: -lift.value * 78 }, { scale: 1 + lift.value * 0.08 }],324 }));325 const shadow = useAnimatedStyle(() => ({326 opacity: show.value * (0.3 - lift.value * 0.18),327 transform: [{ scale: 1 - lift.value * 0.45 }],328 }));329 const halo = useAnimatedStyle(() => ({ opacity: show.value * (1 - lift.value), transform: [{ scale: 0.6 + (1 - lift.value) * 0.4 }] }));330 const ring = useAnimatedStyle(() => ({ opacity: (1 - ripple.value) * 0.9, transform: [{ scale: 0.3 + ripple.value * 1.5 }] }));331 const dot = useAnimatedStyle(() => ({ opacity: seeking.value, transform: [{ scale: 0.5 + seeking.value * 0.5 }] }));332 const pulseA = useAnimatedStyle(() => ({ opacity: seeking.value * (1 - pulse.value) * 0.55, transform: [{ scale: 0.3 + pulse.value * 1.2 }] }));333 const pulseB = useAnimatedStyle(() => {334 const p = (pulse.value + 0.5) % 1;335 return { opacity: seeking.value * (1 - p) * 0.55, transform: [{ scale: 0.3 + p * 1.2 }] };336 });337338 const at = { left: width / 2, top: anchorY };339 return (340 <View style={[styles.map, { height, backgroundColor: pal.map.land }]}>341 <Animated.View style={[styles.world, world]}>342 <CityMap colors={pal.map} />343 {others.map((a) => {344 const Mark = KINDS[a.kind].Icon;345 return (346 <Animated.View key={a.id} entering={ZoomIn.duration(220)} exiting={FadeOut.duration(120)} style={[styles.markerSlot, { left: a.x - 20, top: a.y - 20 }]}>347 <Pressable role="button" focusable={false} aria-label={`Show ${a.label} on the map`} onPress={() => onPick(a.id)} style={styles.markerHit}>348 <View style={[styles.marker, { backgroundColor: pal.surface, borderColor: pal.border }]}>349 <Mark size={13} color={pal.muted} strokeWidth={2.2} />350 </View>351 </Pressable>352 </Animated.View>353 );354 })}355 </Animated.View>356357 {/* The pin stays at one point of the view; the city moves under it. */}358 <View pointerEvents="none" style={[styles.anchor, at]}>359 <Animated.View style={[styles.pulse, pulseA]} />360 <Animated.View style={[styles.pulse, pulseB]} />361 <Animated.View style={[styles.hereDot, dot]} />362 <Animated.View style={[styles.halo, { backgroundColor: pal.halo }, halo]} />363 <Animated.View style={[styles.ripple, ring]} />364 <Animated.View style={[styles.pinShadow, shadow]} />365 <Animated.View style={[styles.pin, pin]}>366 <Svg width={PIN_W} height={PIN_H} viewBox="0 0 46 58">367 <Path d="M23 56C23 56 4 36 4 22a19 19 0 1 1 38 0c0 14-19 34-19 34z" fill={ACCENT} stroke="#FFFFFF" strokeWidth={2.5} strokeLinejoin="round" />368 </Svg>369 <View style={styles.pinIcon}>370 <Icon size={19} color={ON_ACCENT} strokeWidth={2.3} />371 </View>372 </Animated.View>373 </View>374375 <View pointerEvents="none" style={styles.etaSlot}>376 <Animated.View key={locating ? 'locating' : (eta ?? 'none')} entering={FadeInDown.duration(260)} style={[styles.eta, { backgroundColor: pal.surface }, pal.dark ? styles.floatDark : styles.floatLight]}>377 {locating ? <LocateFixed size={15} color={LOCATION} strokeWidth={2.4} /> : <Bike size={15} color={pal.accentText} strokeWidth={2.4} />}378 <Text numberOfLines={1} style={[styles.etaText, { color: pal.fg }]}>379 {locating ? 'Finding your location' : eta ? `${APP_NAME} arrives in ${eta}` : 'Choose where to deliver'}380 </Text>381 </Animated.View>382 </View>383 </View>384 );385}386387// ─── Small controls ─────────────────────────────────────────────────────────388389function PressableScale({ children, onPress, label, to = 0.96, disabled }: { children: ReactNode; onPress?: () => void; label: string; to?: number; disabled?: boolean }) {390 const scale = useSharedValue(1);391 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));392 return (393 <Pressable role="button" aria-label={label} disabled={disabled} onPress={onPress} onPressIn={() => (scale.value = withSpring(to, PRESS))} onPressOut={() => (scale.value = withSpring(1, PRESS))}>394 <Animated.View style={style}>{children}</Animated.View>395 </Pressable>396 );397}398399/** The mark on the chosen row: the ring takes the accent and a check springs in. */400function Radio({ on, pal }: { on: boolean; pal: Palette }) {401 const t = useSharedValue(on ? 1 : 0);402 useEffect(() => {403 t.value = on ? withSpring(1, POP) : withTiming(0, { duration: 140 });404 }, [on, t]);405 const ring = useAnimatedStyle(() => ({ borderColor: interpolateColor(Math.min(1, Math.max(0, t.value)), [0, 1], [pal.faint, ACCENT]) }));406 const fill = useAnimatedStyle(() => ({ opacity: Math.min(1, t.value * 2), transform: [{ scale: Math.max(0, t.value) }] }));407 return (408 <Animated.View style={[styles.radio, ring]}>409 <Animated.View style={[styles.radioFill, fill]}>410 <Check size={14} color={ON_ACCENT} strokeWidth={3.4} />411 </Animated.View>412 </Animated.View>413 );414}415416function Toggle({ on, pal }: { on: boolean; pal: Palette }) {417 const t = useSharedValue(on ? 1 : 0);418 useEffect(() => {419 t.value = withSpring(on ? 1 : 0, { damping: 18, stiffness: 300, mass: 0.6 });420 }, [on, t]);421 const track = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(Math.min(1, Math.max(0, t.value)), [0, 1], [pal.track, ACCENT]) }));422 const thumb = useAnimatedStyle(() => ({ transform: [{ translateX: t.value * 20 }] }));423 return (424 <Animated.View style={[styles.toggle, track]}>425 <Animated.View style={[styles.toggleThumb, thumb]} />426 </Animated.View>427 );428}429430function Spinner() {431 const r = useSharedValue(0);432 useEffect(() => {433 r.value = withRepeat(withTiming(360, { duration: 750, easing: Easing.linear }), -1);434 return () => cancelAnimation(r);435 }, [r]);436 const style = useAnimatedStyle(() => ({ transform: [{ rotate: `${r.value}deg` }] }));437 return <Animated.View style={[styles.spinner, style]} />;438}439440// ─── List rows ──────────────────────────────────────────────────────────────441442type RowProps = { address: Address; selected: boolean; isDefault: boolean; editing: boolean; onSelect: () => void; onRemove: () => void; pal: Palette };443444function AddressRow({ address, selected, isDefault, editing, onSelect, onRemove, pal }: RowProps) {445 const { Icon } = KINDS[address.kind];446 const bump = useSharedValue(1);447 const booted = useRef(false);448 // A small press-back on the card when it becomes the chosen one.449 useEffect(() => {450 if (booted.current && selected) bump.value = withSequence(withTiming(0.975, { duration: 90 }), withSpring(1, POP));451 booted.current = true;452 }, [selected, bump]);453 const style = useAnimatedStyle(() => ({ transform: [{ scale: bump.value }] }));454455 return (456 <Animated.View style={[styles.card, { backgroundColor: pal.surface, borderColor: selected ? ACCENT : pal.border }, style]}>457 {selected && <Animated.View pointerEvents="none" entering={FadeIn.duration(200)} style={[StyleSheet.absoluteFill, styles.cardWash, { backgroundColor: pal.selected }]} />}458 <Pressable role="radio" aria-checked={selected} aria-label={`${address.label}, ${address.line1}, ${address.line2}`} onPress={onSelect} style={styles.cardMain}>459 <View style={[styles.cardIcon, selected ? styles.cardIconOn : { backgroundColor: pal.tile }]}>460 <Icon size={20} color={selected ? ON_ACCENT : pal.fg} strokeWidth={2.1} />461 </View>462 <View style={styles.cardText}>463 <View style={styles.cardTitleRow}>464 <Text numberOfLines={1} style={[styles.cardTitle, { color: pal.fg }]}>465 {address.label}466 </Text>467 {isDefault && (468 <View style={[styles.badge, { backgroundColor: pal.accentSoft }]}>469 <Text style={[styles.badgeText, { color: pal.accentText }]}>Default</Text>470 </View>471 )}472 </View>473 <Text numberOfLines={1} style={[styles.cardLine, { color: pal.body }]}>474 {address.line1}475 </Text>476 <Text numberOfLines={1} style={[styles.cardLine, { color: pal.muted }]}>477 {address.line2}478 </Text>479 {address.notes ? (480 <View style={styles.noteRow}>481 <StickyNote size={12} color={pal.muted} strokeWidth={2.2} />482 <Text numberOfLines={1} style={[styles.noteText, { color: pal.muted }]}>483 {address.notes}484 </Text>485 </View>486 ) : null}487 </View>488 {!editing && (489 <Animated.View entering={FadeIn.duration(160)} style={styles.cardEnd}>490 <Radio on={selected} pal={pal} />491 </Animated.View>492 )}493 </Pressable>494 {editing && (495 <Animated.View entering={ZoomIn.springify().damping(13)} style={styles.cardEnd}>496 <PressableScale label={`Delete ${address.label}`} onPress={onRemove} to={0.88}>497 <View style={[styles.remove, { backgroundColor: pal.errorSoft }]}>498 <Trash2 size={17} color={pal.error} strokeWidth={2.2} />499 </View>500 </PressableScale>501 </Animated.View>502 )}503 </Animated.View>504 );505}506507function LocateRow({ locating, onPress, pal }: { locating: boolean; onPress: () => void; pal: Palette }) {508 const pulse = useSharedValue(0);509 useEffect(() => {510 if (!locating) return;511 pulse.value = 0;512 pulse.value = withRepeat(withTiming(1, { duration: 1100, easing: Easing.out(Easing.quad) }), -1);513 return () => {514 cancelAnimation(pulse);515 pulse.value = 0;516 };517 }, [locating, pulse]);518 const ring = useAnimatedStyle(() => ({ opacity: pulse.value === 0 ? 0 : (1 - pulse.value) * 0.7, transform: [{ scale: 1 + pulse.value * 0.7 }] }));519 return (520 <PressableScale label="Use current location" onPress={onPress} to={0.98} disabled={locating}>521 <View aria-busy={locating} style={[styles.locate, { backgroundColor: pal.surface, borderColor: pal.border }]}>522 <View style={styles.locateIconSlot}>523 <Animated.View style={[styles.locateRing, ring]} />524 <View style={[styles.locateIcon, { backgroundColor: pal.accentSoft }]}>525 <LocateFixed size={19} color={pal.accentText} strokeWidth={2.2} />526 </View>527 </View>528 <View style={styles.cardText}>529 <Text style={[styles.locateTitle, { color: pal.fg }]}>Use current location</Text>530 <Text key={locating ? 'on' : 'off'} style={[styles.cardLine, { color: pal.muted }]}>531 {locating ? 'Locating you now...' : 'Find the address where you are'}532 </Text>533 </View>534 {locating ? <View style={[styles.miniSpinner, { borderColor: pal.track, borderTopColor: pal.accentText }]} /> : <Navigation size={17} color={pal.muted} strokeWidth={2.2} />}535 </View>536 </PressableScale>537 );538}539540// ─── A field whose label floats up on focus ─────────────────────────────────541542type FieldProps = {543 label: string;544 value: string;545 onChangeText: (v: string) => void;546 error?: string | null;547 hint?: string;548 onFocusChange?: (focused: boolean) => void;549} & Omit<TextInputProps, 'value' | 'onChangeText'>;550551function Field({ label, value, onChangeText, error, hint, onFocusChange, multiline, ...input }: FieldProps) {552 const c = usePalette();553 const [focused, setFocused] = useState(false);554 const lift = useSharedValue(value ? 1 : 0);555 const ring = useSharedValue(0);556557 useEffect(() => {558 lift.value = withTiming(focused || value ? 1 : 0, { duration: 180, easing: Easing.out(Easing.cubic) });559 ring.value = withTiming(focused ? 1 : 0, { duration: 180 });560 }, [focused, value, lift, ring]);561562 const labelStyle = useAnimatedStyle(() => ({563 transform: [{ translateY: interpolate(lift.value, [0, 1], [0, -11]) }, { scale: interpolate(lift.value, [0, 1], [1, 0.8]) }],564 }));565 const boxStyle = useAnimatedStyle(() => ({566 borderColor: error ? c.error : interpolateColor(ring.value, [0, 1], [c.border, ACCENT]),567 shadowOpacity: ring.value * 0.22,568 }));569 const focus = (on: boolean) => {570 setFocused(on);571 onFocusChange?.(on);572 };573574 return (575 <View style={styles.fieldSlot}>576 <Animated.View style={[styles.field, multiline && styles.fieldTall, { backgroundColor: c.field }, boxStyle]}>577 <Animated.Text pointerEvents="none" numberOfLines={1} style={[styles.fieldLabel, { color: error ? c.error : focused ? c.accentText : c.muted }, labelStyle]}>578 {label}579 </Animated.Text>580 <TextInput581 {...input}582 multiline={multiline}583 value={value}584 onChangeText={onChangeText}585 onFocus={() => focus(true)}586 onBlur={() => focus(false)}587 aria-label={label}588 aria-invalid={!!error}589 placeholderTextColor={c.faint}590 selectionColor={ACCENT}591 style={[styles.fieldInput, multiline && styles.fieldInputTall, { color: c.fg }, NO_OUTLINE]}592 />593 {hint ? <Text style={[styles.fieldHint, { color: c.muted }]}>{hint}</Text> : null}594 </Animated.View>595 {error ? (596 <Animated.Text entering={FadeInDown.duration(180)} role="alert" style={[styles.fieldError, { color: c.error }]}>597 {error}598 </Animated.Text>599 ) : null}600 </View>601 );602}603604// ─── "New address" sheet ────────────────────────────────────────────────────605606type FieldKey = 'street' | 'apartment' | 'city' | 'postcode' | 'notes';607type Values = Record<FieldKey, string>;608type Draft = Values & { kind: Kind; isDefault: boolean };609610const EMPTY: Values = { street: '', apartment: '', city: '', postcode: '', notes: '' };611const REQUIRED: FieldKey[] = ['street', 'city', 'postcode'];612const NOTES_MAX = 80;613614function check(key: FieldKey, v: Values): string | null {615 if (key === 'street') {616 const s = v.street.trim();617 if (s.length < 5) return 'Enter the street and house number.';618 return /\d/.test(s) ? null : 'Add the house or building number.';619 }620 if (key === 'city') return v.city.trim().length < 2 ? 'Enter a city.' : null;621 if (key === 'postcode') return /^\d{5}$/.test(v.postcode) ? null : 'Use 5 digits.';622 return null;623}624625function Chip({ kind, on, onPress, pal }: { kind: Kind; on: boolean; onPress: () => void; pal: Palette }) {626 const { Icon, chip } = KINDS[kind];627 const pop = useSharedValue(1);628 const press = () => {629 pop.value = withSequence(withTiming(0.9, { duration: 80 }), withSpring(1, POP));630 onPress();631 };632 const style = useAnimatedStyle(() => ({ transform: [{ scale: pop.value }] }));633 return (634 <Pressable role="radio" aria-checked={on} aria-label={`Label: ${chip}`} onPress={press}>635 <Animated.View style={[styles.chip, on ? styles.chipOn : { backgroundColor: pal.bg, borderColor: pal.border }, style]}>636 <Icon size={15} color={on ? ON_ACCENT : pal.fg} strokeWidth={2.2} />637 <Text style={[styles.chipText, { color: on ? ON_ACCENT : pal.fg }]}>{chip}</Text>638 </Animated.View>639 </Pressable>640 );641}642643function AddSheet({ open, onClose, onSave, pal, bottom, maxHeight }: { open: boolean; onClose: () => void; onSave: (d: Draft) => void; pal: Palette; bottom: number; maxHeight: number }) {644 const [mounted, setMounted] = useState(false);645 const [values, setValues] = useState<Values>(EMPTY);646 const [errors, setErrors] = useState<Partial<Record<FieldKey, string>>>({});647 const [kind, setKind] = useState<Kind>('home');648 const [isDefault, setIsDefault] = useState(false);649 const t = useSharedValue(0);650 const shake = useSharedValue(0);651652 useEffect(() => {653 if (!open) {654 t.value = withTiming(0, { duration: 240, easing: Easing.in(Easing.cubic) });655 const id = setTimeout(() => setMounted(false), 260);656 return () => clearTimeout(id);657 }658 setValues(EMPTY);659 setErrors({});660 setKind('home');661 setIsDefault(false);662 setMounted(true);663 t.value = withTiming(1, { duration: 360, easing: Easing.out(Easing.cubic) });664 }, [open, t]);665666 const backdrop = useAnimatedStyle(() => ({ opacity: t.value }));667 const sheet = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - t.value) * 760 }] }));668 const shakeStyle = useAnimatedStyle(() => ({ transform: [{ translateX: shake.value }] }));669670 const set = (key: FieldKey, v: string) => {671 setValues((s) => ({ ...s, [key]: v }));672 if (errors[key]) setErrors((e) => ({ ...e, [key]: undefined }));673 };674 // Leaving a field that has something in it checks just that field.675 const blur = (key: FieldKey) => (focused: boolean) => {676 if (focused || !values[key]) return;677 const message = check(key, values);678 if (message) setErrors((e) => ({ ...e, [key]: message }));679 };680 const submit = () => {681 const found: Partial<Record<FieldKey, string>> = {};682 REQUIRED.forEach((key) => {683 const message = check(key, values);684 if (message) found[key] = message;685 });686 setErrors(found);687 if (Object.keys(found).length) {688 shake.value = withSequence(689 withTiming(-9, { duration: 50 }),690 withTiming(9, { duration: 60 }),691 withTiming(-6, { duration: 60 }),692 withTiming(6, { duration: 60 }),693 withTiming(0, { duration: 50 })694 );695 return;696 }697 onSave({ ...values, kind, isDefault });698 };699700 if (!mounted) return null;701 return (702 <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} pointerEvents={open ? 'auto' : 'none'} style={[StyleSheet.absoluteFill, styles.sheetHost]}>703 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: pal.backdrop }, backdrop]}>704 <Pressable aria-label="Close" onPress={onClose} style={styles.fill} />705 </Animated.View>706 <Animated.View role="dialog" aria-label="New address" style={[styles.sheet, { backgroundColor: pal.surface, maxHeight }, sheet]}>707 <View style={[styles.grabber, { backgroundColor: pal.track }]} />708 <View style={styles.sheetHead}>709 <View style={styles.sheetTitles}>710 <Text style={[styles.sheetTitle, { color: pal.fg }]}>New address</Text>711 <Text style={[styles.sheetSub, { color: pal.muted }]}>Where should we bring your orders?</Text>712 </View>713 <PressableScale label="Close new address" onPress={onClose} to={0.9}>714 <View style={[styles.round, { backgroundColor: pal.bg }]}>715 <X size={18} color={pal.fg} strokeWidth={2.2} />716 </View>717 </PressableScale>718 </View>719720 <ScrollView keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false} contentContainerStyle={[styles.sheetBody, { paddingBottom: bottom + 14 }]}>721 <ScrollView horizontal role="radiogroup" aria-label="Address label" showsHorizontalScrollIndicator={false} keyboardShouldPersistTaps="handled" style={styles.chipScroll} contentContainerStyle={styles.chips}>722 {CHIPS.map((k) => (723 <Chip key={k} kind={k} on={k === kind} onPress={() => setKind(k)} pal={pal} />724 ))}725 </ScrollView>726727 <Animated.View style={[styles.form, shakeStyle]}>728 <Field729 label="Street address"730 value={values.street}731 onChangeText={(v) => set('street', v.slice(0, 48))}732 onFocusChange={blur('street')}733 error={errors.street}734 autoCapitalize="words"735 autoComplete="street-address"736 returnKeyType="next"737 />738 <Field label="Apartment, floor (optional)" value={values.apartment} onChangeText={(v) => set('apartment', v.slice(0, 24))} autoCapitalize="words" returnKeyType="next" />739 <View style={styles.formRow}>740 <View style={styles.formCell}>741 <Field label="City" value={values.city} onChangeText={(v) => set('city', v.replace(/[^\p{L} .'-]/gu, '').slice(0, 28))} onFocusChange={blur('city')} error={errors.city} autoCapitalize="words" returnKeyType="next" />742 </View>743 <View style={styles.postcode}>744 <Field745 label="Postcode"746 value={values.postcode}747 onChangeText={(v) => set('postcode', v.replace(/\D/g, '').slice(0, 5))}748 onFocusChange={blur('postcode')}749 error={errors.postcode}750 keyboardType="number-pad"751 inputMode="numeric"752 autoComplete="postal-code"753 maxLength={5}754 />755 </View>756 </View>757 <Field758 label="Delivery notes (optional)"759 value={values.notes}760 onChangeText={(v) => set('notes', v.replace(/\n/g, ' ').slice(0, NOTES_MAX))}761 hint={`${values.notes.length}/${NOTES_MAX}`}762 multiline763 />764 </Animated.View>765766 <Pressable role="switch" aria-checked={isDefault} aria-label="Make this my default address" onPress={() => setIsDefault((v) => !v)} style={[styles.defaultRow, { backgroundColor: pal.bg }]}>767 <Text style={[styles.defaultTitle, { color: pal.fg }]}>Make this my default address</Text>768 <Toggle on={isDefault} pal={pal} />769 </Pressable>770771 <PressableScale label="Save address" onPress={submit} to={0.97}>772 <View style={[styles.cta, styles.ctaIdle]}>773 <Text style={styles.ctaLabel}>Save address</Text>774 </View>775 </PressableScale>776 </ScrollView>777 </Animated.View>778 </KeyboardAvoidingView>779 );780}781782// ─── Screen ─────────────────────────────────────────────────────────────────783784type Status = 'idle' | 'loading' | 'done';785type Removed = { address: Address; index: number; wasSelected: boolean };786787export default function AddressBookScreen() {788 const c = usePalette();789 const insets = useSafeAreaInsets();790 const { width, height } = useWindowDimensions();791 const [addresses, setAddresses] = useState<Address[]>(ADDRESSES);792 const [selectedId, setSelectedId] = useState<string | null>(DEFAULT_ID);793 const [defaultId, setDefaultId] = useState<string | null>(DEFAULT_ID);794 const [editing, setEditing] = useState(false);795 const [locating, setLocating] = useState(false);796 const [adding, setAdding] = useState(false);797 const [removed, setRemoved] = useState<Removed | null>(null);798 const [status, setStatus] = useState<Status>('idle');799 const [intro, setIntro] = useState(true);800 const [barH, setBarH] = useState(0);801 const [drops, setDrops] = useState(0);802 const list = useRef<ComponentRef<typeof ScrollView>>(null);803 const timers = useRef<ReturnType<typeof setTimeout>[]>([]);804 const snackTimer = useRef<ReturnType<typeof setTimeout> | null>(null);805 const added = useRef(0);806807 useEffect(() => {808 const id = setTimeout(() => setIntro(false), 1200);809 const pending = timers.current;810 return () => {811 clearTimeout(id);812 pending.forEach(clearTimeout);813 if (snackTimer.current) clearTimeout(snackTimer.current);814 };815 }, []);816817 const later = (fn: () => void, ms: number) => timers.current.push(setTimeout(fn, ms));818 const column = Math.min(width, COLUMN);819 const mapH = insets.top + MAP_BODY;820 const selected = addresses.find((a) => a.id === selectedId) ?? null;821822 const select = (id: string) => {823 if (id === selectedId) setDrops((n) => n + 1); // tapping the chosen row again still drops the pin824 setSelectedId(id);825 setStatus('idle');826 };827828 // There is no GPS here: after two seconds the search "finds" the sample address.829 const locate = () => {830 if (locating) return;831 setLocating(true);832 later(() => {833 setLocating(false);834 setAddresses((rows) => (rows.some((a) => a.id === HERE.id) ? rows : [HERE, ...rows]));835 setSelectedId(HERE.id);836 setStatus('idle');837 list.current?.scrollTo({ y: 0, animated: true });838 }, 2000);839 };840841 const save = (draft: Draft) => {842 setAdding(false);843 const n = added.current++;844 const id = `new-${n}`;845 const street = draft.street.trim();846 const apartment = draft.apartment.trim();847 const address: Address = {848 id,849 kind: draft.kind,850 label: KINDS[draft.kind].title,851 line1: apartment ? `${street}, ${apartment}` : street,852 line2: `${draft.city.trim()}, ${draft.postcode}`,853 notes: draft.notes.trim() || undefined,854 eta: '20 to 30 min',855 ...SPOTS[n % SPOTS.length],856 };857 // The row arrives once the sheet has left, so its entrance is seen.858 later(() => {859 setAddresses((rows) => [...rows, address]);860 setSelectedId(id);861 setStatus('idle');862 if (draft.isDefault) setDefaultId(id);863 }, 300);864 later(() => list.current?.scrollToEnd({ animated: true }), 420);865 };866867 const remove = (id: string) => {868 const index = addresses.findIndex((a) => a.id === id);869 if (index < 0) return;870 const rest = addresses.filter((a) => a.id !== id);871 setAddresses(rest);872 setRemoved({ address: addresses[index], index, wasSelected: id === selectedId });873 if (id === selectedId) setSelectedId(rest[0]?.id ?? null);874 if (rest.length === 0) setEditing(false);875 if (snackTimer.current) clearTimeout(snackTimer.current);876 snackTimer.current = setTimeout(() => setRemoved(null), 4500);877 };878879 const undo = () => {880 if (!removed) return;881 if (snackTimer.current) clearTimeout(snackTimer.current);882 setAddresses((rows) => [...rows.slice(0, removed.index), removed.address, ...rows.slice(removed.index)]);883 if (removed.wasSelected) setSelectedId(removed.address.id);884 setRemoved(null);885 };886887 const confirm = () => {888 if (!selected || status !== 'idle') return;889 setStatus('loading');890 // Replace with saving the choice and moving on to checkout.891 later(() => setStatus('done'), 1100);892 later(() => setStatus('idle'), 3200);893 };894895 const rowEntering = (i: number) => (intro ? FadeInDown.delay(140 + i * 60).duration(420) : FadeInDown.springify().damping(13).stiffness(170));896 const count = addresses.length;897898 return (899 <View style={[styles.screen, { backgroundColor: c.bg }]}>900 <View style={styles.column}>901 <MapView902 width={column}903 height={mapH}904 anchorY={insets.top + 132}905 focus={locating ? HERE : (selected ?? HERE)}906 pinKey={`${selectedId}:${drops}`}907 pinned={!!selected && !locating}908 locating={locating}909 Icon={KINDS[selected?.kind ?? 'other'].Icon}910 others={addresses.filter((a) => a.id !== selectedId)}911 onPick={select}912 eta={selected?.eta ?? null}913 pal={c}914 />915916 <View style={[styles.header, { top: insets.top + 6 }]}>917 <PressableScale label="Back" to={0.9}>918 <View style={[styles.round, { backgroundColor: c.surface }, c.dark ? styles.floatDark : styles.floatLight]}>919 <ChevronLeft size={22} color={c.fg} strokeWidth={2.2} />920 </View>921 </PressableScale>922 <PressableScale label={editing ? 'Done editing' : 'Edit addresses'} onPress={() => setEditing((v) => !v)} to={0.93} disabled={count === 0}>923 <View style={[styles.editPill, editing ? styles.editPillOn : { backgroundColor: c.surface }, c.dark ? styles.floatDark : styles.floatLight]}>924 <Text style={[styles.editLabel, { color: editing ? ON_ACCENT : c.fg, opacity: count === 0 ? 0.4 : 1 }]}>{editing ? 'Done' : 'Edit'}</Text>925 </View>926 </PressableScale>927 </View>928929 {/* The list rides over the map's lower edge on an opaque sheet. */}930 <View style={[styles.body, { backgroundColor: c.bg }]}>931 <ScrollView ref={list} showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled" contentContainerStyle={styles.content}>932 <Animated.View entering={FadeInDown.duration(420)} style={styles.titleRow}>933 <Text style={[styles.title, { color: c.fg }]}>Delivery addresses</Text>934 <Text style={[styles.count, { color: c.muted }]}>{count} saved</Text>935 </Animated.View>936937 <Animated.View entering={FadeInDown.delay(70).duration(420)}>938 <LocateRow locating={locating} onPress={locate} pal={c} />939 </Animated.View>940941 <View role="radiogroup" aria-label="Saved addresses" style={styles.rows}>942 {addresses.map((a, i) => (943 <Animated.View key={a.id} layout={MOVE} entering={rowEntering(i)} exiting={FadeOut.duration(150)}>944 <AddressRow address={a} selected={a.id === selectedId} isDefault={a.id === defaultId} editing={editing} onSelect={() => select(a.id)} onRemove={() => remove(a.id)} pal={c} />945 </Animated.View>946 ))}947 {count === 0 && (948 <Animated.View key="empty" entering={FadeIn.delay(160).duration(280)} exiting={FadeOut.duration(100)} style={styles.empty}>949 <Text style={[styles.emptyTitle, { color: c.fg }]}>No saved addresses</Text>950 <Text style={[styles.emptyText, { color: c.muted }]}>Add one below, or use your current location.</Text>951 </Animated.View>952 )}953 <Animated.View key="add" layout={MOVE} entering={FadeInDown.delay(400).duration(420)}>954 <PressableScale label="Add new address" onPress={() => setAdding(true)} to={0.98}>955 <View style={[styles.add, { borderColor: c.faint }]}>956 <Plus size={18} color={c.fg} strokeWidth={2.4} />957 <Text style={[styles.addLabel, { color: c.fg }]}>Add new address</Text>958 </View>959 </PressableScale>960 </Animated.View>961 </View>962 </ScrollView>963 </View>964965 {/* Opaque bar, so the list never shows through it */}966 <View onLayout={(e: LayoutChangeEvent) => setBarH(e.nativeEvent.layout.height)} style={[styles.bar, { backgroundColor: c.bg, borderTopColor: c.border, paddingBottom: insets.bottom + 8 }]}>967 <View style={styles.summary}>968 <MapPin size={15} color={c.muted} strokeWidth={2.2} />969 <Text numberOfLines={1} style={[styles.summaryText, { color: c.muted }]}>970 {selected ? (971 <>972 <Text style={[styles.summaryStrong, { color: c.fg }]}>{selected.label}</Text>973 {` ${selected.line1}`}974 </>975 ) : (976 'No address chosen yet'977 )}978 </Text>979 </View>980 <Pressable role="button" aria-label="Deliver here" aria-busy={status === 'loading'} disabled={!selected || status !== 'idle'} onPress={confirm} style={({ pressed }) => [styles.ctaSlot, { opacity: !selected ? 0.4 : pressed ? 0.88 : 1 }]}>981 <View style={[styles.cta, status === 'done' ? styles.ctaDone : styles.ctaIdle]}>982 {status === 'idle' && (983 <Animated.Text entering={FadeIn.duration(160)} style={styles.ctaLabel}>984 Deliver here985 </Animated.Text>986 )}987 {status === 'loading' && <Spinner />}988 {status === 'done' && (989 <Animated.View entering={ZoomIn.springify().damping(12)} style={styles.ctaRow}>990 <Check size={21} color={ON_ACCENT} strokeWidth={3.2} />991 <Text style={[styles.ctaLabel, styles.ctaLabelDone]}>Delivering to {selected?.label ?? 'you'}</Text>992 </Animated.View>993 )}994 </View>995 </Pressable>996 </View>997998 {removed && (999 <Animated.View key={removed.address.id} entering={FadeInDown.duration(240)} exiting={FadeOutDown.duration(180)} role="alert" style={[styles.snack, { bottom: barH + 12, backgroundColor: c.snack }]}>1000 <Text numberOfLines={1} style={[styles.snackText, { color: c.snackText }]}>1001 {removed.address.label} removed1002 </Text>1003 <Pressable role="button" aria-label="Undo delete" onPress={undo} hitSlop={10} style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}>1004 <Text style={[styles.snackAction, { color: c.snackAction }]}>Undo</Text>1005 </Pressable>1006 </Animated.View>1007 )}10081009 <AddSheet open={adding} onClose={() => setAdding(false)} onSave={save} pal={c} bottom={insets.bottom} maxHeight={height - insets.top - 16} />1010 </View>1011 </View>1012 );1013}10141015// ─── Styles ─────────────────────────────────────────────────────────────────10161017const styles = StyleSheet.create({1018 screen: { flex: 1 },1019 // Phone layout on every width: one centred column that the map, bar and sheet all share.1020 column: { flex: 1, width: '100%', maxWidth: COLUMN, alignSelf: 'center', overflow: 'hidden' },1021 fill: { flex: 1 },10221023 // Map1024 map: { overflow: 'hidden' },1025 world: { position: 'absolute', left: 0, top: 0, width: WORLD_W, height: WORLD_H },1026 markerSlot: { position: 'absolute', width: 40, height: 40 },1027 markerHit: { flex: 1, alignItems: 'center', justifyContent: 'center' },1028 marker: { width: 26, height: 26, borderRadius: 13, borderWidth: 1, alignItems: 'center', justifyContent: 'center' },1029 anchor: { position: 'absolute', width: 0, height: 0 },1030 halo: { position: 'absolute', left: -26, top: -26, width: 52, height: 52, borderRadius: 26 },1031 ripple: { position: 'absolute', left: -30, top: -30, width: 60, height: 60, borderRadius: 30, borderWidth: 2, borderColor: ACCENT },1032 pinShadow: { position: 'absolute', left: -8, top: -3, width: 16, height: 6, borderRadius: 3, backgroundColor: '#000000' },1033 pin: { position: 'absolute', left: -PIN_W / 2, top: -PIN_H + 2, width: PIN_W, height: PIN_H },1034 pinIcon: { position: 'absolute', left: 0, right: 0, top: 3, height: 38, alignItems: 'center', justifyContent: 'center' },1035 pulse: { position: 'absolute', left: -44, top: -44, width: 88, height: 88, borderRadius: 44, backgroundColor: LOCATION },1036 hereDot: {1037 position: 'absolute',1038 left: -10,1039 top: -10,1040 width: 20,1041 height: 20,1042 borderRadius: 10,1043 borderWidth: 3,1044 borderColor: '#FFFFFF',1045 backgroundColor: LOCATION,1046 shadowColor: '#000',1047 shadowOpacity: 0.25,1048 shadowRadius: 5,1049 shadowOffset: { width: 0, height: 2 },1050 },1051 etaSlot: { position: 'absolute', left: 16, right: 16, bottom: SHEET_LAP + 12, alignItems: 'flex-start' },1052 eta: { height: 34, borderRadius: 17, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 7, maxWidth: '100%' },1053 etaText: { fontSize: 13, fontWeight: '600', letterSpacing: -0.1, flexShrink: 1 },1054 // Things that float on the map share one shadow per theme.1055 floatLight: { shadowColor: '#000', shadowOpacity: 0.12, shadowRadius: 10, shadowOffset: { width: 0, height: 4 } },1056 floatDark: { shadowColor: '#000', shadowOpacity: 0.5, shadowRadius: 10, shadowOffset: { width: 0, height: 4 } },10571058 // Header1059 header: { position: 'absolute', left: 16, right: 16, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },1060 round: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },1061 editPill: { height: 40, minWidth: 64, paddingHorizontal: 16, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },1062 editPillOn: { backgroundColor: ACCENT },1063 editLabel: { fontSize: 15, fontWeight: '600', letterSpacing: -0.1 },10641065 // List1066 body: { flex: 1, marginTop: -SHEET_LAP, borderTopLeftRadius: 28, borderTopRightRadius: 28, overflow: 'hidden' },1067 content: { paddingHorizontal: 16, paddingTop: 22, paddingBottom: 20 },1068 titleRow: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', paddingHorizontal: 4, marginBottom: 14 },1069 title: { fontSize: 24, fontWeight: '700', letterSpacing: -0.6 },1070 count: { fontSize: 14, fontWeight: '500' },1071 rows: { marginTop: 10, gap: 10 },10721073 locate: { minHeight: 64, borderRadius: 20, borderWidth: 1, paddingHorizontal: 14, flexDirection: 'row', alignItems: 'center', gap: 12 },1074 locateIconSlot: { width: 44, height: 44 },1075 locateIcon: { width: 44, height: 44, borderRadius: 22, alignItems: 'center', justifyContent: 'center' },1076 locateRing: { position: 'absolute', left: 0, top: 0, width: 44, height: 44, borderRadius: 22, borderWidth: 2, borderColor: ACCENT },1077 locateTitle: { fontSize: 16, fontWeight: '600', letterSpacing: -0.2 },1078 miniSpinner: { width: 18, height: 18, borderRadius: 9, borderWidth: 2.5 },10791080 card: { borderRadius: 20, borderWidth: 1.5, flexDirection: 'row', alignItems: 'center' },1081 cardWash: { borderRadius: 18 },1082 cardMain: { flex: 1, minWidth: 0, flexDirection: 'row', alignItems: 'center', gap: 12, paddingVertical: 14, paddingLeft: 14 },1083 cardIcon: { width: 44, height: 44, borderRadius: 14, alignItems: 'center', justifyContent: 'center', alignSelf: 'flex-start' },1084 cardIconOn: { backgroundColor: ACCENT },1085 cardText: { flex: 1, minWidth: 0 },1086 cardTitleRow: { flexDirection: 'row', alignItems: 'center', gap: 8 },1087 cardTitle: { fontSize: 16, fontWeight: '600', letterSpacing: -0.2, flexShrink: 1 },1088 badge: { height: 20, paddingHorizontal: 8, borderRadius: 10, justifyContent: 'center' },1089 badgeText: { fontSize: 11, fontWeight: '700', letterSpacing: 0.2 },1090 cardLine: { marginTop: 2, fontSize: 14, lineHeight: 19 },1091 noteRow: { marginTop: 6, flexDirection: 'row', alignItems: 'center', gap: 5 },1092 noteText: { flex: 1, fontSize: 12.5 },1093 cardEnd: { width: 52, alignItems: 'center', justifyContent: 'center' },1094 radio: { width: 26, height: 26, borderRadius: 13, borderWidth: 2, alignItems: 'center', justifyContent: 'center' },1095 radioFill: { width: 26, height: 26, borderRadius: 13, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },1096 remove: { width: 38, height: 38, borderRadius: 19, alignItems: 'center', justifyContent: 'center' },10971098 empty: { paddingVertical: 22, alignItems: 'center' },1099 emptyTitle: { fontSize: 16, fontWeight: '600' },1100 emptyText: { marginTop: 4, fontSize: 14 },1101 add: { height: 56, borderRadius: 20, borderWidth: 1.5, borderStyle: 'dashed', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8 },1102 addLabel: { fontSize: 15.5, fontWeight: '600', letterSpacing: -0.1 },11031104 // Bottom bar1105 bar: { paddingHorizontal: 16, paddingTop: 10, borderTopWidth: StyleSheet.hairlineWidth },1106 summary: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingHorizontal: 4, marginBottom: 10 },1107 summaryText: { flex: 1, fontSize: 13.5 },1108 summaryStrong: { fontWeight: '600' },1109 ctaSlot: { alignItems: 'stretch' },1110 cta: { height: BUTTON_H, borderRadius: BUTTON_H / 2, alignItems: 'center', justifyContent: 'center', borderTopWidth: 1, borderTopColor: 'rgba(255,255,255,0.35)' },1111 // A shadow's props stay together in one style object: React Native Web builds the shadow per object.1112 ctaIdle: { backgroundColor: ACCENT, shadowColor: ACCENT, shadowOpacity: 0.34, shadowRadius: 16, shadowOffset: { width: 0, height: 8 } },1113 ctaDone: { backgroundColor: ACCENT_DEEP, shadowColor: ACCENT, shadowOpacity: 0.32, shadowRadius: 16, shadowOffset: { width: 0, height: 8 } },1114 ctaRow: { flexDirection: 'row', alignItems: 'center', gap: 8, paddingHorizontal: 16 },1115 ctaLabel: { color: ON_ACCENT, fontSize: 17, fontWeight: '700', letterSpacing: -0.2 },1116 ctaLabelDone: { flexShrink: 1 },1117 spinner: { width: 22, height: 22, borderRadius: 11, borderWidth: 2.5, borderColor: tint(ON_ACCENT, 0.2), borderTopColor: ON_ACCENT },11181119 // Undo snackbar1120 snack: {1121 position: 'absolute',1122 left: 16,1123 right: 16,1124 height: 52,1125 borderRadius: 16,1126 paddingHorizontal: 16,1127 flexDirection: 'row',1128 alignItems: 'center',1129 gap: 12,1130 shadowColor: '#000',1131 shadowOpacity: 0.24,1132 shadowRadius: 14,1133 shadowOffset: { width: 0, height: 6 },1134 },1135 snackText: { flex: 1, fontSize: 15, fontWeight: '500' },1136 snackAction: { fontSize: 15, fontWeight: '700' },11371138 // New address sheet1139 sheetHost: { justifyContent: 'flex-end' },1140 sheet: { borderTopLeftRadius: 28, borderTopRightRadius: 28, paddingTop: 10 },1141 grabber: { alignSelf: 'center', width: 40, height: 5, borderRadius: 3 },1142 sheetHead: { marginTop: 14, paddingHorizontal: 20, flexDirection: 'row', alignItems: 'flex-start', gap: 12 },1143 sheetTitles: { flex: 1 },1144 sheetTitle: { fontSize: 22, fontWeight: '700', letterSpacing: -0.5 },1145 sheetSub: { marginTop: 4, fontSize: 14.5, lineHeight: 20 },1146 sheetBody: { paddingHorizontal: 20, paddingTop: 16 },1147 chipScroll: { marginHorizontal: -20, flexGrow: 0 },1148 chips: { paddingHorizontal: 20, gap: 8 },1149 chip: { height: 38, paddingHorizontal: 14, borderRadius: 19, borderWidth: 1, flexDirection: 'row', alignItems: 'center', gap: 6 },1150 chipOn: { backgroundColor: ACCENT, borderColor: ACCENT },1151 chipText: { fontSize: 14.5, fontWeight: '600', letterSpacing: -0.1 },11521153 form: { marginTop: 16, gap: 12 },1154 formRow: { flexDirection: 'row', gap: 10, alignItems: 'flex-start' },1155 postcode: { width: 128 },1156 fieldSlot: { minWidth: 0 },1157 formCell: { flex: 1, minWidth: 0 },1158 field: {1159 height: 60,1160 borderRadius: 16,1161 borderWidth: 1.5,1162 paddingHorizontal: 14,1163 shadowColor: ACCENT,1164 shadowRadius: 10,1165 shadowOffset: { width: 0, height: 0 },1166 },1167 fieldTall: { height: 92 },1168 fieldLabel: { position: 'absolute', left: 14, top: 19, fontSize: 16, lineHeight: 20, transformOrigin: 'left center' },1169 fieldInput: { height: '100%', paddingTop: 22, paddingBottom: 4, width: '100%', fontSize: 16, minWidth: 0 },1170 fieldInputTall: { height: 62, marginTop: 26, paddingTop: 0, paddingBottom: 10, lineHeight: 21, textAlignVertical: 'top' },1171 fieldHint: { position: 'absolute', right: 12, bottom: 8, fontSize: 11.5, fontVariant: ['tabular-nums'] },1172 fieldError: { fontSize: 12.5, marginTop: 6, marginLeft: 4 },11731174 defaultRow: { marginTop: 12, marginBottom: 16, height: 56, borderRadius: 16, paddingHorizontal: 14, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 },1175 defaultTitle: { flex: 1, fontSize: 15, fontWeight: '600', letterSpacing: -0.1 },1176 toggle: { width: 50, height: 30, borderRadius: 15, padding: 3 },1177 toggleThumb: {1178 width: 24,1179 height: 24,1180 borderRadius: 12,1181 backgroundColor: '#FFFFFF',1182 shadowColor: '#000',1183 shadowOpacity: 0.2,1184 shadowRadius: 3,1185 shadowOffset: { width: 0, height: 1 },1186 },1187});