create ER diagram, refactor to conform to diagram, simplify session management

This commit is contained in:
Felix Förtsch
2024-10-17 14:41:14 +02:00
parent b7f5caf9dd
commit 97ecbcc6f4
23 changed files with 394 additions and 226 deletions
+28 -8
View File
@@ -14,6 +14,8 @@ struct ContentView: View {
@Default(\.isOnboarding) var isOnboarding
@Default(\.isWorkingOut) var isWorkingOut
@State var activeWorkoutSession: WorkoutSession?
var body: some View {
NavigationStack {
List {
@@ -42,9 +44,14 @@ struct ContentView: View {
// .frame(height: 200)
}
}
Section {
NavigationLink(destination: ActiveWorkoutSession()) {
if (isWorkingOut) {
// MARK: Workout Controls
if let activeWorkoutSession {
Section {
NavigationLink(
destination: ActiveWorkoutSession(
activeWorkoutSession: $activeWorkoutSession,
activeWorkout: activeWorkoutSession.workout)
) {
HStack {
Label("Back to Session", systemImage: "memories")
.symbolEffect(.rotate)
@@ -52,14 +59,25 @@ struct ContentView: View {
.font(.subheadline)
.foregroundStyle(.secondary)
}
} else {
Label("Start Workout Session", systemImage: "play")
}
ActiveWorkoutSessionControls(
session: Binding(
get: { self.activeWorkoutSession! },
set: { self.activeWorkoutSession = $0 }
))
}
} else {
Section(footer: Text("Starts the next planned workout immediately.")) {
Label("Quick Start", systemImage: "play")
}
}
Section {
NavigationLink(destination: WorkoutLog()) {
Label("Workout Log", systemImage: "calendar.badge.clock")
}
NavigationLink(destination: WorkoutLibrary()) {
NavigationLink(destination: WorkoutLibrary(activeWorkoutSession: $activeWorkoutSession)) {
Label("Workouts", systemImage: "figure.run.square.stack")
}
NavigationLink(destination: ExerciseLibrary()) {
@@ -67,9 +85,11 @@ struct ContentView: View {
}
}
Section {
Label("Add Food", systemImage: "plus")
Label("Food Log", systemImage: "list.bullet.clipboard")
Label("Food Library", systemImage: "fork.knife")
NavigationLink(destination: Label("Add Food", systemImage: "plus")) {
Label("Food Library", systemImage: "fork.knife")
}
}
Section {
NavigationLink(destination: Settings()) {