Get Current Widget Kind

Is there a way to find the current widget kind from a view or static function?

The use case is:

We have a standard text view that is used across two different widgets. However the strings displayed will be different in each widget. How can I find out which widget is using the view at runtime?

Thanks!
You could use a Geometry Reader to calculate the size of the view at runtime.

Look at the section Adapting to Different Screen Sizes
section here: https://developer.apple.com/design/human-interface-guidelines/ios/system-capabilities/widgets/
Hi @appleSince80

The widgets might all be the same size. I need to know which one out of the widget bundle is displaying.
I recreated the iOS 14 weather widget in all size families and had played around with using the environment widgetFamily but this only helps if you're wanting to reuse views across a single widget type. Notes and Reminders both have two different widgets and without official support of an environment value out of the box I'd do something like this.

In your Widget definition, pass something into the parent most view of the hierarchy, then pass it around in properties or even a custom environment variable/object!

Code Block
struct WeatherWidget: Widget {
    let kind: String = "WeatherWidget"
    var body: some WidgetConfiguration {
        IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: WeatherTimelineProvider(), content: { entry in
            WeatherWidgetEntryView(entry: entry, kind: kind)
        })
        .configurationDisplayName("Forecast")
        .description("See the current weather conditions and forecast for a location.")
        .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
    }
}

Get Current Widget Kind
 
 
Q