Template · Health
Sleep App SwiftUI Template
Drift, a sleep and recovery companion for a smart ring: a complete Xcode project with pairing, daily readiness, sleep stages, trends, widgets and three brand presets. 14 screens and 4 flows in Drift, as a SwiftUI app template.
A sleep and recovery app on four tabs. First run pairs the ring on a turning dial, sets a bedtime goal, asks for wind-down reminders and an account (Sign in with Apple, or continue without one) and hands off to a StoreKit 2 paywall. Today pages through daily scores on a tilted card rail with a tick dial; Sleep reads last night's stages; Trends shows the weeks; Profile holds the ring, bedtime reminders, the subscription and sign out.
- SwiftUI
- iOS 17.0+
- Xcode project 1.0.0
- sleep-app
$199 once, every piece included. See how installing works · Sign in
01
Flows
Complete journeys through Drift, from first launch to sign out, screen by screen. Open one to play it, or choose any screen to start there.
The first 3 steps of every flow are open. Pro opens every screen of every template, live in each style, and the SwiftUI to build them.
01 · Onboarding
First Run
From the welcome through pairing the ring, a bedtime goal, reminders, an account and Drift Plus to this morning's readiness.
7 Screens14 Steps02 · Core Journey
Morning Readiness
Read today's scores on the card rail, turn back through the fortnight and open what moved a score.
2 Screens8 Steps03 · Core Journey
Nights And Trends
Scrub last night's stages, step back a night, sync the ring and read the weeks in Trends.
2 Screens8 Steps04 · Profile And Settings
Profile And Settings
The subscription, the ring, a new bedtime goal, the theme, the widget gallery and signing out back to the welcome.
5 Screens12 Steps02
Screens
Every screen in Drift, 14 in all, each a SwiftUI view in the Xcode project. In Frost, Velvet and Graphic, light and dark.
First run
Welcome, permissions and the questions that set the app up.
- Welcome
Drift opens on its ring drawn over a score card's arc, with one line on what the ring and the morning score do.
Built onReadiness
- Pair Your Ring
Pair the ring on the tick dial, whose ticks fill as it bonds, through a designed drop-out and a retry.
Built onReadiness
- Set A Bedtime
Turn the dial through quarter hours to set a bedtime goal, with the wake time it implies under the figure.
Built onReadiness
- Wind-Down Reminders
Allow one quiet reminder thirty minutes before bed, shown as it lands on the Lock Screen.
Account and subscription
Sign in, verification and the paywall.
- Sign In
Sign in with Apple to back up your sleep history, or continue without an account.
- Drift Plus
Start Drift Plus on a yearly plan with a fourteen-day trial, or pick monthly.
Tabs
Where the app opens, one screen per tab.
- Today
Read the morning's scores on a tilted card rail and turn the dial under it through the last fourteen days.
Built onReadiness
- Sleep
Scrub last night's stages on the timeline, step through the week's nights and pull down to sync the ring.
Built onSleep
- Trends
See the weeks as stage columns, the share of nights on your bedtime goal, HRV, resting heart rate and insights.
Details and sheets
What the tabs push and present.
- Score Detail
See what moved a score as capsule bars, and the last seven nights with this one lit.
Built onReadiness
Profile and settings
The account, preferences, the subscription and sign out.
- Profile
Manage the subscription, the ring, the bedtime goal and reminders, Apple Health, the theme, and sign out.
Built onSettings
- Bedtime Goal
Pick a new bedtime goal from half-hour times between 9:30 PM and 12:30 AM.
Built onSettings
- Theme
Switch between Drift's Frost, Velvet and Graphic presets and set the appearance.
- Widget Gallery
Review the Readiness and Last Night widgets at their real sizes, from Profile in debug builds.
Built onReadiness
03
Built from the library
The library screens this template wires together, in the order someone meets them. Each one installs on its own too.
First run
Welcome, ring pairing on the dial, a bedtime goal, reminders, Sign in with Apple (or continue without an account) and the StoreKit 2 paywall. Runs once, then records completion.
Tabs
Today, Sleep, Trends and Profile. Today is the Readiness rail; Sleep is the night's stage timeline.
04
What's included
SwiftUI source you own, built on Apple frameworks only.
- Ring pairing and a bedtime goal set on a turning dial
- Daily readiness, sleep and recovery scores on a tilted card rail
- Last night's stages on a scrubbable timeline
- Weekly trends with capsule columns and a goal figure
- Readiness and Last Night widgets
- Three presets: Frost, Velvet and Graphic
05
Implementation notes
How it behaves, what it handles, and the decisions behind it.
SleepApp is one root view. On first launch it runs Drift's own first run: a welcome with the ring drawn over the score card's arc, pairing the ring on the Readiness screen's tick dial (the ticks fill as it pairs), a bedtime goal you set by turning the same dial, then the Purchase screen's StoreKit 2 paywall. Closing, purchasing or restoring finishes onboarding and records it under a completion key, so the root switches to the home on its own.
There is no tab bar. Three round floating buttons carry the app: Sleep on the left, a capsule for Today and Trends in the middle, Profile on the right. Today is the Readiness screen: Sleep, Readiness, Recovery and Balance cards on a tilted rail, with the dial underneath turning through the last fourteen days. Sleep is the Sleep screen: last night as a stepped stage timeline you scrub, with stage totals as capsule bars. Trends stacks each night's stages into capsule columns and sets the share of nights on goal as a giant figure over a grid of dots. Profile is Settings, with sign out back to first run.
Adapting it
- Products: pass your App Store Connect ids as
productIDs. Until they exist, the paywall shows its designed "plans didn't load" state and its close button still finishes onboarding. - Your ring: nights and scores come from
DriftSampleat the top ofSleepApp.swift. Map your ring SDK's or HealthKit's samples to[SleepSegment]per night and your scores toReadinessDay. - Pairing:
SleepAppPairStep.pair()simulates the ring. Call your SDK's discovery and bonding there and drive the dial'sprogressfrom it. - Theme: everything follows the theme you set on
SleepApp. Without a brand it wears Drift Frost;SPBrandTheme(.driftVelvet)or.driftGraphicre-skin every destination, including the cards, stage colours and motif.
The Xcode project
The download is a complete project on Tuist: SwiftData nights behind a repository protocol; sleep, recovery, balance and readiness scored against a seven-night baseline, with the contributors behind each; pairing with a designed failure and retry; a bedtime goal and wind-down reminders; an account step before the paywall, with Sign in with Apple or continue without an account; loading, no data and error states on Sleep; Trends by week and month; Readiness and Last Night widgets; three presets; unit tests and a first-run UI test.
Notes
- Not
@main: putSleepApp()in your ownWindowGroup. - Enable the In-App Purchase capability before testing purchases. A real ring also needs Bluetooth usage strings, and Apple Health the HealthKit capability.
- Drift's scores are sample math for general wellness, not medical readings.
- Previews ship with the file: first run, home, and home in each Drift preset.
06
Keep building
Pieces that work well next to this one.