77 lines
2.0 KiB
Swift
77 lines
2.0 KiB
Swift
//
|
|
// DebugList.swift
|
|
// WorkoutsPlus
|
|
//
|
|
// Created by Felix Förtsch on 30.08.24.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SwiftData
|
|
|
|
struct DebugList: View {
|
|
@Environment(\.modelContext) private var modelContext
|
|
|
|
@Query(sort: \Exercise.name) private var exercises: [Exercise]
|
|
@Query(sort: \Workout.name) private var workouts: [Workout]
|
|
@Query(sort: \WorkoutItem.name) private var workoutItems: [WorkoutItem]
|
|
@Query(sort: \WorkoutSession.name) private var workoutSessions: [WorkoutSession]
|
|
|
|
var body: some View {
|
|
List {
|
|
Button(action: {SampleData.insertSampleData(into: modelContext)} ) {
|
|
Text("Insert Sample Data")
|
|
}
|
|
Section(header: Text("Exercises")) {
|
|
ForEach(exercises) { exercise in
|
|
DebugListItem(item: exercise)
|
|
}
|
|
}
|
|
Section(header: Text("Workouts")) {
|
|
ForEach(workouts) { workout in
|
|
DebugListItem(item: workout)
|
|
}
|
|
}
|
|
Section(header: Text("WorkoutItems")) {
|
|
ForEach(workoutItems) { workoutItem in
|
|
VStack(alignment: .leading) {
|
|
Text("\(workoutItem.name), pos: \(workoutItem.position), reps: \(workoutItem.plannedReps)")
|
|
Text(workoutItem.id.uuidString)
|
|
.font(.system(size: 12, weight: .bold))
|
|
.fontDesign(.monospaced)
|
|
.foregroundStyle(.gray)
|
|
}
|
|
}
|
|
}
|
|
Section(header: Text("Workout Sessions")) {
|
|
ForEach(workoutSessions) { workoutSession in
|
|
DebugListItem(item: workoutSession)
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("Debug")
|
|
.tabItem {
|
|
Image(systemName: "wrench")
|
|
Text("Exercise Debug")
|
|
}
|
|
}
|
|
}
|
|
|
|
struct DebugListItem: View {
|
|
var item: any Nameable
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
Text(item.name)
|
|
Text(item.id.uuidString)
|
|
.font(.system(size: 12, weight: .bold))
|
|
.fontDesign(.monospaced)
|
|
.foregroundStyle(.gray)
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
DebugList()
|
|
.modelContainer(SampleData.shared.modelContainer)
|
|
}
|