feat(watch): add lap detection via accelerometer and workout sync to phone
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import SwiftUI
|
||||
|
||||
struct WorkoutDetailView: View {
|
||||
@ObservedObject var workoutManager: WorkoutManager
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
if let workout = workoutManager.selectedWorkout {
|
||||
Section {
|
||||
VStack(spacing: 8) {
|
||||
Text(workout.name ?? "Workout")
|
||||
.font(.headline)
|
||||
|
||||
Text("\(Int(workout.poolLength))m pool")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text("\(workout.sets.reduce(0) { $0 + $1.distancePerRep * $1.repCount })m total")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
|
||||
Section("Sets") {
|
||||
ForEach(Array(workout.sets.enumerated()), id: \.offset) { i, set in
|
||||
HStack {
|
||||
Text("\(i + 1). \(set.stroke)")
|
||||
.font(.body)
|
||||
Spacer()
|
||||
Text("\(set.repCount)x\(set.distancePerRep)m")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
Button {
|
||||
workoutManager.startWorkout()
|
||||
} label: {
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(systemName: "play.fill")
|
||||
Text("Start")
|
||||
.font(.headline)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.tint(.cyan)
|
||||
|
||||
Button("Back") {
|
||||
workoutManager.selectedWorkout = nil
|
||||
}
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
.listStyle(.automatic)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user