In main app, I can override dark/ light theme based on user preference, so that I can retrieve correct color information based on named color.
if (user preference) {
overrideUserInterfaceStyle = .light
} else {
overrideUserInterfaceStyle = .dark
}
// Dark theme/ light theme automatic aware color.
SwiftUI.Color("purpleColor")
However, how can I override the theme of a WidgetKit, so that my WidgetKit can interpret named color correctly?
I know in WidgetKit, I can read what is current system wide theme settings using
@Environment(\.colorScheme)
But, that is not what I want.
I want the ability to override theme of a WidgetKit based on user preference, then able to retrieve correct named color.
Thanks.