Files
rzen f06c4e996e Rework the Apple Watch progress flow
Watch root lists every in-progress workout; picking an exercise runs a paged Ready -> work/rest -> Finish flow (One More + auto-firing Done), with a phase-dot row and brand-tinted count-up/down timers. Includes the configurable rest and auto-finish settings synced over WatchConnectivity and the wrist-down timer fix.
2026-06-20 14:15:31 -04:00

34 lines
1.1 KiB
Swift

//
// WatchAppDelegate.swift
// Workouts Watch App
//
// Copyright 2025 Rouslan Zenetl. All Rights Reserved.
//
import SwiftUI
import WatchKit
import HealthKit
/// Bridges watchOS lifecycle into the workout session. When the phone starts a workout
/// it calls `startWatchApp(toHandle:)`; watchOS launches (or foregrounds) this app and
/// delivers the configuration to `handle(_:)`, where we start a session to claim
/// foreground runtime. The session manager is shared with the view tree via the
/// environment (see `WorkoutsWatchApp`).
@MainActor
final class WatchAppDelegate: NSObject, WKApplicationDelegate {
let sessionManager = WorkoutSessionManager()
func applicationDidFinishLaunching() {
#if DEBUG
// The screenshot harness renders fixed screens don't pop the Health auth
// dialog over them (it would also leak into App Store captures).
if ScreenshotSeed.isActive { return }
#endif
sessionManager.requestAuthorization()
}
func handle(_ workoutConfiguration: HKWorkoutConfiguration) {
sessionManager.start(with: workoutConfiguration)
}
}