You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
JustOneThing/WidgetShared/JustOneThingWidget.swift

52 lines
1.2 KiB

//
// 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: ThingEntry
var body: some View {
Text(entry.thing.text)
}
}
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(thing: .placeholder))
#if os(watchOS)
.previewContext(WidgetPreviewContext(family: .accessoryRectangular))
#else
.previewContext(WidgetPreviewContext(family: .systemMedium))
#endif
}
}