Real life traffic light in Xcode (SwiftUI)

Hi good people of the internet.

What's the best approach to code a logic of a real life traffic light in Xcode using SwiftUI? Any repos on GitHub / code snippets / tips / etc.

Don't look or code to just paste. Why don't you try it on your own ? It is a really interesting task.

Some hints:

  • create a view for a traffic light (may be in several flavours: horizontal, vertical)
  • Create a view for the crossraod and the traffic lights
  • Create a model of the traffic light, with notably : its status, the action to turn to a new color, the timing for light change (how much time on orange for instance), specific behaviours as flashing on orange…
  • Create a model of the crossroad: how many traffic lights, logic to switch each traffic light…

Good luck.

Note: you tagged your post as Swift. Should have been SwiftUI (you would access to more of expert people in SwiftUI).

@Claude31 Hello. Thank you very much for your reply. Well, hard luck that I can't add a new tag when a post is created.

Real life traffic light in Xcode (SwiftUI)
 
 
Q