What's happening here is when I select the View Results button, a .sheet screen is presented which shows some results. I have two if statements, one after the other, where I believe this is where my problem lies.
Both of these toggles, Medicare & Disability reflect these two if statements in the code below.
If seems to me that since the if ssdiElig
statement, is below the if elig
statement, I'm unable to see the results from toggling JUST the Disability button.
I've tried putting these two if statements in their own functions but that didn't work well and created many errors. My question is, is there a better way to put this code together so if I select the Disability button without interacting with the Medicare button, the Disability if statement will run on it's own
ZStack {
VStack {
Button(action: {mspEligibility(); ssdiEligibility(); ssiEligibility(); mspEligibility2(); PAzipcode(); mspEligibility3()
self.isOpen = true
print(elig)
print(ssdiElig)
}, label: {
Text("View Results")
}).sheet(isPresented: $isOpen, content: {
if elig == true {
ZStack {
RoundedRectangle(cornerRadius: 25)
.fill(Color.white)
.frame(width: 375, height: 125)
.shadow(color: Color.black.opacity(0.5), radius: 10, x: 10, y: 10)
.shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)
HStack {
Text("Eligible for MSP")
.font(.headline)
.padding(60)
Image(systemName: "face.dashed")
.resizable()
.frame(width: 60, height: 60)
.padding(7)
}
}
} else {
Text("")
}
if ssdiElig == true {
ZStack {
RoundedRectangle(cornerRadius: 25)
.fill(Color.white)
.frame(width: 375, height: 125)
.shadow(color: Color.black.opacity(0.5), radius: 10, x: 10, y: 10)
.shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)
HStack {
Text("Eligible for SSDI")
.font(.headline)
.padding(60)
Image(systemName: "face.dashed")
.resizable()
.frame(width: 60, height: 60)
.padding(7)
}
}
} else {
Text("")
}
})