# React Native fitness app template (Pro)

> A complete React Native fitness and health app for iOS, Android and the web: setup in three steps, activity rings, programs and workouts, a live workout with a timer and heart-rate zones, progress charts, a class timetable on an event calendar, badges and a leaderboard.

# Fitness: Stride Pro

Stride plans training around your goals. The live session counts down each block, can pause and skip, and shows heart rate against zones on a gauge.

See it live, on any device

## Use the whole app

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

<FitnessApp />;
```

| Prop | Type | Default |
| --- | --- | --- |
| `initialRoute` | 'today' \| 'setup' \| 'train' \| 'workout' \| 'session' \| 'progress' \| 'classes' \| 'profile' | 'today' |
| `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 |
| --- | --- |
| `TodayScreen` | RadialChart rings, the planned workout, StatsRow for steps, heart and sleep, the week's streak |
| `SetupScreen` | Steps as progress, goals on a multiple ToggleGroup, a Slider and SegmentedControl for rhythm |
| `TrainScreen` | Programs in a Carousel and workouts filtered with chips |
| `WorkoutScreen` | The plan on Pro's Timeline with numbered markers |
| `SessionScreen` | A countdown per block, Progress for the whole session, a GaugeChart of heart-rate zones, pause and skip |
| `FitnessProgressScreen` | A year HeatmapChart, this week against last, weight with a target band, a RadarChart profile |
| `ClassesScreen` | Pro's EventCalendar of studio classes with booking in a BottomSheet |
| `FitnessProfileScreen` | Badges and a sortable leaderboard Table |

Every screen is exported on its own, takes its data as props, and has sample data as defaults. `sessionAt(exercises, elapsed)` says which block a session is on and what is left; `heartZone(bpm)` the zone.

## Built with

The free components, from `patine-ui`:

[Avatar](/docs/components/avatar) · [Badge](/docs/components/badge) · [BottomSheet](/docs/components/bottom-sheet) · [Button](/docs/components/button) · [Card](/docs/components/card) · [Carousel](/docs/components/carousel) · [ChipGroup](/docs/components/chip-group) · [DescriptionList](/docs/components/description-list) · [Heading, Text](/docs/components/text) · [List, ListItem](/docs/components/list) · [Progress](/docs/components/progress) · [SegmentedControl](/docs/components/segmented-control) · [Slider](/docs/components/slider) · [Steps](/docs/components/steps) · [Table](/docs/components/table) · [ToggleGroup](/docs/components/toggle-group)

And from Patine Pro:

- [App shell and layout](/docs/pro/layout) PRO
- [Bar chart](/docs/components/bar-chart) PRO
- [Event calendar](/docs/blocks/event-calendar) PRO
- [Gauge chart](/docs/components/gauge-chart) PRO
- [Heatmap](/docs/components/heatmap-chart) PRO
- [Line chart](/docs/components/line-chart) PRO
- [Radar chart](/docs/components/radar-chart) PRO
- [Radial chart](/docs/components/radial-chart) PRO
- [Sparkline](/docs/components/sparkline) PRO
- [Stats row](/docs/blocks/stats-row) PRO
- [Timeline](/docs/blocks/timeline) PRO

## Files

```text
fitness/
├── hooks/
│   └── useFitness.ts
├── ClassesScreen.tsx
├── fitness.constants.ts
├── fitness.utils.ts
├── FitnessApp.tsx
├── FitnessProfileScreen.tsx
├── FitnessProgressScreen.tsx
├── index.ts
├── SessionScreen.tsx
├── SetupScreen.tsx
├── TodayScreen.tsx
├── TrainScreen.tsx
└── WorkoutScreen.tsx
```

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

## A look at the code

The workout clock and heart-rate zones, from `fitness.utils.ts`:

```tsx
/** Seconds as a clock: 75 is "1:15", 3725 is "1:02:05". */
export const clock = (seconds: number) => {
  const s = Math.max(0, Math.floor(seconds));
  const h = Math.floor(s / 3600);
  const m = Math.floor((s % 3600) / 60);
  const pad = (n: number) => String(n).padStart(2, '0');
  return h ? `${h}:${pad(m)}:${pad(s % 60)}` : `${m}:${pad(s % 60)}`;
};

/** The heart-rate zone for a beat, from a max heart rate: 1 easy to 5 all out. */
export const heartZone = (bpm: number, max = 190) => {
  const r = bpm / max;
  return r < 0.6 ? 1 : r < 0.7 ? 2 : r < 0.8 ? 3 : r < 0.9 ? 4 : 5;
};
```

Get the source with Pro
