Hi,
I have this code to change my background color based on the enum AddressType
enum AddressType: String, CaseIterable{
case shipFrom = "1"
case shipTo = "2"
case unknown = "999"
init(type: String) {
switch type {
case "1": self = .shipFrom
case "2": self = .shipTo
default: self = .unknown
}
}
var text: String {
switch self {
case .shipFrom: return "Ship From"
case .shipTo: return "Ship To"
case .unknown: return "N/A"
}
}
}
.background(addressType.self == AddressType.shipFrom ? Color.green : Color.yellow)
Question is now: what do I have to do if I want my shipFrom in Color.green and my shipTo in Color.orange? I have tried adding a 2nd .background() for the shipTo but that did not work.
Is there any way to work with more than 1 IF clause?
Max