alstr
alstr

Reputation: 1554

How to style table view for Widget configuration dynamic values?

I have a functioning Widget configured using IntentConfiguration to allow the user to edit the widget's displayed data.

That part of things works fine. What I'd like to do is to style the table view that is presented when the user is configuring the widget and choosing from one of the dynamically supplied values.

At the moment it looks like:

Widget configuration

I've noticed the Home Assistant app has some different styling:

Widget configuration

It looks like they are setting the view based on certain criteria (see here), but I haven't fully figured out how it works yet. The Apple documentation also seems very sparse on this.

At the moment, I've only defined the view for the actual widget, e.g.:

struct MyWidgetView: View {
    var entry: Provider.Entry

    var body: some View {
        Text(entry.name)
    }
}

@main
struct MyWidget: Widget {
    let kind: String = "MyWidget"

    var body: some WidgetConfiguration {
        IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in
            MyWidgetView(entry: entry)
        }
        .configurationDisplayName("A Widget")
        .description("Displays stuff.")
    }
}

I can supply the configuration list options in my IntentHandler without issue, but how can I adjust the UI?

Upvotes: 2

Views: 685

Answers (1)

Adam
Adam

Reputation: 5145

In your IntentHandler, you return a collection of INObjects (actually you’ll use your project’s generated subclass of INObject, but look at INObject for the API). When you create those objects, you can pass in an image and/or subtitle, which is what you’re seeing in that screenshot.

Upvotes: 2

Related Questions