introduce WorkoutItem, refactor ExerciseTemplate to Exercise

This commit is contained in:
Felix Förtsch
2024-09-02 17:17:11 +02:00
parent 22b0ba372e
commit 8e1d3306b9
13 changed files with 149 additions and 142 deletions
+4 -14
View File
@@ -41,23 +41,13 @@ struct WorkoutLibrary: View {
if isAddingWorkout {
// TODO: On tap-out of the text field, it should lose focus
TextField("New Workout", text: $newWorkoutName, onCommit: {
saveWorkout(workout: newWorkout)
save(workout: newWorkout)
})
.textInputAutocapitalization(.words)
.focused($isInputFieldFocused)
}
Button(action: {
if isAddingWorkout {
saveWorkout(workout: newWorkout)
}
addWorkout()
}) {
HStack {
Image(systemName: "plus.circle.fill")
.foregroundStyle(.green)
Text("Add Workout")
}
}
// TODO: When pressing the button again, it should check if something is being added already and if yes, save it.
AddItemButton(label: "Workout", action: addWorkout)
}
.searchable(text: $searchText)
}
@@ -80,7 +70,7 @@ struct WorkoutLibrary: View {
}
// TODO: Brauchen wir das?
private func saveWorkout(workout: Workout) {
private func save(workout: Workout) {
withAnimation {
newWorkout.name = newWorkoutName
if !workout.name.isEmpty {