// // JustOneThingWidget.swift // JustOneThing // // Created by Alan Francis on 11/06/2023. // import WidgetKit import SwiftUI import Intents @main struct JustOneThingWidgetBundle: WidgetBundle { var body: some Widget { JustOneThingWidget() } } struct ThingEntryView : View { var entry: ThingProvider.Entry var body: some View { Text(entry.date, style: .time) } } struct JustOneThingWidget: Widget { let kind: String = "JustOneThingWidget" var body: some WidgetConfiguration { IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: ThingProvider()) { entry in ThingEntryView(entry: entry) } .configurationDisplayName("My Widget") .description("This is an example widget.") } } struct Widget_Previews: PreviewProvider { static var previews: some View { ThingEntryView(entry: ThingEntry(date: Date(), configuration: ConfigurationIntent(), thing: .placeholder)) #if os(watchOS) .previewContext(WidgetPreviewContext(family: .accessoryRectangular)) #else .previewContext(WidgetPreviewContext(family: .systemMedium)) #endif } }