Skip to main content

Food delivery: Basil Pro

Basil delivers from local kitchens. The restaurant deal (20% off over £25) applies itself and tells you how much more to add; the courier chat answers back in the demo.

See it live, on any device

Use the whole app​

import { FoodApp } from '@patine-ui/pro';

<FoodApp />;
PropTypeDefault
initialRoute'home' | 'restaurant' | 'dish' | 'basket' | 'tracking' | 'chat' | 'rate' | 'orders''home'
demo'ready' | 'loading' | 'empty' | 'error''ready'
insets{ top, bottom }None
platform'ios' | 'android' | 'web'Platform.OS

Screens move the platform's way: on iOS a pushed screen slides in from the trailing edge, on Android they fade through, on the web and between tabs they fade in. Reduce motion turns it off.

Screens​

ScreenWhat it does
FoodHomeScreenThe address, a search, offers in a Carousel, cuisines, the fastest kitchens and all restaurants
RestaurantScreenThe menu by section with chips, quick add, and the basket pinned
DishScreenSize on a RadioGroup, extras as Checkboxes, a note (TextArea) and the live price
BasketScreenSteppers, a tip SegmentedControl, address and Apple Pay, totals with the deal
TrackingScreenA route map, Pro's OrderTracker and the courier to message or call
CourierChatScreenMessageBubble and ChatComposer with quick replies
RateScreenRating for food and courier, compliments on a ToggleGroup, a tip
FoodOrdersScreenPast orders with Reorder

Every screen is exported on its own, takes its data as props, and has sample data as defaults. basketTotals(lines, delivery, tip) works out items, the deal, fees and the tip; unitPrice a dish with its size and extras.

Built with​

The free components, from patine-ui:

Avatar · Badge · Button · Carousel · ChatComposer, MessageBubble · Checkbox · ChipGroup · DescriptionList · Header · Heading, Text · List, ListItem · RadioGroup, RadioGroupItem · Rating · SearchField · SegmentedControl · Separator · TextArea · ToggleGroup

And from Patine Pro:

Files​

food/
├── hooks/
│ └── useFood.ts
├── BasketScreen.tsx
├── CourierChatScreen.tsx
├── DishScreen.tsx
├── food.constants.ts
├── food.utils.ts
├── FoodApp.tsx
├── FoodHomeScreen.tsx
├── FoodOrdersScreen.tsx
├── index.ts
├── RateScreen.tsx
├── RestaurantScreen.tsx
└── TrackingScreen.tsx

It also uses shared/, the theme, money formatting and screen transitions every Pro app shares.

A look at the code​

The basket’s totals with the restaurant’s deal, service and tip, from food.utils.ts:

/** What a basket comes to: items, the restaurant's deal (20% off past £25), delivery, service and the tip. */
export const basketTotals = (lines: readonly BasketLine[], delivery: number, tip: number, dealThreshold = 2500, dealPercent = 0.2) => {
const items = lines.reduce((s, l) => s + unitPrice(l.dishId, l.size, l.extras) * l.quantity, 0);
const deal = items >= dealThreshold ? Math.round(items * dealPercent) : 0;
const service = items ? SERVICE_FEE : 0;
return {
count: lines.reduce((n, l) => n + l.quantity, 0),
items,
deal,
toDeal: Math.max(0, dealThreshold - items),
delivery: items ? delivery : 0,
service,
tip,
total: items ? items - deal + delivery + service + tip : 0,
};
};
Get the source with Pro