Let say I have a SwiftUI component and I want it to change color according to a parameter I choose like :
Component(colorValue: "1")
Component(colorValue: "2")
Component(colorValue: "3")
colorValue: 1 would change the color of my component to red, 2 to green, 3 to blue for example.
When I only had 2 colors in the beggining of my project I used a boolean in my component :
Rectangle().fill(Color(colorValue ? "red" : "blue"))
But now that I have multiple choice, how can I achieve the color change by checking the value of the colorValue String ?
Thanks in advance !