Sample-Daten mit 4 Decks und totalDueCount=23. Small-Preview zeigt zusätzlich den Empty-State als zweiten Timeline-Entry. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
1.5 KiB
Swift
57 lines
1.5 KiB
Swift
import SwiftUI
|
|
import WidgetKit
|
|
|
|
struct WordeckDueWidget: Widget {
|
|
let kind: String = "ev.mana.wordeck.due"
|
|
|
|
var body: some WidgetConfiguration {
|
|
StaticConfiguration(kind: kind, provider: DueProvider()) { entry in
|
|
DueWidgetView(entry: entry)
|
|
.containerBackground(.fill.tertiary, for: .widget)
|
|
.widgetURL(URL(string: "wordeck://study"))
|
|
}
|
|
.configurationDisplayName("Karten heute")
|
|
.description("Zeigt deine fälligen Karten und Top-Decks.")
|
|
.supportedFamilies([
|
|
.systemSmall,
|
|
.systemMedium,
|
|
.systemLarge,
|
|
.accessoryCircular,
|
|
.accessoryInline,
|
|
.accessoryRectangular,
|
|
])
|
|
}
|
|
}
|
|
|
|
// MARK: - Previews
|
|
|
|
private let demoEntry = DueEntry(
|
|
date: .now,
|
|
totalDueCount: 23,
|
|
topDecks: [
|
|
WidgetSnapshot.Entry(id: "d1", name: "Italienisch — Verben", dueCount: 12, colorHex: nil),
|
|
WidgetSnapshot.Entry(id: "d2", name: "iOS-Snippets", dueCount: 7, colorHex: nil),
|
|
WidgetSnapshot.Entry(id: "d3", name: "Anatomie", dueCount: 4, colorHex: nil),
|
|
WidgetSnapshot.Entry(id: "d4", name: "Sterne am Nordhimmel", dueCount: 2, colorHex: nil),
|
|
],
|
|
isPlaceholder: false
|
|
)
|
|
|
|
#Preview("Klein", as: .systemSmall) {
|
|
WordeckDueWidget()
|
|
} timeline: {
|
|
demoEntry
|
|
DueEntry.placeholder
|
|
}
|
|
|
|
#Preview("Mittel", as: .systemMedium) {
|
|
WordeckDueWidget()
|
|
} timeline: {
|
|
demoEntry
|
|
}
|
|
|
|
#Preview("Groß", as: .systemLarge) {
|
|
WordeckDueWidget()
|
|
} timeline: {
|
|
demoEntry
|
|
}
|