// // ActiveWorkoutSessionControls.swift // WorkoutsPlus // // Created by Felix Förtsch on 16.09.24. // import SwiftUI struct ActiveWorkoutSessionControls: View { @Binding var session: WorkoutSession var body: some View { VStack { HStack { Text(session.getCurrentTodo()) .font(.system(size: 24, weight: .bold, design: .rounded)) } ProgressView("", value: session.getCurrentExerciseIndex(), total: session.getTotalExerciseCount() - 1 ) HStack { Button(action: { session.prevExercise() }) { HStack { Image(systemName: "backward.end.fill") Text("Prev") } } .buttonStyle(.borderedProminent) .fontWeight(.bold) .tint(.primary) Button(action: { // TODO: Implement proper Pausing session.isPaused = true }) { HStack { Image(systemName: "pause.fill") Text("Pause") } } .buttonStyle(.borderedProminent) .fontWeight(.bold) .tint(.gray) .disabled(true) Button(action: { session.nextExercise() }) { HStack { Text("Next") Image(systemName: "forward.end.fill") } } .buttonStyle(.borderedProminent) .fontWeight(.bold) .tint(.primary) } } } } #Preview("isWorkingOut = true") { @Previewable @State var activeWorkoutSession = WorkoutSession(start: Workout.sampleData.first!) // For some reason the return keyword is required here to avoid the error "Type of expression is ambiguous without a type annotation" return ActiveWorkoutSessionControls(session: $activeWorkoutSession) .onAppear() { Defaults.shared.isWorkingOut = true } }