try? it out
import SwiftUI
struct ContentView: View {
// Apple docs:
// https://developer.apple.com/documentation/swiftui/environmentvalues/colorscheme
@Environment(\.colorScheme) var colorScheme
var body: some View {
Text(colorScheme == .dark ? "Dark" : "Light")
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}