if else Help

I am looking for a way to just change the color in an if statement. Is that possible or is the code below the best or the only way to do this?


                Section(header: Text("Detail Sections Verification")) {
                    if order.specialRequestEnabled {
                        Text("Information Verified")
                            .color(.green)
                            .frame(minWidth: 0, maxWidth: .infinity,
                                   alignment: .center)
                    } else {
                        Text("Information Not Verified")
                            .color(.red)
                            .frame(minWidth: 0, maxWidth: .infinity,
                                   alignment: .center)
                    }

                    Toggle(isOn: $order.specialRequestEnabled) {
                        Text("Set if all data is verified")
                    }
                    
                 }

Accepted Reply

Try

.color(order.specialRequestEnabled ? .green : .red)

Replies

Try

.color(order.specialRequestEnabled ? .green : .red)

Thank you very much. Answers here are very valuable to a beginner like myself.