Food delivery home

The home tab of a delivery app: an address picker sheet, a delivery or pickup switch with a sliding thumb, a header that collapses until only the search field sticks, round cuisine chips that filter the restaurant list as cards glide into place, a paged offer carousel whose plate drifts as you swipe, toggling filter pills, hearts that spring, and a cart bar that slides up with a rolling total when you add a dish.

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

Details

File
components/patterns/food-delivery-home.tsx
Lines
1000
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/food-delivery-home.tsx
1import { useEffect, useMemo, useRef, useState, type ComponentRef, type ReactNode } from 'react';
2import { Image, Platform, Pressable, ScrollView, StyleSheet, Text, TextInput, View, useColorScheme, useWindowDimensions, type StyleProp, type ViewStyle } from 'react-native';
3import Animated, {
4 cancelAnimation,
5 Easing,
6 FadeIn,
7 FadeInDown,
8 FadeOut,
9 LinearTransition,
10 ZoomIn,
11 ZoomOut,
12 interpolate,
13 useAnimatedScrollHandler,
14 useAnimatedStyle,
15 useSharedValue,
16 withRepeat,
17 withSequence,
18 withSpring,
19 withTiming,
20 type SharedValue,
21} from 'react-native-reanimated';
22import { LinearGradient } from 'expo-linear-gradient';
23import { useSafeAreaInsets } from 'react-native-safe-area-context';
24import Svg, { Circle } from 'react-native-svg';
25import { Bike, Briefcase, Check, ChevronDown, ChevronRight, Heart, House, MapPin, Plus, ReceiptText, Search, SearchX, ShoppingBag, Star, Store, Tag, UserRound, X, type LucideIcon } from 'lucide-react-native';
26
27// ─── Brand ──────────────────────────────────────────────────────────────────
28// The screen's accent and name. Every accent colour below derives from these, so changing them rebrands the screen.
29
30const ACCENT = '#FF5A36';
31const ACCENT_DARK = '#FF8264'; // accent text and soft fills on dark backgrounds
32const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill
33const APP_NAME = 'Forkful';
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}
49function spin(hex: string, deg: number, light = 0, sat = 0) {
50 const n = parseInt(hex.slice(1), 16);
51 const r = ((n >> 16) & 255) / 255;
52 const g = ((n >> 8) & 255) / 255;
53 const b = (n & 255) / 255;
54 const max = Math.max(r, g, b);
55 const min = Math.min(r, g, b);
56 const d = max - min;
57 const s = Math.min(1, Math.max(0, (d === 0 ? 0 : d / (1 - Math.abs(max + min - 1))) + sat));
58 const l = Math.min(1, Math.max(0, (max + min) / 2 + light));
59 const h0 = d === 0 ? 0 : max === r ? ((g - b) / d + 6) % 6 : max === g ? (b - r) / d + 2 : (r - g) / d + 4;
60 const h = (((h0 * 60 + deg) % 360) + 360) % 360;
61 const a = s * Math.min(l, 1 - l);
62 const f = (m: number) => {
63 const k = (m + h / 30) % 12;
64 return Math.round(255 * (l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1)))).toString(16).padStart(2, '0');
65 };
66 return `#${f(0)}${f(8)}${f(4)}`.toUpperCase();
67}
68
69// ─── Sample data ────────────────────────────────────────────────────────────
70
71/** `ratio` is the source photo's width over height; `focus` is where the food sits along its long side (0 to 1). */
72type Shot = { id: string; ratio: number; focus: number; tint: string };
73const shot = (id: string, ratio: number, tint: string, focus = 0.5): Shot => ({ id, ratio, focus, tint });
74const photo = (id: string, w: number) => `https://images.unsplash.com/photo-${id}?w=${w}&q=80&fit=crop`;
75
76type Cuisine = 'Pizza' | 'Sushi' | 'Burgers' | 'Healthy' | 'Desserts' | 'Coffee' | 'Ramen' | 'Indian';
77
78const CUISINES: { name: Cuisine; shot: Shot }[] = [
79 { name: 'Pizza', shot: shot('1513104890138-7c749659a591', 1.5, '#D9A066', 0.75) },
80 { name: 'Sushi', shot: shot('1579871494447-9811cf80d66c', 1.5, '#C97B5A', 0.2) },
81 { name: 'Burgers', shot: shot('1571091718767-18b5b1457add', 1.5, '#8A5A3C') },
82 { name: 'Healthy', shot: shot('1546069901-ba9599a7e63c', 1, '#E9E6E1') },
83 { name: 'Desserts', shot: shot('1551024601-bec78aea704b', 0.8, '#C98B5E', 0.45) },
84 { name: 'Coffee', shot: shot('1495474472287-4d71bcdd2085', 1.5, '#5B4636', 0.6) },
85 { name: 'Ramen', shot: shot('1569718212165-3a8278d5f624', 1, '#B9C4B0') },
86 { name: 'Indian', shot: shot('1585937421612-70a008356fbe', 0.75, '#B5602E', 0.7) },
87];
88
89type Restaurant = {
90 id: string;
91 name: string;
92 cuisines: Cuisine[];
93 blurb: string;
94 rating: number;
95 reviews: string;
96 /** Minutes to the door, minutes until a pickup order is ready, delivery fee in dollars, distance in miles. */
97 time: number;
98 ready: number;
99 fee: number;
100 miles: number;
101 offer?: string;
102 shot: Shot;
103};
104
105const RESTAURANTS: Restaurant[] = [
106 { id: 'saffron', name: 'Saffron Room', cuisines: ['Indian'], blurb: 'Indian · Curry · Tandoor · $$', rating: 4.8, reviews: '2.1k', time: 25, ready: 15, fee: 0.99, miles: 1.2, offer: '20% off', shot: shot('1565557623262-b51c2513a641', 1.84, '#B88C6E') },
107 { id: 'nonna', name: 'Nonna’s Kitchen', cuisines: ['Pizza'], blurb: 'Italian · Wood-fired pizza · $$', rating: 4.7, reviews: '3.4k', time: 20, ready: 10, fee: 0, miles: 0.6, offer: 'Buy 1 get 1', shot: shot('1574071318508-1cdbab80d002', 1.5, '#A8703F') },
108 { id: 'kyoto', name: 'Kyoto Ramen Bar', cuisines: ['Ramen'], blurb: 'Japanese · Ramen · Gyoza · $$', rating: 4.9, reviews: '1.8k', time: 35, ready: 20, fee: 1.49, miles: 2.1, shot: shot('1569718212165-3a8278d5f624', 1, '#B9C4B0') },
109 { id: 'green', name: 'Green Fork', cuisines: ['Healthy', 'Coffee'], blurb: 'Bowls · Salads · Juices · $', rating: 4.6, reviews: '960', time: 15, ready: 8, fee: 0, miles: 0.4, offer: '15% off bowls', shot: shot('1512621776951-a57141f2eefd', 1.5, '#8E8F86') },
110 { id: 'smash', name: 'Smash Yard', cuisines: ['Burgers'], blurb: 'Burgers · Fries · Shakes · $', rating: 4.4, reviews: '5.2k', time: 20, ready: 12, fee: 0.49, miles: 0.9, offer: 'Buy 1 get 1', shot: shot('1568901346375-23c9450c58cd', 1.2, '#4A4038', 0.6) },
111 { id: 'maki', name: 'Maki & Tide', cuisines: ['Sushi', 'Healthy'], blurb: 'Sushi · Poke · Sashimi · $$$', rating: 4.7, reviews: '740', time: 40, ready: 25, fee: 2.49, miles: 2.8, shot: shot('1553621042-f6e147245754', 1.25, '#7A5A44') },
112 { id: 'sugar', name: 'Sugar Loft', cuisines: ['Desserts'], blurb: 'Cakes · Pastry · Gelato · $$', rating: 4.5, reviews: '1.1k', time: 25, ready: 10, fee: 0.99, miles: 1.5, offer: '20% off', shot: shot('1565958011703-44f9829ba187', 0.8, '#5A5650', 0.55) },
113 { id: 'slow', name: 'Slow Pour', cuisines: ['Coffee', 'Desserts'], blurb: 'Coffee · Bakery · Brunch · $', rating: 4.3, reviews: '2.6k', time: 10, ready: 5, fee: 0, miles: 0.3, shot: shot('1509042239860-f550ce710b93', 0.667, '#6B5A48', 0.66) },
114];
115
116const DISHES = [
117 { id: 'tagliatelle', name: 'Truffle tagliatelle', from: 'Nonna’s Kitchen', price: 16.5, shot: shot('1551183053-bf91a1d81141', 1.6, '#B98A4E') },
118 { id: 'toast', name: 'Berry French toast', from: 'Slow Pour', price: 11, shot: shot('1484723091739-30a097e8f929', 0.77, '#3A3531', 0.3) },
119 { id: 'plate', name: 'Garden grain plate', from: 'Green Fork', price: 13.5, shot: shot('1490645935967-10de6ba17061', 1.47, '#8C7A62') },
120 { id: 'linguine', name: 'Chili prawn linguine', from: 'Nonna’s Kitchen', price: 18, shot: shot('1563379926898-05f4575a45d8', 1.5, '#3B3A3A') },
121];
122
123// The welcome offer is the app's own, so it wears the accent; the Pass and After-dark cards keep their own palettes.
124const PROMOS = [
125 { id: 'welcome', eyebrow: 'Welcome offer', title: '40% off your\nfirst 3 orders', cta: 'Use FORK40', colors: [spin(ACCENT, 2, 0.025), spin(ACCENT, -2, -0.112, -0.206)] as const, ink: ON_ACCENT, pill: '#FFFFFF', pillInk: spin(ACCENT, -2, -0.208, -0.177), shot: shot('1574071318508-1cdbab80d002', 1.5, '#A8703F') },
126 { id: 'pass', eyebrow: `${APP_NAME} Pass`, title: 'Free delivery\nover $15', cta: 'Try 30 days', colors: ['#1F7A5C', '#0E4433'] as const, ink: '#FFFFFF', pill: '#FFFFFF', pillInk: '#0E4433', shot: shot('1546069901-ba9599a7e63c', 1, '#E9E6E1') },
127 { id: 'late', eyebrow: 'After dark', title: 'Desserts till\n2 am, 20% off', cta: 'Get the deal', colors: ['#FFCB52', '#FF9F1C'] as const, ink: '#2A1803', pill: '#2A1803', pillInk: '#FFD877', shot: shot('1551024601-bec78aea704b', 0.8, '#C98B5E', 0.45) },
128];
129
130const ADDRESSES: { id: string; label: string; street: string; detail: string; icon: LucideIcon }[] = [
131 { id: 'home', label: 'Home', street: '221 Park Ave', detail: 'Apt 4B · Leave at the door', icon: House },
132 { id: 'work', label: 'Work', street: '48 Mercer St', detail: 'Floor 9 · Meet in the lobby', icon: Briefcase },
133 { id: 'mum', label: 'Mum’s place', street: '17 Linden Row', detail: 'Ring the top bell', icon: Heart },
134];
135
136const PILLS = [
137 { key: 'fast', label: 'Under 30 min' },
138 { key: 'top', label: 'Rating 4.5+' },
139 { key: 'offers', label: 'Offers' },
140] as const;
141type PillKey = (typeof PILLS)[number]['key'];
142type Mode = 'delivery' | 'pickup';
143
144const TABS: { label: string; icon: LucideIcon }[] = [
145 { label: 'Home', icon: House },
146 { label: 'Search', icon: Search },
147 { label: 'Orders', icon: ReceiptText },
148 { label: 'Account', icon: UserRound },
149];
150
151// ─── Palette ────────────────────────────────────────────────────────────────
152
153const STAR = '#F5A623';
154const SPRING = { damping: 18, stiffness: 260, mass: 0.7 };
155const TOP_H = 104; // address row + delivery switch: the part of the header that scrolls away
156const HEADER_H = 170;
157const TAB_H = 56;
158const CART_H = 56;
159const PROMO_H = 148;
160
161function usePalette() {
162 const dark = useColorScheme() === 'dark';
163 return {
164 dark,
165 bg: dark ? '#0F0D0C' : '#FFFFFF',
166 surface: dark ? '#1B1816' : '#FFFFFF',
167 field: dark ? '#1E1B19' : '#F5F2EF',
168 fg: dark ? '#FAF6F3' : '#1C1614',
169 muted: dark ? '#A69D97' : '#786E68',
170 faint: dark ? '#5E5651' : '#B4ABA5',
171 line: dark ? '#2A2623' : '#ECE7E3',
172 thumb: dark ? '#3A3430' : '#FFFFFF',
173 accentSoft: dark ? shade(ACCENT_DARK, 0.77) : shade(ACCENT, -0.895),
174 accentInk: dark ? ACCENT_DARK : spin(ACCENT, 0.5, -0.106, -0.243),
175 good: dark ? '#4ADE80' : '#15803D',
176 heartOff: dark ? '#FAF6F3' : '#1C1614',
177 scrim: dark ? 'rgba(0,0,0,0.6)' : 'rgba(28,22,20,0.42)',
178 };
179}
180type Palette = ReturnType<typeof usePalette>;
181
182// Scale up past the target, then settle: the heart, the Add button and the cart badge.
183const pop = (peak: number) =>
184 withSequence(withTiming(peak, { duration: 140, easing: Easing.out(Easing.back(2.4)) }), withTiming(1, { duration: 190, easing: Easing.out(Easing.cubic) }));
185const money = (n: number) => `$${n.toFixed(2)}`;
186
187// ─── Small pieces ───────────────────────────────────────────────────────────
188
189function Tap({ children, label, onPress, to = 0.94, role = 'button', style }: { children: ReactNode; label: string; onPress?: () => void; to?: number; role?: 'button' | 'link'; style?: StyleProp<ViewStyle> }) {
190 const scale = useSharedValue(1);
191 const press = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
192 return (
193 <Pressable role={role} aria-label={label} onPress={onPress} hitSlop={6} onPressIn={() => (scale.value = withSpring(to, SPRING))} onPressOut={() => (scale.value = withSpring(1, SPRING))} style={style}>
194 <Animated.View style={press}>{children}</Animated.View>
195 </Pressable>
196 );
197}
198
199/** A food photo that fades in over a tinted, pulsing placeholder and keeps the dish in frame. */
200function Photo({ shot: s, alt, width, height, px, style }: { shot: Shot; alt: string; width: number; height: number; px: number; style?: StyleProp<ViewStyle> }) {
201 const shown = useSharedValue(0);
202 const pulse = useSharedValue(0.1);
203 useEffect(() => {
204 pulse.value = withRepeat(withSequence(withTiming(0.35, { duration: 700 }), withTiming(0.1, { duration: 700 })), -1);
205 return () => cancelAnimation(pulse);
206 }, [pulse]);
207 const image = useAnimatedStyle(() => ({ opacity: shown.value }));
208 const placeholder = useAnimatedStyle(() => ({ opacity: (1 - shown.value) * pulse.value }));
209 const wide = s.ratio > width / height;
210 const w = wide ? height * s.ratio : width;
211 const h = wide ? height : width / s.ratio;
212 return (
213 <View style={[styles.photo, { width, height, backgroundColor: s.tint }, style]}>
214 <Animated.View style={[StyleSheet.absoluteFill, styles.photoFlash, placeholder]} />
215 <Animated.View style={[styles.photoFrame, { left: wide ? -(w - width) * s.focus : 0, top: wide ? 0 : -(h - height) * s.focus, width: w, height: h }, image]}>
216 <Image
217 source={{ uri: photo(s.id, px) }}
218 alt={alt}
219 resizeMode="cover"
220 style={{ width: w, height: h }}
221 onLoad={() => {
222 cancelAnimation(pulse);
223 shown.value = withTiming(1, { duration: 320 });
224 }}
225 />
226 </Animated.View>
227 </View>
228 );
229}
230
231function SectionHead({ title, note, pal }: { title: string; note?: string; pal: Palette }) {
232 return (
233 <View style={styles.sectionHead}>
234 <Text style={[styles.sectionTitle, { color: pal.fg }]}>{title}</Text>
235 {note ? <Text style={[styles.sectionNote, styles.tabular, { color: pal.muted }]}>{note}</Text> : null}
236 </View>
237 );
238}
239
240// ─── Header: address, delivery switch, search ───────────────────────────────
241
242function ModeSwitch({ mode, onChange, pal }: { mode: Mode; onChange: (m: Mode) => void; pal: Palette }) {
243 const { width } = useWindowDimensions();
244 const half = (width - 32 - 6) / 2;
245 const x = useSharedValue(mode === 'delivery' ? 0 : 1);
246 useEffect(() => {
247 x.value = withSpring(mode === 'delivery' ? 0 : 1, SPRING);
248 }, [mode, x]);
249 const thumb = useAnimatedStyle(() => ({ transform: [{ translateX: x.value * half }] }));
250 const options = [
251 { key: 'delivery' as const, label: 'Delivery', icon: Bike },
252 { key: 'pickup' as const, label: 'Pickup', icon: Store },
253 ];
254 return (
255 <View role="tablist" aria-label="Order type" style={[styles.switch, { backgroundColor: pal.field }]}>
256 <Animated.View style={[styles.switchThumb, { width: half, backgroundColor: pal.thumb }, pal.dark ? styles.thumbDark : styles.thumbLight, thumb]} />
257 {options.map(({ key, label, icon: Icon }) => {
258 const on = mode === key;
259 return (
260 <Pressable key={key} role="tab" aria-selected={on} aria-label={label} onPress={() => onChange(key)} style={styles.switchOption}>
261 <Icon size={16} color={on ? pal.fg : pal.muted} strokeWidth={2.2} />
262 <Text style={[styles.switchLabel, { color: on ? pal.fg : pal.muted }]}>{label}</Text>
263 </Pressable>
264 );
265 })}
266 </View>
267 );
268}
269
270/** The cart count. It pops whenever the number changes, and the new digit rolls in. */
271function CountBadge({ count, ring }: { count: number; ring: string }) {
272 const scale = useSharedValue(1);
273 useEffect(() => {
274 scale.value = pop(1.4);
275 }, [count, scale]);
276 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
277 return (
278 <Animated.View pointerEvents="none" entering={ZoomIn.duration(180)} exiting={ZoomOut.duration(140)} style={[styles.badge, { borderColor: ring }, style]}>
279 <Animated.Text key={count} entering={FadeInDown.duration(180)} style={[styles.badgeText, styles.tabular]}>
280 {count}
281 </Animated.Text>
282 </Animated.View>
283 );
284}
285
286function SearchField({ value, onChange, inputRef, pal }: { value: string; onChange: (v: string) => void; inputRef: React.RefObject<ComponentRef<typeof TextInput> | null>; pal: Palette }) {
287 const [focused, setFocused] = useState(false);
288 return (
289 <View style={[styles.search, { backgroundColor: pal.field, borderColor: focused ? ACCENT : pal.field }]}>
290 <Search size={18} color={focused ? pal.fg : pal.muted} strokeWidth={2.3} />
291 <TextInput
292 ref={inputRef}
293 value={value}
294 onChangeText={onChange}
295 onFocus={() => setFocused(true)}
296 onBlur={() => setFocused(false)}
297 placeholder="Search dishes, restaurants"
298 placeholderTextColor={pal.muted}
299 selectionColor={ACCENT}
300 aria-label="Search dishes and restaurants"
301 autoCapitalize="none"
302 autoCorrect={false}
303 returnKeyType="search"
304 style={[styles.searchInput, { color: pal.fg }, Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null]}
305 />
306 {value.length > 0 && (
307 <Animated.View entering={ZoomIn.duration(160)} exiting={ZoomOut.duration(120)}>
308 <Pressable
309 role="button"
310 aria-label="Clear search"
311 hitSlop={8}
312 onPress={() => {
313 onChange('');
314 inputRef.current?.focus();
315 }}
316 style={[styles.searchClear, { backgroundColor: pal.faint }]}
317 >
318 <X size={14} color={pal.field} strokeWidth={3} />
319 </Pressable>
320 </Animated.View>
321 )}
322 </View>
323 );
324}
325
326// ─── Cuisine chips ──────────────────────────────────────────────────────────
327
328function CuisineChip({ name, shot: s, selected, dimmed, onPress, pal }: { name: Cuisine; shot: Shot; selected: boolean; dimmed: boolean; onPress: () => void; pal: Palette }) {
329 const on = useSharedValue(selected ? 1 : 0);
330 useEffect(() => {
331 on.value = withSpring(selected ? 1 : 0, SPRING);
332 }, [selected, on]);
333 const ring = useAnimatedStyle(() => ({ opacity: on.value, transform: [{ scale: 0.86 + on.value * 0.14 }] }));
334 const plate = useAnimatedStyle(() => ({ transform: [{ scale: 1 - on.value * 0.1 }] }));
335 return (
336 <Tap label={name} onPress={onPress} to={0.92}>
337 <View role="tab" aria-selected={selected} style={[styles.cuisine, { opacity: dimmed ? 0.55 : 1 }]}>
338 <View style={styles.cuisineSlot}>
339 <Animated.View style={[styles.cuisineRing, ring]} />
340 <Animated.View style={plate}>
341 <Photo shot={s} alt="" width={58} height={58} px={160} style={styles.cuisinePhoto} />
342 </Animated.View>
343 </View>
344 <Text style={[styles.cuisineLabel, { color: selected ? pal.accentInk : pal.fg, fontWeight: selected ? '700' : '500' }]}>{name}</Text>
345 </View>
346 </Tap>
347 );
348}
349
350// ─── Promo carousel: paged, the plate drifts and turns as you swipe ─────────
351
352function Banner({ promo, index, x, width, claimed, onClaim }: { promo: (typeof PROMOS)[number]; index: number; x: SharedValue<number>; width: number; claimed: boolean; onClaim: () => void }) {
353 const drift = useAnimatedStyle(() => {
354 const t = Math.max(-1, Math.min(1, x.value / width - index));
355 return { transform: [{ translateX: interpolate(t, [-1, 0, 1], [36, 0, -36]) }, { rotate: `${interpolate(t, [-1, 0, 1], [40, 0, -40])}deg` }] };
356 });
357 return (
358 <View style={[styles.banner, { width }]}>
359 <LinearGradient colors={promo.colors} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={styles.bannerCard}>
360 <Svg width={280} height={280} style={styles.rings}>
361 <Circle cx={140} cy={140} r={138} stroke={promo.ink} strokeOpacity={0.16} strokeWidth={1.5} fill="none" />
362 <Circle cx={140} cy={140} r={112} fill={promo.ink} fillOpacity={0.1} />
363 </Svg>
364 <Animated.View pointerEvents="none" style={[styles.plate, drift]}>
365 <Photo shot={promo.shot} alt="" width={156} height={156} px={400} style={styles.platePhoto} />
366 </Animated.View>
367 <View style={styles.bannerBody}>
368 <Text style={[styles.eyebrow, { color: promo.ink }]}>{promo.eyebrow}</Text>
369 <Text style={[styles.bannerTitle, { color: promo.ink }]}>{promo.title}</Text>
370 <Tap label={claimed ? `${promo.eyebrow} added to your account` : `${promo.cta}: ${promo.title.replace('\n', ' ')}`} onPress={onClaim} style={styles.ctaSlot}>
371 <View style={[styles.cta, { backgroundColor: promo.pill }]}>
372 {claimed ? (
373 <Animated.View entering={ZoomIn.duration(180)}>
374 <Check size={14} color={promo.pillInk} strokeWidth={3} />
375 </Animated.View>
376 ) : null}
377 <Text style={[styles.ctaLabel, { color: promo.pillInk }]}>{claimed ? 'Added' : promo.cta}</Text>
378 </View>
379 </Tap>
380 </View>
381 </LinearGradient>
382 </View>
383 );
384}
385
386function Dot({ index, x, width, color }: { index: number; x: SharedValue<number>; width: number; color: string }) {
387 const style = useAnimatedStyle(() => {
388 const t = Math.max(0, 1 - Math.abs(x.value / width - index));
389 return { width: 6 + t * 12, opacity: 0.2 + t * 0.8 };
390 });
391 return <Animated.View style={[styles.dot, { backgroundColor: color }, style]} />;
392}
393
394function Promos({ pal }: { pal: Palette }) {
395 const { width } = useWindowDimensions();
396 const [claimed, setClaimed] = useState<string[]>([]);
397 const x = useSharedValue(0);
398 const onScroll = useAnimatedScrollHandler((e) => {
399 x.value = e.contentOffset.x;
400 });
401 return (
402 <View>
403 <Animated.ScrollView horizontal pagingEnabled showsHorizontalScrollIndicator={false} onScroll={onScroll} scrollEventThrottle={16} aria-label="Promotions">
404 {PROMOS.map((p, i) => (
405 <Banner key={p.id} promo={p} index={i} x={x} width={width} claimed={claimed.includes(p.id)} onClaim={() => setClaimed((s) => (s.includes(p.id) ? s.filter((v) => v !== p.id) : [...s, p.id]))} />
406 ))}
407 </Animated.ScrollView>
408 <View style={styles.dots}>
409 {PROMOS.map((p, i) => (
410 <Dot key={p.id} index={i} x={x} width={width} color={pal.fg} />
411 ))}
412 </View>
413 </View>
414 );
415}
416
417// ─── Restaurant card ────────────────────────────────────────────────────────
418
419const MOVE = LinearTransition.duration(300);
420
421function HeartButton({ liked, onPress, name, pal }: { liked: boolean; onPress: () => void; name: string; pal: Palette }) {
422 const scale = useSharedValue(1);
423 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
424 return (
425 <Pressable
426 role="button"
427 aria-label={liked ? `Remove ${name} from favourites` : `Add ${name} to favourites`}
428 hitSlop={6}
429 onPress={() => {
430 scale.value = withSequence(withTiming(0.7, { duration: 90 }), withSpring(1, { damping: 7, stiffness: 320, mass: 0.6 }));
431 onPress();
432 }}
433 style={[styles.heart, { backgroundColor: pal.surface }]}
434 >
435 <Animated.View style={style}>
436 <Heart size={17} color={liked ? ACCENT : pal.heartOff} fill={liked ? ACCENT : 'transparent'} strokeWidth={2.2} />
437 </Animated.View>
438 </Pressable>
439 );
440}
441
442function RestaurantCard({ r, width, photoH, mode, liked, onLike, compact, pal }: { r: Restaurant; width: number; photoH: number; mode: Mode; liked: boolean; onLike: () => void; compact?: boolean; pal: Palette }) {
443 const scale = useSharedValue(1);
444 const press = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
445 const delivery = mode === 'delivery';
446 const eta = delivery ? `${r.time - 5}-${r.time + 5} min` : `Ready in ${r.ready} min`;
447 const cost = delivery ? (r.fee === 0 ? 'Free delivery' : `${money(r.fee)} delivery`) : `${r.miles.toFixed(1)} mi away`;
448 return (
449 <Animated.View style={[{ width }, press]}>
450 {/* Open the restaurant from here. The heart sits beside it, not inside it. */}
451 <Pressable role="link" aria-label={`${r.name}, rated ${r.rating}, ${eta}, ${cost}`} onPressIn={() => (scale.value = withSpring(0.975, SPRING))} onPressOut={() => (scale.value = withSpring(1, SPRING))}>
452 <View style={styles.cardMedia}>
453 <Photo shot={r.shot} alt={`Food from ${r.name}`} width={width} height={photoH} px={800} />
454 <View style={[styles.eta, { backgroundColor: pal.surface }]}>
455 <Animated.Text key={eta} entering={FadeIn.duration(200)} style={[styles.etaText, styles.tabular, { color: pal.fg }]}>
456 {eta}
457 </Animated.Text>
458 </View>
459 </View>
460 <View style={styles.cardRow}>
461 <Text numberOfLines={1} style={[compact ? styles.cardNameCompact : styles.cardName, { color: pal.fg }]}>
462 {r.name}
463 </Text>
464 <View style={styles.rating}>
465 <Star size={13} color={STAR} fill={STAR} />
466 <Text style={[styles.ratingText, styles.tabular, { color: pal.fg }]}>{r.rating.toFixed(1)}</Text>
467 <Text style={[styles.ratingCount, styles.tabular, { color: pal.muted }]}>({r.reviews})</Text>
468 </View>
469 </View>
470 {compact ? null : (
471 <Text numberOfLines={1} style={[styles.cardBlurb, { color: pal.muted }]}>
472 {r.blurb}
473 </Text>
474 )}
475 <View style={styles.cardMeta}>
476 {delivery ? <Bike size={14} color={r.fee === 0 ? pal.good : pal.muted} strokeWidth={2.2} /> : <MapPin size={14} color={pal.muted} strokeWidth={2.2} />}
477 <Text style={[styles.cardCost, styles.tabular, { color: delivery && r.fee === 0 ? pal.good : pal.muted, fontWeight: delivery && r.fee === 0 ? '600' : '400' }]}>{cost}</Text>
478 {compact ? null : <Text style={[styles.cardCost, styles.tabular, { color: pal.muted }]}>{delivery ? `· ${r.miles.toFixed(1)} mi` : '· No fees'}</Text>}
479 </View>
480 </Pressable>
481 {r.offer ? (
482 <View pointerEvents="none" style={styles.offer}>
483 <Tag size={11} color={ON_ACCENT} strokeWidth={2.8} />
484 <Text style={styles.offerText}>{r.offer}</Text>
485 </View>
486 ) : null}
487 <HeartButton liked={liked} onPress={onLike} name={r.name} pal={pal} />
488 </Animated.View>
489 );
490}
491
492// ─── Dish card with a quick Add ─────────────────────────────────────────────
493
494function DishCard({ dish, qty, onAdd, pal }: { dish: (typeof DISHES)[number]; qty: number; onAdd: () => void; pal: Palette }) {
495 const scale = useSharedValue(1);
496 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
497 return (
498 <View style={[styles.dish, { backgroundColor: pal.surface, borderColor: pal.line }]}>
499 <Photo shot={dish.shot} alt={dish.name} width={166} height={112} px={500} />
500 <View style={styles.dishBody}>
501 <Text numberOfLines={1} style={[styles.dishName, { color: pal.fg }]}>
502 {dish.name}
503 </Text>
504 <Text numberOfLines={1} style={[styles.dishFrom, { color: pal.muted }]}>
505 {dish.from}
506 </Text>
507 <View style={styles.dishRow}>
508 <Text style={[styles.dishPrice, styles.tabular, { color: pal.fg }]}>{money(dish.price)}</Text>
509 <Pressable
510 role="button"
511 aria-label={qty ? `Add another ${dish.name}, ${qty} in cart` : `Add ${dish.name} to cart`}
512 hitSlop={8}
513 onPress={() => {
514 scale.value = pop(1.18);
515 onAdd();
516 }}
517 >
518 <Animated.View style={[styles.add, { backgroundColor: qty ? ACCENT : pal.accentSoft }, style]}>
519 <Plus size={14} color={qty ? ON_ACCENT : pal.accentInk} strokeWidth={3} />
520 <Animated.Text key={qty} entering={FadeInDown.duration(180)} style={[styles.addLabel, styles.tabular, { color: qty ? ON_ACCENT : pal.accentInk }]}>
521 {qty ? qty : 'Add'}
522 </Animated.Text>
523 </Animated.View>
524 </Pressable>
525 </View>
526 </View>
527 </View>
528 );
529}
530
531// ─── Filter pill ────────────────────────────────────────────────────────────
532
533function FilterPill({ label, on, onPress, pal }: { label: string; on: boolean; onPress: () => void; pal: Palette }) {
534 return (
535 <Tap label={label} onPress={onPress}>
536 <Animated.View layout={MOVE} aria-checked={on} role="checkbox" style={[styles.pill, { backgroundColor: on ? pal.accentSoft : pal.bg, borderColor: on ? ACCENT : pal.line }]}>
537 {on ? (
538 <Animated.View entering={ZoomIn.duration(160)}>
539 <Check size={14} color={pal.accentInk} strokeWidth={3} />
540 </Animated.View>
541 ) : null}
542 <Text style={[styles.pillLabel, { color: on ? pal.accentInk : pal.fg }]}>{label}</Text>
543 </Animated.View>
544 </Tap>
545 );
546}
547
548// ─── Address sheet ──────────────────────────────────────────────────────────
549
550function AddressSheet({ open, selected, onSelect, onClose, pal }: { open: boolean; selected: string; onSelect: (id: string) => void; onClose: () => void; pal: Palette }) {
551 const insets = useSafeAreaInsets();
552 const t = useSharedValue(0);
553 useEffect(() => {
554 t.value = withTiming(open ? 1 : 0, { duration: open ? 320 : 220, easing: open ? Easing.out(Easing.cubic) : Easing.in(Easing.cubic) });
555 }, [open, t]);
556 const backdrop = useAnimatedStyle(() => ({ opacity: t.value }));
557 const sheet = useAnimatedStyle(() => ({ transform: [{ translateY: (1 - t.value) * 460 }] }));
558 return (
559 <View pointerEvents={open ? 'auto' : 'none'} aria-hidden={!open} style={[StyleSheet.absoluteFill, styles.sheetLayer]}>
560 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: pal.scrim }, backdrop]}>
561 <Pressable role="button" aria-label="Close addresses" onPress={onClose} style={StyleSheet.absoluteFill} />
562 </Animated.View>
563 <Animated.View role="dialog" aria-label="Choose a delivery address" style={[styles.sheet, { backgroundColor: pal.surface, paddingBottom: insets.bottom + 16 }, sheet]}>
564 <View style={[styles.grabber, { backgroundColor: pal.line }]} />
565 <Text style={[styles.sheetTitle, { color: pal.fg }]}>Deliver to</Text>
566 {ADDRESSES.map(({ id, label, street, detail, icon: Icon }) => {
567 const on = id === selected;
568 return (
569 <Pressable key={id} role="radio" aria-checked={on} aria-label={`${label}, ${street}`} onPress={() => onSelect(id)} style={({ pressed }) => [styles.address, { borderColor: on ? ACCENT : pal.line, backgroundColor: on ? pal.accentSoft : pressed ? pal.field : pal.surface }]}>
570 <View style={[styles.addressIcon, { backgroundColor: on ? ACCENT : pal.field }]}>
571 <Icon size={18} color={on ? ON_ACCENT : pal.fg} strokeWidth={2.2} />
572 </View>
573 <View style={styles.addressText}>
574 <Text style={[styles.addressLabel, { color: pal.fg }]}>
575 {label} · {street}
576 </Text>
577 <Text numberOfLines={1} style={[styles.addressDetail, { color: pal.muted }]}>
578 {detail}
579 </Text>
580 </View>
581 {on ? (
582 <Animated.View entering={ZoomIn.duration(180)} style={styles.addressCheck}>
583 <Check size={14} color={ON_ACCENT} strokeWidth={3.2} />
584 </Animated.View>
585 ) : null}
586 </Pressable>
587 );
588 })}
589 <Pressable role="button" aria-label="Add a new address" style={({ pressed }) => [styles.addressNew, { opacity: pressed ? 0.55 : 1 }]}>
590 <Plus size={18} color={pal.accentInk} strokeWidth={2.6} />
591 <Text style={[styles.addressNewLabel, { color: pal.accentInk }]}>Add a new address</Text>
592 </Pressable>
593 </Animated.View>
594 </View>
595 );
596}
597
598// ─── Cart bar and tab bar ───────────────────────────────────────────────────
599
600function CartBar({ count, total, bottom }: { count: number; total: number; bottom: number }) {
601 const shown = count > 0;
602 const t = useSharedValue(0);
603 useEffect(() => {
604 t.value = withSpring(shown ? 1 : 0, { damping: 16, stiffness: 190, mass: 0.8 });
605 }, [shown, t]);
606 const style = useAnimatedStyle(() => ({ opacity: Math.min(1, t.value * 2), transform: [{ translateY: (1 - t.value) * 90 }] }));
607 return (
608 <Animated.View pointerEvents={shown ? 'auto' : 'none'} aria-hidden={!shown} style={[styles.cartSlot, { bottom }, style]}>
609 <Tap label={`View cart, ${count} ${count === 1 ? 'item' : 'items'}, ${money(total)}`} to={0.97}>
610 <View style={styles.cart}>
611 <View style={styles.cartCount}>
612 <Animated.Text key={count} entering={FadeInDown.duration(200)} style={[styles.cartCountText, styles.tabular]}>
613 {count}
614 </Animated.Text>
615 </View>
616 <View style={styles.cartText}>
617 <Text style={styles.cartTitle}>View cart</Text>
618 <Text style={styles.cartNote}>{count === 1 ? '1 item' : `${count} items`} · Checkout in 2 taps</Text>
619 </View>
620 <Animated.Text key={total} entering={FadeInDown.duration(200)} style={[styles.cartTotal, styles.tabular]}>
621 {money(total)}
622 </Animated.Text>
623 <ChevronRight size={18} color={ON_ACCENT} strokeWidth={2.6} />
624 </View>
625 </Tap>
626 </Animated.View>
627 );
628}
629
630function TabBar({ onSearch, pal }: { onSearch: () => void; pal: Palette }) {
631 const insets = useSafeAreaInsets();
632 const [tab, setTab] = useState('Home');
633 return (
634 <View role="tablist" style={[styles.tabBar, { paddingBottom: insets.bottom, backgroundColor: pal.bg, borderTopColor: pal.line }]}>
635 {TABS.map(({ label, icon: Icon }) => {
636 const on = tab === label;
637 return (
638 <Pressable
639 key={label}
640 role="tab"
641 aria-selected={on}
642 aria-label={`${label} tab`}
643 onPress={() => {
644 setTab(label);
645 if (label === 'Search') onSearch();
646 }}
647 style={styles.tab}
648 >
649 <Icon size={23} color={on ? ACCENT : pal.muted} strokeWidth={on ? 2.4 : 1.9} />
650 <Text style={[styles.tabLabel, { fontWeight: on ? '700' : '500', color: on ? pal.fg : pal.muted }]}>{label}</Text>
651 </Pressable>
652 );
653 })}
654 </View>
655 );
656}
657
658// ─── Screen ─────────────────────────────────────────────────────────────────
659
660export default function FoodDeliveryHomeScreen() {
661 const pal = usePalette();
662 const insets = useSafeAreaInsets();
663 const { width } = useWindowDimensions();
664
665 const [mode, setMode] = useState<Mode>('delivery');
666 const [addressId, setAddressId] = useState('home');
667 const [sheetOpen, setSheetOpen] = useState(false);
668 const [query, setQuery] = useState('');
669 const [cuisine, setCuisine] = useState<Cuisine | null>(null);
670 const [pills, setPills] = useState<PillKey[]>([]);
671 const [liked, setLiked] = useState<string[]>(['nonna']);
672 const [cart, setCart] = useState<Record<string, number>>({});
673 const inputRef = useRef<ComponentRef<typeof TextInput>>(null);
674
675 const address = ADDRESSES.find((a) => a.id === addressId) ?? ADDRESSES[0];
676 const count = Object.values(cart).reduce((n, q) => n + q, 0);
677 const total = DISHES.reduce((sum, d) => sum + (cart[d.id] ?? 0) * d.price, 0);
678 const minutes = (r: Restaurant) => (mode === 'delivery' ? r.time : r.ready);
679
680 // Browsing shows offers and shelves; a cuisine or a search folds them away so results sit under the chips.
681 const term = query.trim().toLowerCase();
682 const browsing = cuisine === null && term === '';
683 const fastest = useMemo(() => [...RESTAURANTS].sort((a, b) => (mode === 'delivery' ? a.time - b.time : a.ready - b.ready)).slice(0, 5), [mode]);
684 const results = useMemo(
685 () =>
686 RESTAURANTS.filter(
687 (r) =>
688 (cuisine === null || r.cuisines.includes(cuisine)) &&
689 (term === '' || `${r.name} ${r.blurb}`.toLowerCase().includes(term)) &&
690 (!pills.includes('fast') || (mode === 'delivery' ? r.time : r.ready) < 30) &&
691 (!pills.includes('top') || r.rating >= 4.5) &&
692 (!pills.includes('offers') || !!r.offer),
693 ),
694 [cuisine, term, pills, mode],
695 );
696 const toggle = <T,>(list: T[], v: T) => (list.includes(v) ? list.filter((x) => x !== v) : [...list, v]);
697 const listTitle = term ? 'Results' : cuisine ? `${cuisine} near you` : 'All restaurants';
698
699 // The address row and the switch scroll away; the search field stops under the status bar.
700 const scrollY = useSharedValue(0);
701 const onScroll = useAnimatedScrollHandler((e) => {
702 scrollY.value = e.contentOffset.y;
703 });
704 const header = useAnimatedStyle(() => ({ transform: [{ translateY: -Math.max(0, Math.min(TOP_H, scrollY.value)) }] }));
705 const headerTop = useAnimatedStyle(() => ({ opacity: interpolate(scrollY.value, [0, TOP_H * 0.7], [1, 0], 'clamp') }));
706 const hairline = useAnimatedStyle(() => ({ opacity: interpolate(scrollY.value, [TOP_H - 12, TOP_H + 8], [0, 1], 'clamp') }));
707
708 const cardW = width - 32;
709 return (
710 <View style={[styles.screen, { backgroundColor: pal.bg }]}>
711 <Animated.ScrollView
712 onScroll={onScroll}
713 scrollEventThrottle={16}
714 showsVerticalScrollIndicator={false}
715 keyboardShouldPersistTaps="handled"
716 contentContainerStyle={{ paddingTop: insets.top + HEADER_H, paddingBottom: insets.bottom + TAB_H + 24 + (count > 0 ? CART_H + 12 : 0) }}
717 >
718 {/* Cuisines */}
719 <Animated.View entering={FadeInDown.duration(400)}>
720 <ScrollView horizontal showsHorizontalScrollIndicator={false} role="tablist" aria-label="Cuisines" contentContainerStyle={styles.cuisines}>
721 {CUISINES.map((c) => (
722 <CuisineChip key={c.name} name={c.name} shot={c.shot} selected={c.name === cuisine} dimmed={cuisine !== null && c.name !== cuisine} onPress={() => setCuisine((v) => (v === c.name ? null : c.name))} pal={pal} />
723 ))}
724 </ScrollView>
725 </Animated.View>
726
727 {browsing ? (
728 <Animated.View key="shelves" entering={FadeIn.duration(260)} exiting={FadeOut.duration(160)}>
729 <Animated.View entering={FadeInDown.delay(70).duration(420)}>
730 <Promos pal={pal} />
731 </Animated.View>
732
733 <Animated.View entering={FadeInDown.delay(140).duration(420)}>
734 <SectionHead title="Fastest near you" note={mode === 'delivery' ? 'From 10 min' : 'Ready from 5 min'} pal={pal} />
735 <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.shelf}>
736 {fastest.map((r) => (
737 <RestaurantCard key={r.id} r={r} width={236} photoH={128} mode={mode} liked={liked.includes(r.id)} onLike={() => setLiked((s) => toggle(s, r.id))} compact pal={pal} />
738 ))}
739 </ScrollView>
740 </Animated.View>
741
742 <Animated.View entering={FadeInDown.delay(210).duration(420)}>
743 <SectionHead title="Popular dishes" note="One tap to add" pal={pal} />
744 <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.shelf}>
745 {DISHES.map((d) => (
746 <DishCard key={d.id} dish={d} qty={cart[d.id] ?? 0} onAdd={() => setCart((s) => ({ ...s, [d.id]: (s[d.id] ?? 0) + 1 }))} pal={pal} />
747 ))}
748 </ScrollView>
749 </Animated.View>
750 </Animated.View>
751 ) : null}
752
753 {/* Restaurants */}
754 <Animated.View entering={FadeInDown.delay(280).duration(420)}>
755 {/* Only fixed-size blocks get a layout transition, so they glide without stretching. */}
756 <Animated.View layout={MOVE}>
757 <SectionHead title={listTitle} note={`${results.length} ${results.length === 1 ? 'place' : 'places'}`} pal={pal} />
758 <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.pills}>
759 {PILLS.map((p) => (
760 <FilterPill key={p.key} label={p.label} on={pills.includes(p.key)} onPress={() => setPills((s) => toggle(s, p.key))} pal={pal} />
761 ))}
762 </ScrollView>
763 </Animated.View>
764 <View style={styles.list}>
765 {results.map((r) => (
766 <Animated.View key={r.id} layout={MOVE} entering={FadeIn.duration(260)} exiting={FadeOut.duration(160)}>
767 <RestaurantCard r={r} width={cardW} photoH={164} mode={mode} liked={liked.includes(r.id)} onLike={() => setLiked((s) => toggle(s, r.id))} pal={pal} />
768 </Animated.View>
769 ))}
770 {results.length === 0 ? (
771 <Animated.View entering={FadeIn.delay(160).duration(260)} style={styles.empty}>
772 <View style={[styles.emptyIcon, { backgroundColor: pal.field }]}>
773 <SearchX size={26} color={pal.muted} />
774 </View>
775 <Text style={[styles.emptyTitle, { color: pal.fg }]}>Nothing matches yet</Text>
776 <Text style={[styles.emptyBody, { color: pal.muted }]}>Try fewer filters, another cuisine or a shorter search.</Text>
777 <Pressable
778 role="button"
779 aria-label="Clear all filters"
780 hitSlop={10}
781 onPress={() => {
782 setPills([]);
783 setCuisine(null);
784 setQuery('');
785 }}
786 style={({ pressed }) => [styles.emptyAction, { opacity: pressed ? 0.55 : 1 }]}
787 >
788 <Text style={[styles.emptyActionLabel, { color: pal.accentInk }]}>Clear filters</Text>
789 </Pressable>
790 </Animated.View>
791 ) : null}
792 </View>
793 </Animated.View>
794 </Animated.ScrollView>
795
796 {/* Header: opaque. It slides up until the search field sits under the status bar. */}
797 <Animated.View style={[styles.header, { paddingTop: insets.top, backgroundColor: pal.bg }, header]}>
798 <Animated.View style={[styles.headerTop, headerTop]}>
799 <View style={styles.addressRow}>
800 <Pressable role="button" aria-label={`${mode === 'delivery' ? 'Deliver to' : 'Pick up near'} ${address.label}, ${address.street}. Change address`} aria-expanded={sheetOpen} onPress={() => setSheetOpen(true)} style={({ pressed }) => [styles.addressButton, { opacity: pressed ? 0.6 : 1 }]}>
801 <View style={[styles.pin, { backgroundColor: pal.accentSoft }]}>
802 <MapPin size={18} color={pal.accentInk} strokeWidth={2.4} />
803 </View>
804 <View style={styles.addressLines}>
805 <Text style={[styles.addressCaption, { color: pal.muted }]}>{mode === 'delivery' ? 'Deliver to' : 'Pick up near'}</Text>
806 <View style={styles.addressValue}>
807 <Animated.Text key={address.id} entering={FadeIn.duration(220)} numberOfLines={1} style={[styles.addressName, { color: pal.fg }]}>
808 {address.label}, {address.street}
809 </Animated.Text>
810 <ChevronDown size={17} color={pal.fg} strokeWidth={2.6} />
811 </View>
812 </View>
813 </Pressable>
814 <Tap label={count ? `Cart, ${count} items` : 'Cart, empty'} to={0.9}>
815 <View style={[styles.cartButton, { backgroundColor: pal.field }]}>
816 <ShoppingBag size={20} color={pal.fg} strokeWidth={2.1} />
817 {count > 0 ? <CountBadge count={count} ring={pal.field} /> : null}
818 </View>
819 </Tap>
820 </View>
821 <ModeSwitch mode={mode} onChange={setMode} pal={pal} />
822 </Animated.View>
823 <SearchField value={query} onChange={setQuery} inputRef={inputRef} pal={pal} />
824 <Animated.View style={[styles.hairline, { backgroundColor: pal.line }, hairline]} />
825 </Animated.View>
826 {/* Keeps the status bar clear while the header slides under it. */}
827 <View pointerEvents="none" style={[styles.statusCover, { height: insets.top, backgroundColor: pal.bg }]} />
828
829 <CartBar count={count} total={total} bottom={insets.bottom + TAB_H + 10} />
830 <TabBar onSearch={() => inputRef.current?.focus()} pal={pal} />
831 <AddressSheet
832 open={sheetOpen}
833 selected={addressId}
834 onClose={() => setSheetOpen(false)}
835 onSelect={(id) => {
836 setAddressId(id);
837 setTimeout(() => setSheetOpen(false), 220);
838 }}
839 pal={pal}
840 />
841 </View>
842 );
843}
844
845// ─── Styles ─────────────────────────────────────────────────────────────────
846
847const styles = StyleSheet.create({
848 screen: { flex: 1, overflow: 'hidden' },
849 tabular: { fontVariant: ['tabular-nums'] },
850
851 // Small pieces
852 photo: { overflow: 'hidden' },
853 photoFlash: { backgroundColor: '#FFFFFF' },
854 photoFrame: { position: 'absolute' },
855 sectionHead: { flexDirection: 'row', alignItems: 'baseline', justifyContent: 'space-between', paddingHorizontal: 16, paddingTop: 22, paddingBottom: 12 },
856 sectionTitle: { fontSize: 20, fontWeight: '800', letterSpacing: -0.5 },
857 sectionNote: { fontSize: 13, fontWeight: '500' },
858
859 // Header
860 header: { position: 'absolute', top: 0, left: 0, right: 0, paddingHorizontal: 16 },
861 statusCover: { position: 'absolute', top: 0, left: 0, right: 0 },
862 headerTop: { height: TOP_H },
863 addressRow: { height: 48, flexDirection: 'row', alignItems: 'center', gap: 12 },
864 addressButton: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 10 },
865 pin: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },
866 addressLines: { flex: 1 },
867 addressCaption: { fontSize: 12, fontWeight: '500', lineHeight: 16 },
868 addressValue: { flexDirection: 'row', alignItems: 'center', gap: 3 },
869 addressName: { fontSize: 16.5, fontWeight: '700', letterSpacing: -0.3, lineHeight: 22, flexShrink: 1 },
870 cartButton: { width: 42, height: 42, borderRadius: 21, alignItems: 'center', justifyContent: 'center' },
871 badge: { position: 'absolute', top: -3, right: -3, minWidth: 20, height: 20, borderRadius: 10, paddingHorizontal: 4, borderWidth: 2, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' },
872 badgeText: { color: ON_ACCENT, fontSize: 10.5, fontWeight: '800', lineHeight: 13 },
873 switch: { height: 40, marginTop: 8, borderRadius: 13, padding: 3, flexDirection: 'row' },
874 switchThumb: { position: 'absolute', top: 3, left: 3, bottom: 3, borderRadius: 10 },
875 thumbLight: { shadowColor: '#3A1D10', shadowOpacity: 0.14, shadowRadius: 6, shadowOffset: { width: 0, height: 2 } },
876 thumbDark: { shadowColor: '#000000', shadowOpacity: 0.4, shadowRadius: 6, shadowOffset: { width: 0, height: 2 } },
877 switchOption: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 7 },
878 switchLabel: { fontSize: 14.5, fontWeight: '600' },
879 search: { height: 48, borderRadius: 14, borderWidth: 1.5, flexDirection: 'row', alignItems: 'center', paddingLeft: 13, paddingRight: 9, gap: 9 },
880 searchInput: { flex: 1, height: '100%', fontSize: 16, paddingVertical: 0 },
881 searchClear: { width: 26, height: 26, borderRadius: 13, alignItems: 'center', justifyContent: 'center' },
882 hairline: { height: StyleSheet.hairlineWidth, marginTop: 10, marginHorizontal: -16 },
883
884 // Cuisine chips
885 cuisines: { paddingHorizontal: 12, paddingTop: 4, gap: 4 },
886 cuisine: { width: 72, alignItems: 'center', gap: 5 },
887 cuisineSlot: { width: 68, height: 68, alignItems: 'center', justifyContent: 'center' },
888 cuisineRing: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, borderRadius: 34, borderWidth: 2.5, borderColor: ACCENT },
889 cuisinePhoto: { borderRadius: 29 },
890 cuisineLabel: { fontSize: 12.5, letterSpacing: -0.1 },
891
892 // Promo carousel
893 banner: { paddingHorizontal: 16, paddingTop: 14 },
894 bannerCard: { height: PROMO_H, borderRadius: 22, overflow: 'hidden' },
895 rings: { position: 'absolute', right: -96, top: -66 },
896 plate: {
897 position: 'absolute',
898 right: -34,
899 top: -4,
900 width: 164,
901 height: 164,
902 borderRadius: 82,
903 borderWidth: 4,
904 borderColor: 'rgba(255,255,255,0.9)',
905 shadowColor: '#000000',
906 shadowOpacity: 0.3,
907 shadowRadius: 18,
908 shadowOffset: { width: 0, height: 10 },
909 },
910 platePhoto: { borderRadius: 78 },
911 bannerBody: { flex: 1, paddingLeft: 20, justifyContent: 'center', alignItems: 'flex-start' },
912 eyebrow: { opacity: 0.82, fontSize: 11, fontWeight: '700', letterSpacing: 1.2, textTransform: 'uppercase' },
913 bannerTitle: { fontSize: 24, lineHeight: 27, fontWeight: '800', letterSpacing: -0.8, marginTop: 5 },
914 ctaSlot: { marginTop: 12 },
915 cta: { height: 32, paddingHorizontal: 14, borderRadius: 16, flexDirection: 'row', alignItems: 'center', gap: 5 },
916 ctaLabel: { fontSize: 13, fontWeight: '700' },
917 dots: { flexDirection: 'row', justifyContent: 'center', gap: 5, marginTop: 12 },
918 dot: { height: 6, borderRadius: 3 },
919
920 // Restaurant card
921 shelf: { paddingHorizontal: 16, gap: 12 },
922 list: { paddingHorizontal: 16, paddingTop: 16, gap: 24 },
923 cardMedia: { borderRadius: 18, overflow: 'hidden' },
924 eta: { position: 'absolute', right: 10, bottom: 10, height: 26, paddingHorizontal: 10, borderRadius: 13, justifyContent: 'center' },
925 etaText: { fontSize: 12.5, fontWeight: '700' },
926 cardRow: { flexDirection: 'row', alignItems: 'center', gap: 10, marginTop: 10 },
927 cardName: { flex: 1, fontSize: 18, fontWeight: '700', letterSpacing: -0.4 },
928 cardNameCompact: { flex: 1, fontSize: 16, fontWeight: '700', letterSpacing: -0.3 },
929 rating: { flexDirection: 'row', alignItems: 'center', gap: 3 },
930 ratingText: { fontSize: 13.5, fontWeight: '700' },
931 ratingCount: { fontSize: 13 },
932 cardBlurb: { fontSize: 14, marginTop: 3 },
933 cardMeta: { flexDirection: 'row', alignItems: 'center', gap: 5, marginTop: 4 },
934 cardCost: { fontSize: 13.5 },
935 offer: { position: 'absolute', left: 10, top: 10, height: 26, paddingLeft: 8, paddingRight: 10, borderRadius: 13, backgroundColor: ACCENT, flexDirection: 'row', alignItems: 'center', gap: 4 },
936 offerText: { color: ON_ACCENT, fontSize: 12, fontWeight: '700' },
937 heart: { position: 'absolute', right: 10, top: 10, width: 34, height: 34, borderRadius: 17, alignItems: 'center', justifyContent: 'center' },
938
939 // Dish card
940 dish: { width: 168, borderRadius: 18, borderWidth: 1, overflow: 'hidden' },
941 dishBody: { padding: 12, paddingTop: 10 },
942 dishName: { fontSize: 14.5, fontWeight: '700', letterSpacing: -0.2 },
943 dishFrom: { fontSize: 12.5, marginTop: 2 },
944 dishRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginTop: 10 },
945 dishPrice: { fontSize: 15.5, fontWeight: '700' },
946 add: { height: 32, minWidth: 68, paddingHorizontal: 12, borderRadius: 16, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 4 },
947 addLabel: { fontSize: 13.5, fontWeight: '700' },
948
949 // Filter pills and the empty state
950 pills: { paddingHorizontal: 16, gap: 8 },
951 pill: { height: 36, paddingHorizontal: 14, borderRadius: 18, borderWidth: 1.5, flexDirection: 'row', alignItems: 'center', gap: 5 },
952 pillLabel: { fontSize: 13.5, fontWeight: '600' },
953 empty: { alignItems: 'center', paddingVertical: 36, paddingHorizontal: 24 },
954 emptyIcon: { width: 60, height: 60, borderRadius: 30, alignItems: 'center', justifyContent: 'center' },
955 emptyTitle: { fontSize: 18, fontWeight: '700', letterSpacing: -0.3, marginTop: 16 },
956 emptyBody: { fontSize: 14.5, lineHeight: 21, textAlign: 'center', marginTop: 6 },
957 emptyAction: { marginTop: 16 },
958 emptyActionLabel: { fontSize: 15, fontWeight: '700' },
959
960 // Address sheet
961 sheetLayer: { justifyContent: 'flex-end' },
962 sheet: { borderTopLeftRadius: 28, borderTopRightRadius: 28, paddingHorizontal: 16, paddingTop: 10, gap: 10 },
963 grabber: { alignSelf: 'center', width: 40, height: 5, borderRadius: 3 },
964 sheetTitle: { fontSize: 22, fontWeight: '800', letterSpacing: -0.6, marginTop: 10, marginBottom: 4, paddingHorizontal: 4 },
965 address: { minHeight: 68, borderRadius: 18, borderWidth: 1.5, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 12 },
966 addressIcon: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },
967 addressText: { flex: 1 },
968 addressLabel: { fontSize: 15.5, fontWeight: '700', letterSpacing: -0.2 },
969 addressDetail: { fontSize: 13.5, marginTop: 2 },
970 addressCheck: { width: 24, height: 24, borderRadius: 12, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },
971 addressNew: { height: 48, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 6 },
972 addressNewLabel: { fontSize: 15, fontWeight: '700' },
973
974 // Cart bar and tab bar
975 cartSlot: { position: 'absolute', left: 16, right: 16 },
976 cart: {
977 height: CART_H,
978 borderRadius: 18,
979 backgroundColor: ACCENT,
980 flexDirection: 'row',
981 alignItems: 'center',
982 paddingLeft: 10,
983 paddingRight: 12,
984 gap: 10,
985 shadowColor: shade(ACCENT, 0.25),
986 shadowOpacity: 0.4,
987 shadowRadius: 18,
988 shadowOffset: { width: 0, height: 8 },
989 },
990 cartCount: { width: 36, height: 36, borderRadius: 12, backgroundColor: tint(ON_ACCENT, 0.22), alignItems: 'center', justifyContent: 'center', overflow: 'hidden' },
991 cartCountText: { color: ON_ACCENT, fontSize: 15, fontWeight: '800' },
992 cartText: { flex: 1 },
993 cartTitle: { color: ON_ACCENT, fontSize: 15.5, fontWeight: '700', letterSpacing: -0.2 },
994 cartNote: { color: tint(ON_ACCENT, 0.86), fontSize: 12.5, marginTop: 1 },
995 cartTotal: { color: ON_ACCENT, fontSize: 16, fontWeight: '800' },
996 tabBar: { position: 'absolute', left: 0, right: 0, bottom: 0, flexDirection: 'row', borderTopWidth: StyleSheet.hairlineWidth },
997 tab: { flex: 1, height: TAB_H, alignItems: 'center', justifyContent: 'center', gap: 3 },
998 tabLabel: { fontSize: 10.5 },
999});

More screens like this.

All Food & Delivery