fix repetitive save of WorkoutItem, add: Onboarding, Defaults, Settings, Trainer/Trainee skeletons, reorder files, remove all Bindable
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// WorkoutDetailsView.swift
|
||||
// WorkoutDetail.swift
|
||||
// WorkoutsPlus
|
||||
//
|
||||
// Created by Felix Förtsch on 10.08.24.
|
||||
@@ -12,8 +12,8 @@ struct WorkoutDetail: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@Environment(\.modelContext) private var modelContext
|
||||
|
||||
@Bindable var workout: Workout
|
||||
@State private var isPresenting = false
|
||||
@State var workout: Workout
|
||||
@State private var isPresentingExerciseLibrary = false
|
||||
|
||||
var body: some View {
|
||||
|
||||
@@ -47,18 +47,17 @@ struct WorkoutDetail: View {
|
||||
EditButton()
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $isPresenting) {
|
||||
NavigationStack {
|
||||
AddWorkoutItemToWorkout(workout: workout)
|
||||
}
|
||||
.presentationDetents([.medium, .large])
|
||||
.presentationDragIndicator(.visible)
|
||||
.sheet(isPresented: $isPresentingExerciseLibrary) {
|
||||
AddWorkoutItemToWorkout(workout: workout)
|
||||
.presentationDetents([.medium, .large])
|
||||
.presentationDragIndicator(.visible)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private func addWorkoutItemToWorkout() {
|
||||
withAnimation {
|
||||
isPresenting = true
|
||||
isPresentingExerciseLibrary = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,3 +91,20 @@ struct WorkoutDetail: View {
|
||||
.modelContainer(SampleData.shared.modelContainer)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview("Debug") {
|
||||
TabView {
|
||||
WorkoutDetail(workout: Workout.sampleData)
|
||||
.tabItem {
|
||||
Image(systemName: "figure.run.square.stack")
|
||||
Text("Workouts")
|
||||
}
|
||||
|
||||
DebugList()
|
||||
.tabItem {
|
||||
Image(systemName: "hammer")
|
||||
Text("Debug")
|
||||
}
|
||||
}
|
||||
.modelContainer(SampleData.shared.modelContainer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user