Is there a way to override the theme of WidgetKit, so that we can retrieve correct named color in WidgetKit?

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.

Widgets live on Springboard and is more likely to follow the interface style of your Home Screen. If you are trying to manually set themes set in your main app, the best course would be to store that in an App Group, reference the values in your Widget and reload them when changes occur. This way the shared data can drive everything.

Rico
WWDR - DTS - Software Engineer

Is there a way to override the theme of WidgetKit, so that we can retrieve correct named color in WidgetKit?
 
 
Q