30 lines
1.1 KiB
Swift
30 lines
1.1 KiB
Swift
import WidgetKit
|
|
import SwiftUI
|
|
|
|
// Diagnostic widget: no AppIntents, no shared code. Tells apart "WidgetKit rejects the extension" from
|
|
// "the AppIntents in the real widget break it".
|
|
struct TestEntry: TimelineEntry { let date: Date }
|
|
|
|
struct TestProvider: TimelineProvider {
|
|
func placeholder(in context: Context) -> TestEntry { TestEntry(date: Date()) }
|
|
func getSnapshot(in context: Context, completion: @escaping (TestEntry) -> Void) { completion(TestEntry(date: Date())) }
|
|
func getTimeline(in context: Context, completion: @escaping (Timeline<TestEntry>) -> Void) {
|
|
completion(Timeline(entries: [TestEntry(date: Date())], policy: .never))
|
|
}
|
|
}
|
|
|
|
struct TestWidget: Widget {
|
|
var body: some WidgetConfiguration {
|
|
StaticConfiguration(kind: "MulberryTest", provider: TestProvider()) { _ in
|
|
Text("Mulberry test widget").containerBackground(.purple, for: .widget)
|
|
}
|
|
.configurationDisplayName("Mulberry test")
|
|
.description("Diagnostic widget.")
|
|
.supportedFamilies([.systemSmall])
|
|
}
|
|
}
|
|
|
|
@main
|
|
struct TestWidgets: WidgetBundle {
|
|
var body: some Widget { TestWidget() }
|
|
}
|