# React Native food delivery app template (Pro)

> A complete React Native food delivery app for iOS, Android and the web: offers and restaurants near you, a menu by section, a dish to customise, a basket with tips and deals, live order tracking, a chat with the courier, and rating the order.

# 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

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

<FoodApp />;
```

| Prop | Type | Default |
| --- | --- | --- |
| `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

| Screen | What it does |
| --- | --- |
| `FoodHomeScreen` | The address, a search, offers in a Carousel, cuisines, the fastest kitchens and all restaurants |
| `RestaurantScreen` | The menu by section with chips, quick add, and the basket pinned |
| `DishScreen` | Size on a RadioGroup, extras as Checkboxes, a note (TextArea) and the live price |
| `BasketScreen` | Steppers, a tip SegmentedControl, address and Apple Pay, totals with the deal |
| `TrackingScreen` | A route map, Pro's OrderTracker and the courier to message or call |
| `CourierChatScreen` | MessageBubble and ChatComposer with quick replies |
| `RateScreen` | Rating for food and courier, compliments on a ToggleGroup, a tip |
| `FoodOrdersScreen` | Past 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](/docs/components/avatar) · [Badge](/docs/components/badge) · [Button](/docs/components/button) · [Carousel](/docs/components/carousel) · [ChatComposer, MessageBubble](/docs/components/chat) · [Checkbox](/docs/components/checkbox) · [ChipGroup](/docs/components/chip-group) · [DescriptionList](/docs/components/description-list) · [Header](/docs/components/header) · [Heading, Text](/docs/components/text) · [List, ListItem](/docs/components/list) · [RadioGroup, RadioGroupItem](/docs/components/radio-group) · [Rating](/docs/components/rating) · [SearchField](/docs/components/search-field) · [SegmentedControl](/docs/components/segmented-control) · [Separator](/docs/components/separator) · [TextArea](/docs/components/text-area) · [ToggleGroup](/docs/components/toggle-group)

And from Patine Pro:

- [App shell and layout](/docs/pro/layout) PRO
- [Brand logos](/docs/components/brand-icons) PRO
- [Order tracker](/docs/blocks/order-tracker) PRO

## Files

```text
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`:

```tsx
/** 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
