I have a small Question about SwiftUI and programming for Darkmode. I am programming in swift for like 4 month by now and I want to start programming for Dark Mode and Light Mode.
In SwiftUI there are a few methods to Color something, for example a Text. If I want to color the Foreground from the Text Green there are the following ways to do it (correct me if I am wrong):
.foregroundColor(.green)
.foregroundColor(Color.green)
.foregroundColor(Color(UIColor.green))
.foregroundColor(Color(UIColor.systemGreen)) <- I usually do this
In Light Mode, this works, but if I switch to dark Mode, some of my Components are colored differently, for Example if I have a black foreground, this foreground is now white. But with some other Components, its black.
Can you guys give me an Example how I should properly program for Darkmode? Which of these 4 Methods above should I use? Or is there a different way? Or do you have other Tips for Coloring Fore- and Background with SwiftUI?
Note: I am not trying to find a Solution for a specific Problem, I just want to understand how all of the Colors and different Methods of coloring works in SwiftUI. I already Googled stuff but didn't find something that I understood, so I try my luck here :D