// // AccessoryWidget.swift // JustOneThing // // Created by Alan Francis on 06/07/2023. // import SwiftUI import WidgetKit import Intents struct JustOneThingAccessoryWidget: Widget { let kind: String = "JustOneThingAccessoryWidget" let persistenceController = PersistenceController.shared var body: some WidgetConfiguration { IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: ThingProvider()) { entry in JustOneThingAccessoryThingView(thing: entry.thing) } .configurationDisplayName("One Tiny Thing") .description("Show a random Thing in an Accessory.") .supportedFamilies([.accessoryInline, .accessoryCircular, .accessoryRectangular]) } } struct JustOneThingAccessoryThingView: View { let thing: Thing @Environment(\.widgetFamily) var family var body: some View { if( family == .accessoryCircular ) { Image(systemName:"1.magnifyingglass").font(.largeTitle) } else { ThingView(thing: thing) } } }