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>
72 lines
2 KiB
Swift
72 lines
2 KiB
Swift
import SwiftUI
|
|
|
|
#if canImport(UIKit)
|
|
import UIKit
|
|
#elseif canImport(AppKit)
|
|
import AppKit
|
|
#endif
|
|
|
|
/// Lädt ein authentifiziertes Image vom Wordeck-Media-Endpoint und
|
|
/// rendert es. Streamt erst beim ersten Mal, danach aus dem
|
|
/// MediaCache (LRU 200 MB).
|
|
struct RemoteImage: View {
|
|
let mediaId: String
|
|
let contentMode: ContentMode
|
|
|
|
@Environment(\.mediaCache) private var mediaCache
|
|
@State private var image: PlatformImage?
|
|
@State private var failed = false
|
|
|
|
init(mediaId: String, contentMode: ContentMode = .fit) {
|
|
self.mediaId = mediaId
|
|
self.contentMode = contentMode
|
|
}
|
|
|
|
var body: some View {
|
|
Group {
|
|
if let image {
|
|
imageView(image)
|
|
} else if failed {
|
|
ContentUnavailableView("Bild konnte nicht geladen werden", systemImage: "photo.badge.exclamationmark")
|
|
.foregroundStyle(WordeckTheme.mutedForeground)
|
|
} else {
|
|
ProgressView()
|
|
.tint(WordeckTheme.primary)
|
|
}
|
|
}
|
|
.task(id: mediaId) {
|
|
await load()
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func imageView(_ image: PlatformImage) -> some View {
|
|
#if canImport(UIKit)
|
|
Image(uiImage: image).resizable().aspectRatio(contentMode: contentMode)
|
|
#elseif canImport(AppKit)
|
|
Image(nsImage: image).resizable().aspectRatio(contentMode: contentMode)
|
|
#endif
|
|
}
|
|
|
|
private func load() async {
|
|
guard let cache = mediaCache else { failed = true
|
|
return
|
|
}
|
|
do {
|
|
let data = try await cache.data(for: mediaId)
|
|
if let img = PlatformImage(data: data) {
|
|
image = img
|
|
} else {
|
|
failed = true
|
|
}
|
|
} catch {
|
|
failed = true
|
|
}
|
|
}
|
|
}
|
|
|
|
#if canImport(UIKit)
|
|
typealias PlatformImage = UIImage
|
|
#elseif canImport(AppKit)
|
|
typealias PlatformImage = NSImage
|
|
#endif
|