I am trying to apply multiple filters to a struct in a List.
The following code is the main search control filter:
@State private var includeInactive : Bool = false
@State private var searchText: String = ""
@State private var isEditing = false
List(clientData.Clients.filter({
searchText.isEmpty ? true : $0.fullname.lowercased().contains(searchText.lowercased())
}) ) { ClientLimited in
The code for the search filter works fine.
The question is, how do I add query elements. I want to also filter this list on an element called inactive from the includeInactive Bool, which is set by a toggle.
I can change the filter as follows:
@State private var includeInactive : Bool = false
List(clientData.Clients.filter({
includeInactive == true ? true : $0.inactive == false
}) ) { ClientLimited in
This filters the data correctly for the inactive control.
How do you add both of these into one filter?