v0.7.0 — Phase β-6 Native-Polish
Drei Sub-Pakete: Keyboard-Shortcuts, Daily-Reminder-Notifications, WidgetKit-Extension mit App-Group-Daten-Sharing. Siri-Shortcuts und Share-Extension auf β-7 verschoben — niedrige Priorität, die drei großen Brocken decken 90% des Native-Polish ab. Keyboard-Shortcuts: - Hidden Buttons in StudySessionView mit .keyboardShortcut - Space = flip, 1/2/3/4 = again/hard/good/easy - iPad-Magic-Keyboard + macOS-tauglich Daily-Reminders: - NotificationManager @Observable mit UNUserNotificationCenter - Authorization-State + Permission-Request-Flow - UNCalendarNotificationTrigger täglich zur konfigurierten Zeit - SettingsView in AccountView mit Toggle + DatePicker - UserDefaults-Persistierung von Hour/Minute/Enabled WidgetKit-Extension: - WidgetSnapshot Codable mit topDecks (Top-3 by dueCount) + totalDueCount - WidgetSnapshotStore schreibt in group.ev.mana.cards-Container - DeckListStore.refresh schreibt Snapshot + WidgetCenter.reloadAllTimelines - CardsWidgetExtension-Target im project.yml (app-extension) - CardsWidgetBundle + CardsDueWidget mit 5 Familien (small/medium/ accessoryCircular/accessoryInline/accessoryRectangular) - DueProvider TimelineProvider mit 30-min-Refresh - DueWidgetView Family-Switch - WidgetSnapshot.swift shared in beiden Targets via XcodeGen sources - App-Group im Haupt- und Widget-Entitlement 35 Tests grün (keine neuen Tests in β-6 — WidgetKit + Notifications sind System-API-Integrationen, Tests wären überwiegend Mocks). Build inkl. Widget-Extension grün. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
07ada72b0f
commit
a1770fbc6a
15 changed files with 580 additions and 13 deletions
22
Widgets/CardsWidget/CardsDueWidget.swift
Normal file
22
Widgets/CardsWidget/CardsDueWidget.swift
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct CardsDueWidget: Widget {
|
||||
let kind: String = "ev.mana.cards.due"
|
||||
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: DueProvider()) { entry in
|
||||
DueWidgetView(entry: entry)
|
||||
.containerBackground(.fill.tertiary, for: .widget)
|
||||
}
|
||||
.configurationDisplayName("Karten heute")
|
||||
.description("Zeigt deine fälligen Karten und Top-Decks.")
|
||||
.supportedFamilies([
|
||||
.systemSmall,
|
||||
.systemMedium,
|
||||
.accessoryCircular,
|
||||
.accessoryInline,
|
||||
.accessoryRectangular,
|
||||
])
|
||||
}
|
||||
}
|
||||
13
Widgets/CardsWidget/CardsWidgetBundle.swift
Normal file
13
Widgets/CardsWidget/CardsWidgetBundle.swift
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
/// Cards-Widget-Bundle. Liefert ein einziges Widget mit drei Größen
|
||||
/// (small, medium) plus Lock-Screen-Familien (circular, inline,
|
||||
/// rectangular). Daten kommen aus dem shared App-Group-Container
|
||||
/// (siehe `WidgetSnapshotStore` im Haupt-Target).
|
||||
@main
|
||||
struct CardsWidgetBundle: WidgetBundle {
|
||||
var body: some Widget {
|
||||
CardsDueWidget()
|
||||
}
|
||||
}
|
||||
48
Widgets/CardsWidget/DueProvider.swift
Normal file
48
Widgets/CardsWidget/DueProvider.swift
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import Foundation
|
||||
import WidgetKit
|
||||
|
||||
/// Liest WidgetSnapshot aus dem shared App-Group-Container und schneidet
|
||||
/// eine Timeline mit 30-Minuten-Refresh. Haupt-App ruft zusätzlich nach
|
||||
/// jedem Refresh `WidgetCenter.shared.reloadAllTimelines()` auf, dann ist
|
||||
/// das Update sofort sichtbar.
|
||||
struct DueEntry: TimelineEntry, Sendable {
|
||||
let date: Date
|
||||
let totalDueCount: Int
|
||||
let topDecks: [WidgetSnapshot.Entry]
|
||||
let isPlaceholder: Bool
|
||||
|
||||
static let placeholder = DueEntry(
|
||||
date: .now,
|
||||
totalDueCount: 0,
|
||||
topDecks: [],
|
||||
isPlaceholder: true
|
||||
)
|
||||
}
|
||||
|
||||
struct DueProvider: TimelineProvider {
|
||||
func placeholder(in _: Context) -> DueEntry {
|
||||
.placeholder
|
||||
}
|
||||
|
||||
func getSnapshot(in _: Context, completion: @escaping @Sendable (DueEntry) -> Void) {
|
||||
completion(loadEntry())
|
||||
}
|
||||
|
||||
func getTimeline(in _: Context, completion: @escaping @Sendable (Timeline<DueEntry>) -> Void) {
|
||||
let entry = loadEntry()
|
||||
let next = Calendar.current.date(byAdding: .minute, value: 30, to: .now) ?? .now
|
||||
completion(Timeline(entries: [entry], policy: .after(next)))
|
||||
}
|
||||
|
||||
private func loadEntry() -> DueEntry {
|
||||
guard let snapshot = WidgetSnapshotStore.read() else {
|
||||
return .placeholder
|
||||
}
|
||||
return DueEntry(
|
||||
date: snapshot.updatedAt,
|
||||
totalDueCount: snapshot.totalDueCount,
|
||||
topDecks: snapshot.topDecks,
|
||||
isPlaceholder: false
|
||||
)
|
||||
}
|
||||
}
|
||||
102
Widgets/CardsWidget/DueWidgetView.swift
Normal file
102
Widgets/CardsWidget/DueWidgetView.swift
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
/// Family-Switch für das Cards-Due-Widget.
|
||||
struct DueWidgetView: View {
|
||||
let entry: DueEntry
|
||||
|
||||
@Environment(\.widgetFamily) private var family
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
switch family {
|
||||
case .systemSmall:
|
||||
smallView
|
||||
case .systemMedium:
|
||||
mediumView
|
||||
case .accessoryCircular:
|
||||
circularView
|
||||
case .accessoryInline:
|
||||
inlineView
|
||||
case .accessoryRectangular:
|
||||
rectangularView
|
||||
default:
|
||||
smallView
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var smallView: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text("\(entry.totalDueCount)")
|
||||
.font(.system(size: 48, weight: .bold))
|
||||
Text(entry.totalDueCount == 1 ? "Karte fällig" : "Karten fällig")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
Spacer()
|
||||
if let top = entry.topDecks.first {
|
||||
Text(top.name)
|
||||
.font(.caption2)
|
||||
.lineLimit(1)
|
||||
.foregroundStyle(.primary)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
private var mediumView: some View {
|
||||
HStack(alignment: .top, spacing: 16) {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("\(entry.totalDueCount)")
|
||||
.font(.system(size: 40, weight: .bold))
|
||||
Text(entry.totalDueCount == 1 ? "Karte fällig" : "Karten fällig")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Divider()
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
ForEach(entry.topDecks.prefix(3)) { deck in
|
||||
HStack {
|
||||
Text(deck.name)
|
||||
.font(.caption.weight(.medium))
|
||||
.lineLimit(1)
|
||||
Spacer()
|
||||
Text("\(deck.dueCount)")
|
||||
.font(.caption.weight(.bold))
|
||||
}
|
||||
}
|
||||
if entry.topDecks.isEmpty {
|
||||
Text("Keine Decks")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
|
||||
private var circularView: some View {
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(.tint.opacity(0.2))
|
||||
Text("\(entry.totalDueCount)")
|
||||
.font(.headline.bold())
|
||||
}
|
||||
}
|
||||
|
||||
private var inlineView: some View {
|
||||
Text("Cards: \(entry.totalDueCount) fällig")
|
||||
}
|
||||
|
||||
private var rectangularView: some View {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("\(entry.totalDueCount) fällig")
|
||||
.font(.headline)
|
||||
if let top = entry.topDecks.first {
|
||||
Text(top.name)
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.ev.mana.cards</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
29
Widgets/CardsWidget/Resources/Info.plist
Normal file
29
Widgets/CardsWidget/Resources/Info.plist
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Cards Widget</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XPC!</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
Loading…
Add table
Add a link
Reference in a new issue