add always sorted [WorkoutItem], ContentUnavailableView to searches, SampleData import, refactor WorkoutItem init
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// 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())
|
||||
}
|
||||
ProgressView("",
|
||||
value: session.getCurrentExerciseIndex() + 1,
|
||||
total: session.getTotalExerciseCount()
|
||||
)
|
||||
HStack {
|
||||
Button(action: {
|
||||
session.prevExercise()
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "backward.end.fill")
|
||||
Text("Prev")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.bold()
|
||||
.tint(.primary)
|
||||
Button(action: {
|
||||
// TODO: Implement proper Pausing
|
||||
session.pause()
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "pause.fill")
|
||||
Text("Pause")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.bold()
|
||||
.tint(.gray)
|
||||
.disabled(true)
|
||||
Button(action: {
|
||||
session.nextExercise()
|
||||
}) {
|
||||
HStack {
|
||||
Text("Next")
|
||||
Image(systemName: "forward.end.fill")
|
||||
}
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.bold()
|
||||
.tint(.primary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview("isWorkingOut = true") {
|
||||
@Previewable @State var activeWorkoutSession = WorkoutSession()
|
||||
activeWorkoutSession.workout = 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
|
||||
}
|
||||
}
|
||||
|
||||
#Preview("isWorkingOut = false") {
|
||||
@Previewable @State var activeWorkoutSession = WorkoutSession()
|
||||
|
||||
return ActiveWorkoutSessionControls(session: $activeWorkoutSession)
|
||||
.onAppear() {
|
||||
Defaults.shared.isWorkingOut = false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user