Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 3177
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 2, 20222022-06-02T04:56:26+00:00 2022-06-02T04:56:26+00:00

swift – In SwiftUI, sorted(by: ) operation triggered from a sheet view, need to show a ProgressView while operation completes

  • 0

[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]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 9 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 11 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 10 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.