introduce WorkoutItem, refactor ExerciseTemplate to Exercise
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user