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:
Till JS 2026-05-13 01:00:04 +02:00
parent 07ada72b0f
commit a1770fbc6a
15 changed files with 580 additions and 13 deletions

View file

@ -0,0 +1,48 @@
import Foundation
/// Datei-Format für die WidgetKit-Extension. Wird vom Haupt-Target nach
/// jedem erfolgreichen `DeckListStore.refresh()` in den shared App-Group-
/// Container geschrieben; das Widget liest es im TimelineProvider.
///
/// Wire ist bewusst stabil + schmal nur was das Widget rendert.
/// Neue Felder dürfen additiv dazukommen, alte Felder bleiben.
struct WidgetSnapshot: Codable, Sendable {
let updatedAt: Date
let totalDueCount: Int
let topDecks: [Entry]
struct Entry: Codable, Sendable, Identifiable {
let id: String // deck-id
let name: String
let dueCount: Int
let colorHex: String?
}
}
/// Liest und schreibt WidgetSnapshot in den shared App-Group-Container.
enum WidgetSnapshotStore {
/// App-Group-ID muss exakt mit dem Entitlement-Eintrag matchen.
static let appGroupID = "group.ev.mana.cards"
static let snapshotFilename = "widget-snapshot.json"
static var snapshotURL: URL? {
FileManager.default
.containerURL(forSecurityApplicationGroupIdentifier: appGroupID)?
.appendingPathComponent(snapshotFilename)
}
static func write(_ snapshot: WidgetSnapshot) {
guard let url = snapshotURL else { return }
let encoder = JSONEncoder()
encoder.dateEncodingStrategy = .iso8601
guard let data = try? encoder.encode(snapshot) else { return }
try? data.write(to: url, options: .atomic)
}
static func read() -> WidgetSnapshot? {
guard let url = snapshotURL, let data = try? Data(contentsOf: url) else { return nil }
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .iso8601
return try? decoder.decode(WidgetSnapshot.self, from: data)
}
}