Posts

Post not yet marked as solved
2 Replies
2.1k Views
Let's say I create a "SwiftUI View" file called "Test"Then let's modify the PreviewProvider section to look like this:#if DEBUG struct Test_Previews : PreviewProvider { static var previews: some View { Group { Test() Test() .environment(\.colorScheme, .dark) } } } #endifNow when I look at my preview, I notice that the Text color is different for the Light and the Dark mode, but the background color does not change by default. So the text on the Dark Mode Version will not show up since it is white on white.If I take my main section of code and then wrap the Text view in a List View like this:struct Test : View { var body: some View { List(/0 ..< 5/) { item in Text(/"Hello World!") } } }then it handles changing the background color of the list to be black in dark mode so the white text shows up properly.My question is: Do we have to check manually to see if the mode is Light or Dark to change the Background color in code? Or is there a native container view to wrap the Text in this case inside that will handle changing the background color without having to put it in a List View?Thanks,Dave
Posted
by David4FSU.
Last updated
.