Code + Identity-Rename zur Vorbereitung auf Apple-Dev-Portal-Aktion (Bundle ev.mana.wordeck, App-Group group.ev.mana.wordeck, AASA applinks:wordeck.com). Build bleibt funktional, aber gegen die neue text-only-API können image-occlusion-Creates 422 zurückgeben — das wird mit der Wordeck-Native v1.0-Welle (parallele Apple-Aktion) sauber gemacht. Umbenennung: - 41 Files: cardecky/Cardecky → wordeck/Wordeck (Display, Strings, Kommentare) - 57 Files: CardsNative → WordeckNative, CardsAPI → WordeckAPI, CardsTheme → WordeckTheme, CardsBrand → WordeckBrand, CardsWidget → WordeckWidget, CardsDueWidget → WordeckDueWidget - Bundle-ID ev.mana.cardecky → ev.mana.wordeck (project.yml, Info.plist, entitlements, Keychain-Service, App-Group) - AASA applinks:cardecky.mana.how → applinks:wordeck.com - API-Base cardecky-api.mana.how → api.wordeck.com - 10 Files renamed (App-Entry, API-Extensions, Theme, Widget, Entitlements, Tests) - xcodeproj regenerated via xcodegen → WordeckNative.xcodeproj - MaskRegionsTests.swift gelöscht (image-occlusion entfällt mit Wordeck text-only) Forgejo-Repo git.mana.how/till/cards-native → wordeck-native umbenannt (Auto-Redirect aktiv). Lokales Verzeichnis Code/cards-native/ bleibt vorerst — wird beim nächsten Apple-Setup mit Bundle-Test umbenannt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.7 KiB
Swift
48 lines
1.7 KiB
Swift
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 {
|
|
let updatedAt: Date
|
|
let totalDueCount: Int
|
|
let topDecks: [Entry]
|
|
|
|
struct Entry: Codable, 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.wordeck"
|
|
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)
|
|
}
|
|
}
|