if(user.reserved == "yes") {
HStack {
Image(systemName: "person.crop.circle.badge.checkmark").foregroundColor(.green)
Text("\(user.name)").foregroundColor(.green)
}
} else if (user.reserved == "no"){
HStack {
Image(systemName: "person.crop.circle.badge.checkmark").foregroundColor(.red)
Text("\(user.name)").foregroundColor(.red)
}
} else if (user.reserved == "waiting") {
HStack {
Image(systemName: "person.crop.circle.badge.checkmark").foregroundColor(.orange)
Text("\(user.name)").foregroundColor(.orange)
}
}
'''
I have this code where I want to change the appearance of the text color based on a user saying yes or no. I tried creating a var like "var color: Color" in the if statements however, it kept saying that it dit not conform to the view. How can I make conditional code effectively instead of having to copy past every thing again and again?