# React Native delivery tracking template with live map (Pro)

> A React Native delivery tracking screen for iOS, Android and the web: the courier riding the route on a map with their heading, a countdown and arrival time, order steps, call and chat, and rating with a tip. Built on Patine Pro's MapView, no native modules.

# Delivery tracking Pro

Live delivery tracking for the person waiting, as Uber Eats and Wolt show it. The courier rides the route with their heading, the part already ridden fades, and the camera keeps courier and door in frame; move the map to look around, then tap **Re-centre**. Above it: the step in words, a countdown and arrival time, the courier to call or message, the pickup and door, and the order. Once it's delivered, rate the courier, add compliments and a tip. On desktops the details sit beside the map; on phones they live in a sheet over it.

Built from [MapView](../blocks/map) (`MapMarker`, `MapRoute`, `MapSheet`) and free components.

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

<CourierTrackingScreen />;
```

```tsx live full
import { View } from 'react-native';
import { CourierTrackingScreen } from '@patine-ui/pro';

export default function Example() {
  return (
    <View style={{ width: '100%', height: 680 }}>
      <CourierTrackingScreen />
    </View>
  );
}
```

## Make it yours

| Prop | Type | Default |
| --- | --- | --- |
| `trip` | `TripPlan`: `from`, `to`, `courier`, `items`, `total`, `approach` and `route` (coordinates), `prepare`, `pickupDwell`, `speed`, `arriving` | `DEMO_TRIP`, a Hackney order by e-bike |
| `speed` | `number`: seconds of the trip per second | `8` in the demo; pass `1` with a live feed |
| `startAt` | `number`: seconds into the trip it opens at | `300` |
| `onCall` | `() => void` | Dials the courier |
| `onChat` | `() => void` | Open your chat |
| `onRate` | `({ stars, tip, compliments }) => void` | |
| `onBack` | `() => void`: shows a back button | |
| `onHelp` | `() => void` | |

`tripState(trip, t)` says where a delivery is `t` seconds after the order: the step (`TRIP_STEPS`), the courier's place and heading, and the seconds and metres left. With real GPS, copy the screen and feed the courier's position to the marker instead.

The map opens on OpenStreetMap's tiles, which suit development. For production, pass a provider's URL with your key to `MapView` (see [Tiles](../blocks/map#tiles)).

## Built with

The free components, from `patine-ui`:

[Avatar](/docs/components/avatar) · [Button](/docs/components/button) · [Rating](/docs/components/rating) · [SegmentedControl](/docs/components/segmented-control) · [Separator](/docs/components/separator) · [Text](/docs/components/text)

And from Patine Pro:

- [App shell and layout](/docs/pro/layout) PRO
- [Map](/docs/blocks/map) PRO
- [Patine Icons, the Pro set](/docs/components/icons) PRO

## Files

```text
courier/
├── components/
│   ├── CourierCard.tsx
│   ├── Pins.tsx
│   ├── RateTrip.tsx
│   └── TripStatus.tsx
├── hooks/
│   └── useTrip.ts
├── courier.constants.ts
├── courier.types.ts
├── courier.utils.ts
├── CourierTrackingScreen.tsx
└── index.ts
```

## A look at the code

The countdown and arrival time, from `courier.utils.ts`:

```tsx
/** Seconds as the countdown shows them: "12 min", "1 min", then "Now". */
export const formatEta = (seconds: number) => {
  if (seconds < 45) return 'Now';
  return `${Math.max(1, Math.round(seconds / 60))} min`;
};

/** A time of day as a 24-hour clock, as UK apps show it: "19:58". */
export const formatArrival = (from: Date, seconds: number) => {
  const d = new Date(from.getTime() + seconds * 1000);
  return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
};
```

Get the source with Pro

## Accessibility

- The status is a live region: "Sam is on the way. Arriving in 12 min, at 19:58".
- The steps are a progress bar named "Step 4 of 6: On the way".
- The courier pin and both places are named on the map.
- Compliments are checkboxes; the rating and tip are labelled controls.

## Related

- [Map](../blocks/map) · [Store locator](./store-locator) · [Dispatch](./dispatch) · [Food delivery](./food)
