I am making an application in which I want to filter an array of workout data more times.
I used to do it by the help of filter, map, for loop in UIKit, but in SwiftUI no luck.
List {
if workoutsModel.workoutsAreFiltered {
ForEach(workoutsModel.workoutsFilter) { workoutFilter in
if workoutFilter.isOn {
ForEach(self.workoutsModel.workout) { workout in
if workoutFilter.name == workout.goal || workout.muscles.contains(workoutFilter.name) {
WorkoutsRow(workout: workout)
}
}
}
}
} else {
ForEach(self.workoutsModel.workout) { workout in
WorkoutsRow(workout: workout)
}
}
}