with this code I fill the list
struct RisultatiRicercaNominativo: View {
@EnvironmentObject var ricerca: Ricerca
let elettore: Elettore
var ricercaPrecisa :Array = [String]()
var ricercaarrey = [ArrayAny]()
var body: some View {
VStack {
navRitorno()
.background(Color.blue)
List {
ForEach(elettori) { item in
// CASO NOME PIENO E COGNOME PIENO
if ricerca.nome != "" && ricerca.cognome != "" {
if String(item.cognome).contains(ricerca.cognome.uppercased()) && String(item.nome).contains(ricerca.nome.uppercased()){
ElettoreSingoloView(elettore: item)
.padding(.horizontal, 20)
} else {
EmptyView()
}
} //End if
// CASO NOME VUOTO E COGNOME PIENO
if ricerca.nome == "" && ricerca.cognome != "" {
if String(item.cognome).contains(ricerca.cognome.uppercased()) {
ElettoreSingoloView(elettore: item)
.padding(.horizontal, 20)
} else {
EmptyView()
}
} //End if
} //END LOOP
} //LIST
.listStyle(InsetGroupedListStyle())
I can see the list filled in any case.
With this button I return to the content view:
Button(action: {
ricerca.cognome = ""
ricerca.nome = ""
ricerca.sezione = ""
ricerca.indirizzo = ""
ricerca.isResult = false
// }
}, label: {
Image(systemName: "chevron.left")
.font(.title)
.foregroundColor(.white)
})
If the json file contains 1000 record all is ok :(