add ActiveWorkoutSession logic, refactor Home, add additional sample data, add isDebug

This commit is contained in:
Felix Förtsch
2024-09-14 17:01:20 +02:00
parent f45d6288dd
commit 0a400ff349
27 changed files with 710 additions and 189 deletions

View File

@@ -6,12 +6,20 @@
//
import SwiftUI
import SwiftData
// Maybe: https://github.com/LeoNatan/LNPopupController/tree/master
// TODO:The Miniplayer is the same view that we use for the Live Activity
// .safeAreaInset(edge: .bottom) { }
struct MiniPlayer: View {
@Default(\.isWorkingOut) var isWorkingOut
@Default(\.activeWorkoutId) var selectedWorkoutId
// @Query private var workouts: [Workout]
@State private var isFullScreenCoverPresented = false
@State private var workout = Workout.sampleData
@State private var workoutSession: WorkoutSession?
var body: some View {
Group {
@@ -31,7 +39,7 @@ struct MiniPlayer: View {
Button(action: {
withAnimation() {
// TODO: This button has to do something with the workout (pause it, next exercise, etc)
isWorkingOut.toggle()
}}) {
Image(systemName: "pause.circle.fill")
.font(.title)
@@ -43,7 +51,7 @@ struct MiniPlayer: View {
}
.buttonStyle(.plain)
.fullScreenCover(isPresented: $isFullScreenCoverPresented) {
ActiveWorkoutSession(workout: workout)
// ActiveWorkoutSession(workout: workout, workoutSession: workoutSession)
}
} else {
Button(action: {
@@ -53,7 +61,7 @@ struct MiniPlayer: View {
Text("Start Workout")
.font(.headline)
// TODO: Replace this with the upcoming/planned workout
Text("→ Recommended Routine")
Text(selectedWorkoutId)
.font(.subheadline)
.foregroundColor(.secondary)
}
@@ -61,7 +69,11 @@ struct MiniPlayer: View {
Button(action: {
withAnimation() {
// TODO: This button "quick starts" the workout (skips over the ActiveWorkoutSession fullscreen cover)
isWorkingOut.toggle()
// if let workoutId = selectedWorkoutId {
// If you selectedWorkoutId is set, get the corresponding workout. This idea is generally okay, but feels off (DRY?)
// workout = workouts.filter({ $0.id == UUID(uuidString: workoutId) }).first
// }
}}) {
Image(systemName: "play.circle.fill")
.font(.title)
@@ -73,7 +85,7 @@ struct MiniPlayer: View {
}
.buttonStyle(.plain)
.fullScreenCover(isPresented: $isFullScreenCoverPresented) {
ActiveWorkoutSession(workout: workout)
// ActiveWorkoutSession(workout: workout, workoutSession: workoutSession)
}
}
}
@@ -83,7 +95,7 @@ struct MiniPlayer: View {
.cornerRadius(12)
.shadow(radius: 10)
.padding(.horizontal)
.padding(.bottom, 65)
// .padding(.bottom, 65)
}
}