|
I was working on the first challenge listed here: https://www.hackingwithswift.com/books/ios-swiftui/views-and-modifiers-wrap-up "Go back to project 1 and use a conditional modifier to change the total amount text view to red if the user selects a 0% tip." I was able to make it work using Below is my code:
|
|
Ian has a doubt about his approach:
Well done. It's great you're taking a critical look at your solution and asking questions. @twoStraws challened you to apply a conditional modifier. I think you applied procedural logic, instead. Remember! SwiftUI is a declarative language. You should think about DECLARING what you want your user to see. In this case, make a declaration:
In a procedural language you might add conditionals:
|
|
Thanks, I knew it should be something like that just couldn't put my head around how to do it. For anyone else looking your playground example also needs to
|
SPONSORED AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.