Hi Team, I would like to combine or mix and match two filter
here is the code but seems like I cannot do what I want... I want to be able to show only what the filter is made for so if TECO and favorite is active then I would only see favourite and not TECO project , and if TECO is not active but favourite is active then it will only show all favourite project and if TECO is active it will only show all project which are not TECO regardless if they are favortie
import SwiftUI
struct ProjectList: View {
@State private var showTecoOnly = false
@State private var showFavoriteOnly = false
var filteredTECOProjects: [Project] {
projects.filter { project in
(!showTecoOnly || !project.isTeco)
}
}
var filteredProjects: [Project] {
projects.filter { project in
(!showFavoriteOnly || project.isFavorite)
}
}
var body: some View {
NavigationSplitView {
List {
Toggle(isOn: $showTecoOnly) {
Text("Hide TECO")
}
Toggle(isOn: $showFavoriteOnly) {
Text("Show Favorite")
}
ForEach (filteredTECOProjects ) && ForEach (filteredProjects ) { project in
NavigationLink {
ProjectDetail(project: project)
} label: {
ProjectRow(project: project)
}
}
Divider()
}
.animation(.default, value: filteredTECOProjects)
.navigationTitle("PROJECTS")
} detail: {
Text("Select a project")
}
}
}
#Preview {
ProjectList()
}