[ad_1]
From Results View:
struct ResultsView: View {
@State private var selectedSort : Int = 1
func selectedSorter(selectedSort: Int, results: [Product]) -> [Product]
switch selectedSort {
case 1:
return results
case 2:
return results.sorted(by: { (first, second) -> Bool in
return second.price < first.price
})
Ect....
default:
print("Off")
return results
}
}
var body: some View {
let results = selectedSorter(selectedSort: selectedSort, results: results)
This operation takes time. I am calling it from a .sheet view called FilterView:
struct FiltersView: View {
var progressHide : Bool = true
@Binding var selectedSort:Int
ProgressView("Sorting...please wait").isHidden(progressHide)
Picker("Sort by", selection: $selectedSort) {
Text("Off").tag(1)
Text("Price High to Low").tag(2)
Ect...
}.pickerStyle(.wheel)
}
So my question is, how can I toggle progressHide in the FilterView from Results View to show the ProgressView while the seletedSorter operation happens?
In my case, I am sorting over 5000 results with images involved, it sometimes can take up to 30 seconds of a frozen screen, kinda hurting the UX cause the screen is frozen.
[ad_2]