WIP
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
struct AddExerciseView: View {
|
||||
@State var exercises: [ExerciseExercise]?
|
||||
@@ -17,6 +18,8 @@ struct AddExerciseView: View {
|
||||
@State var selectedEquipment = [Equipment]()
|
||||
@State var filteredExercises = [ExerciseExercise]()
|
||||
|
||||
@State var searchString: String = ""
|
||||
|
||||
@EnvironmentObject var bridgeModule: BridgeModule
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
@@ -101,15 +104,23 @@ struct AddExerciseView: View {
|
||||
}.frame(height: 100)
|
||||
}
|
||||
|
||||
TextField("Filter", text: $searchString)
|
||||
.onReceive(Just(searchString)) { location in
|
||||
filterExercises()
|
||||
}
|
||||
.padding()
|
||||
|
||||
List() {
|
||||
ForEach(filteredExercises.indices, id: \.self) { i in
|
||||
let obj = filteredExercises[i]
|
||||
VStack {
|
||||
Text(obj.name)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Text(obj.side)
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
if obj.side.count > 0 {
|
||||
Text(obj.side)
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
Text(obj.equipmentRequired)
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -117,6 +128,7 @@ struct AddExerciseView: View {
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
selectedWorkout(obj)
|
||||
dismiss()
|
||||
@@ -172,7 +184,11 @@ struct AddExerciseView: View {
|
||||
}
|
||||
}
|
||||
|
||||
return hasCorrectMuscles && hasCorrectEquipment
|
||||
if !searchString.isEmpty {
|
||||
return exercise.name.contains(searchString) && hasCorrectMuscles && hasCorrectEquipment
|
||||
} else {
|
||||
return hasCorrectMuscles && hasCorrectEquipment
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user