• Sjmarf@sh.itjust.works
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    4 months ago

    One option would be to use an enum with a label computed property.

    enum TransitionState {
        case stageOne, stageTwo, stageThree
    
        var label: String {
            switch self {
                 case .stageOne: "Stage one!"
                 case .stageTwo: "Stage two!"
                 case .stageThree: "Stage three!"
            }
        }
    }
    
    struct MyView: View {
        @State var transitionState: TransitionState = .stageOne
    
        var body: some View {
            Text(transitionState.label)
        }
    }