Files
Lichtkasten DevandClaude Opus 5.5 93ecdf03fc Gesendet-Status, Agentur-Check, Rückgängig und Spieltag-Assistent
- Gesendet-Status pro Bild: Upload-Historie (FTP + Immich) mit Ziel und Zeit, grünes Abzeichen im Kontaktabzug,
  Anzeige in Lupe und IPTC-Fenster, Filter Gesendet/Nicht gesendet, bereits gesendete beim Upload überspringen,
  'Als nicht gesendet markieren'
- Agentur-Check vor dem FTP-Upload: Pflichtfelder, offene Variablen und Codes, Datum aus alter Vorlage,
  IIM-Längen, offene Trikot-Vorschläge, Mindestgröße; Prüffenster mit Bearbeiten/Erneut prüfen/
  Nur fehlerfreie senden; Einstellungsseite und Schalter pro Server
- Rückgängig/Wiederholen (⌘Z/⇧⌘Z) für Sterne, Farben, Tags, IPTC und Vorlagen, Schreibvorgänge serialisiert,
  in Textfeldern bleibt ⌘Z beim Text
- Spieltag-Assistent (⌘⇧N, auch im Ingest und in der Matchday-Ansicht): Teams, Wettbewerbe und Muster werden
  gespeichert; erzeugt Vorlage im Aufbau der Basis-Vorlage, Ingest-Ordner, Trikot-Teams und aktive Code-Teams;
  Trikotfarben aus der Erkennung fließen ins Team zurück; Matchday nimmt die Teams aus dem Ereignis des Bildes
- Tests für Spieltag-Generator, Agentur-Check und Gesendet-Log, README ergänzt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
2026-11-05 00:23:03 +00:00

202 lines
9.0 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import SwiftUI
import LichtkastenCore
/// Right panel of the loupe (layout B): rating, color class, player suggestion and the IPTC fields
/// you change per image – saving with ⌘N / ⌘B like in the IPTC window. All other fields: I.
struct LoupeInspector: View {
@EnvironmentObject var state: AppState
@State private var texts: FieldTexts = [:]
@State private var dirty: Set<String> = []
@State private var loadedID: String?
@State private var saving = false
private var item: PhotoItem? { state.cursorItem }
private static let quickFields = ["caption", "headline", "keywords", "personInImage", "event", "city", "sublocation", "dateCreated"]
var body: some View {
VStack(spacing: 0) {
header
Rectangle().fill(LK.border).frame(height: 1)
ScrollView {
VStack(alignment: .leading, spacing: 14) {
suggestions
LKSectionLabel(title: "Bildinhalt")
field("caption", "Beschreibung", height: 150)
field("headline", "Überschrift", height: 50)
field("keywords", "Stichwörter", height: 70)
field("personInImage", "Personen")
LKSectionLabel(title: "Ort").padding(.top, 4)
HStack(alignment: .top, spacing: 10) {
field("city", "Stadt")
field("sublocation", "Ort")
}
field("event", "Ereignis")
VStack(alignment: .leading, spacing: 5) {
Text("Datum").font(.system(size: 12)).foregroundStyle(LK.text2)
DateFieldEditor(text: binding("dateCreated"))
}
Button("Alle IPTC-Felder … (I)") { state.openWindow("iptc") }
.buttonStyle(LKButtonStyle(compact: true))
}
.padding(18)
}
Rectangle().fill(LK.border).frame(height: 1)
HStack(spacing: 8) {
Button("← Speichern ⌘N") { saveAndMove(-1) }
.keyboardShortcut("n", modifiers: .command)
.buttonStyle(LKButtonStyle())
.frame(maxWidth: .infinity)
Button("Speichern → ⌘B") { saveAndMove(1) }
.keyboardShortcut("b", modifiers: .command)
.buttonStyle(LKButtonStyle(primary: true))
.frame(maxWidth: .infinity)
}
.padding(14)
.disabled(item == nil || saving)
}
.background(LK.panel)
.onAppear { load(force: true) }
.onChange(of: state.cursorID) { _, _ in load(force: true) }
.onReceive(state.$items) { _ in if dirty.isEmpty { DispatchQueue.main.async { load(force: false) } } }
}
// MARK: Header: name, stars, color class
private var header: some View {
VStack(alignment: .leading, spacing: 10) {
HStack {
Text(item?.baseName ?? "–").font(LK.mono(13, .medium)).foregroundStyle(LK.text).lineLimit(1).truncationMode(.middle)
Spacer()
if let item {
HStack(spacing: 2) {
ForEach(1...5, id: \.self) { n in
Button { state.setRating(item.rating == n ? 0 : n, advance: false, only: item) } label: {
Image(systemName: n <= item.rating ? "star.fill" : "star")
.font(.system(size: 13))
.foregroundStyle(n <= item.rating ? LK.amber : LK.faint)
}
.buttonStyle(.plain)
.help("\(n) Stern(e) – ⌥\(n)")
}
}
}
}
if let item {
HStack(spacing: 6) {
ForEach(ColorLabel.allCases, id: \.self) { l in
let on = item.label == l
Button { state.setLabel(l, advance: false, only: item) } label: {
Capsule().fill(on ? l.lkColor : l.lkColor.opacity(0.25))
.frame(width: 26, height: on ? 8 : 6)
}
.buttonStyle(.plain)
.help("\(l.pmColorClass) – \(l.germanName)")
}
Spacer()
Button { state.toggleTag() } label: {
Label(item.tagged ? "Getaggt" : "Tag", systemImage: item.tagged ? "checkmark.square.fill" : "square")
.font(.system(size: 12, weight: .semibold))
.foregroundStyle(item.tagged ? LK.amber : LK.text2)
}
.buttonStyle(.plain)
.help("Tag (T)")
}
SentStatusLine(summary: state.sentSummary(for: item))
}
}
.padding(18)
}
// MARK: Player suggestion (jersey numbers)
@ViewBuilder
private var suggestions: some View {
let open = item.map { state.openSuggestions(for: $0.id) } ?? []
if let item, !open.isEmpty {
VStack(alignment: .leading, spacing: 8) {
ForEach(open) { s in
HStack(spacing: 10) {
if let c = s.measuredColor {
RoundedRectangle(cornerRadius: 3).fill(c.swiftUI).frame(width: 12, height: 12)
}
Text(s.code ?? "#\(s.number)").font(LK.mono(12, .semibold)).foregroundStyle(LK.amber)
Text(s.replacement.map { JerseyLogic.personName(replacement: $0, columns: []) } ?? "")
.font(.system(size: 13)).foregroundStyle(LK.text).lineLimit(1)
Text("\(Int(s.confidence * 100)) %").font(LK.mono(11)).foregroundStyle(LK.muted)
Spacer()
Button("Annehmen") { accept([s], item: item) }
.buttonStyle(LKButtonStyle(primary: true, compact: true))
.keyboardShortcut(s.id == open.first?.id ? KeyboardShortcut("j", modifiers: .command) : nil)
Button { state.dismissSuggestion(s, for: item.id) } label: { Image(systemName: "xmark") }
.buttonStyle(LKButtonStyle(compact: true))
.help("Falsch – verwerfen")
}
}
}
.padding(12)
.background(RoundedRectangle(cornerRadius: 10).fill(LK.amberSoft))
.overlay(RoundedRectangle(cornerRadius: 10).stroke(LK.amber.opacity(0.35)))
}
}
// MARK: Fields
private func binding(_ id: String) -> Binding<String> {
Binding(get: { texts[id] ?? "" }, set: { texts[id] = $0; dirty.insert(id) })
}
private func field(_ id: String, _ label: String, height: CGFloat? = nil) -> some View {
VStack(alignment: .leading, spacing: 5) {
HStack {
Text(label).font(.system(size: 12)).foregroundStyle(dirty.contains(id) ? LK.amber : LK.text2)
if let f = IPTCField.byID[id], f.kind == .list {
Text("Komma-getrennt").font(.system(size: 10)).foregroundStyle(LK.faint)
}
}
if let height {
CodeTextView(text: binding(id), codes: state.codes)
.frame(height: height)
.clipShape(RoundedRectangle(cornerRadius: 8))
.overlay(RoundedRectangle(cornerRadius: 8).stroke(LK.borderStrong))
} else {
CodeTextField(text: binding(id), codes: state.codes)
.frame(height: 22)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
}
// MARK: Actions
private func load(force: Bool) {
guard let item else { texts = [:]; dirty = []; loadedID = nil; return }
if !force && loadedID == item.id && !dirty.isEmpty { return }
texts = item.iptc.texts()
dirty = []
loadedID = item.id
}
private func accept(_ s: [JerseySuggestion], item: PhotoItem) {
let updated = state.applying(s, to: IPTCValues(texts: texts)).texts()
for id in ["caption", "personInImage"] where (texts[id] ?? "") != (updated[id] ?? "") {
texts[id] = updated[id] ?? ""
dirty.insert(id)
}
state.markSuggestionsDone(s, for: item.id)
}
private func saveAndMove(_ delta: Int) {
Task {
if let item, !dirty.isEmpty {
saving = true
let fields = IPTCField.all.filter { dirty.contains($0.id) }
let ok = await state.applyIPTCAndWait(IPTCValues(texts: texts), fields: fields, to: [item])
saving = false
guard ok else { return }
dirty = []
}
state.moveCursor(by: delta)
}
}
}