Button w/ condition on .sheet is not working

I have a button which is connected to a presented .Sheet when pressed which has simple if/else statement inside. However, when this particular Bool ssdiElig is true it still registers as false on the view.

Here is my button code and below that the function that gives me the ssdiElig value (bool) for the .sheet if/else statement.

                ZStack {
                    VStack {
                        Button(action: {mspEligibility(); ssdiEligibility(); ssiEligibility(); mspEligibility2(); PAzipcode(); mspEligibility3();
                            self.isOpen = true
                            print(ssdiElig)
                        }, label: {
                            Text("View Results")
                        }).sheet(isPresented: $isOpen, content: {
                            if ssdiElig {
                            Text("ssdi yes")
                            } else {
                            Text("ssdi no")
                            }
                        }
                    )}

This function will give ssdiElig Bool the value

   func ssdiEligibility() {
        if disabled == true && income <= 803 {
            print("SSDI Eligible")
            ssdiElig = true
        } else if ssdiBen == true || ssiBen == true {
            print("Not SSDI Eligible")
            ssdiElig = false
        } else {
            print("Not SSDI Eligible")
            ssdiElig = false
        }
    }

Inside the console, ssdiElig prints out true. Also, SSDI Eligible is printed out as well.

So, to me, its just the if statement that isn't working for some reason?

Could you explain precisely the sequence of events:

When you start app

  • what is the value of ssdiElig and isOpen
  • what do you get on screen (all the Text)
  • what do you get on console

Is it what you expect ?

Once you tap "View Results" button:

  • what does print(ssdiElig) print ?
  • what do you get on screen (all the Text): is sheet presented ?
  • what do you get on console

What'd did you expect ?

Could you also test a simplified version of action:

     Button(action: {
           ssdiEligibility()
           self.isOpen = true
           // Keep what comes next

Does it works ?

Button w/ condition on .sheet is not working
 
 
Q