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.
40 lines
1.1 KiB
40 lines
1.1 KiB
//
|
|
// 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)
|
|
}
|
|
}
|
|
}
|
|
|
|
|