From 7a349b8c343bebc4a5764bb44de4156d0e87ac11 Mon Sep 17 00:00:00 2001 From: Lichtkasten Dev Date: Wed, 4 Nov 2026 15:40:53 +0000 Subject: [PATCH] =?UTF-8?q?Neues=20Design=20'Leuchttisch'=20(warmes=20Grap?= =?UTF-8?q?hit,=20Bernstein-Akzent)=20f=C3=BCr=20alle=20Fenster;=20Lupe=20?= =?UTF-8?q?im=20Studio-Layout=20(Filmstreifen=20+=20IPTC-Panel=20mit=20?= =?UTF-8?q?=E2=8C=98N/=E2=8C=98B);=20Matchday-Ansicht=20(Teamleiste,=20Spi?= =?UTF-8?q?elerinnen-Liste,=20Teamfilter,=20Kacheln=20mit=20Teamfarbe=20+?= =?UTF-8?q?=20Nummer)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D --- Sources/Lichtkasten/LichtkastenApp.swift | 7 +- Sources/Lichtkasten/Services/AppState.swift | 95 ++++++++- .../Lichtkasten/Services/Persistence.swift | 5 + .../Lichtkasten/Views/ContactSheetView.swift | 177 +++++++++------- Sources/Lichtkasten/Views/ContentView.swift | 187 ++++++++-------- Sources/Lichtkasten/Views/IPTCForm.swift | 21 +- .../Lichtkasten/Views/IPTCInfoWindow.swift | 4 +- .../Lichtkasten/Views/JerseySetupView.swift | 2 +- .../Lichtkasten/Views/LoupeInspector.swift | 200 ++++++++++++++++++ Sources/Lichtkasten/Views/MatchdayViews.swift | 162 ++++++++++++++ Sources/Lichtkasten/Views/PreviewView.swift | 121 ++++++++--- Sources/Lichtkasten/Views/TasksWindow.swift | 2 +- Sources/Lichtkasten/Views/Theme.swift | 140 ++++++++++++ 13 files changed, 920 insertions(+), 203 deletions(-) create mode 100644 Sources/Lichtkasten/Views/LoupeInspector.swift create mode 100644 Sources/Lichtkasten/Views/MatchdayViews.swift create mode 100644 Sources/Lichtkasten/Views/Theme.swift diff --git a/Sources/Lichtkasten/LichtkastenApp.swift b/Sources/Lichtkasten/LichtkastenApp.swift index 48741c8..6b05957 100644 --- a/Sources/Lichtkasten/LichtkastenApp.swift +++ b/Sources/Lichtkasten/LichtkastenApp.swift @@ -31,6 +31,7 @@ struct LichtkastenApp: App { Window("IPTC-Info", id: "iptc") { IPTCInfoWindow() .environmentObject(state) + .lkWindow() .frame(minWidth: 1020, minHeight: 680) } .defaultSize(width: 1240, height: 860) @@ -39,19 +40,21 @@ struct LichtkastenApp: App { Window("IPTC für Auswahl", id: "iptc-batch") { BatchEditWindow() .environmentObject(state) + .lkWindow() .frame(minWidth: 1200, minHeight: 700) } .defaultSize(width: 1400, height: 900) // ⌘U – upload dialog Window("Hochladen", id: "upload") { - UploadWindow().environmentObject(state) + UploadWindow().environmentObject(state).lkWindow() } .windowResizability(.contentSize) // PM: Tasks window Window("Aufgaben", id: "tasks") { TasksWindow() + .lkWindow() .environmentObject(state) .environmentObject(state.tasks) .environmentObject(state.uploads) @@ -62,12 +65,14 @@ struct LichtkastenApp: App { Window("Code-Ersetzungen", id: "codes") { CodesWindow() .environmentObject(state) + .lkWindow() .frame(minWidth: 640, minHeight: 480) } Settings { SettingsView() .environmentObject(state) + .lkWindow() .frame(width: 760, height: 600) } } diff --git a/Sources/Lichtkasten/Services/AppState.swift b/Sources/Lichtkasten/Services/AppState.swift index 0b8bccf..7986391 100644 --- a/Sources/Lichtkasten/Services/AppState.swift +++ b/Sources/Lichtkasten/Services/AppState.swift @@ -14,8 +14,15 @@ struct PMFilter: Equatable { /// only images with open jersey suggestions var suggestionsOnly = false + /// Matchday filters + var team: UUID? + var person: String? + var withoutPlayer = false - var isActive: Bool { tag != .all || (ratingOn && !ratings.isEmpty) || (colorOn && !colors.isEmpty) || suggestionsOnly } + var isActive: Bool { + tag != .all || (ratingOn && !ratings.isEmpty) || (colorOn && !colors.isEmpty) || suggestionsOnly + || team != nil || person != nil || withoutPlayer + } func matches(_ item: PhotoItem) -> Bool { switch tag { @@ -83,7 +90,21 @@ final class AppState: ObservableObject { } } /// Flat lookup of all enabled teams (used for expansion). - @Published private(set) var codes: CodeReplacements + @Published private(set) var codes: CodeReplacements { didSet { rebuildPersonIndex() } } + /// person name ("Svenja Huth") → code ("w10") – for Matchday cards + private(set) var personIndex: [String: String] = [:] + + private func rebuildPersonIndex() { + var idx: [String: String] = [:] + for set in codeLibrary.sets where set.enabled { + for e in set.entries { + guard let rep = e.columns.first else { continue } + let name = JerseyLogic.personName(replacement: rep, columns: e.columns) + if idx[name] == nil { idx[name] = e.code.lowercased() } + } + } + personIndex = idx + } @Published var gridColumns = 5 // Sheets @@ -128,6 +149,7 @@ final class AppState: ObservableObject { ?? CodeLibrary.migrate(Storage.load(CodeReplacements.self, from: Storage.codesURL) ?? CodeReplacements()) codeLibrary = library codes = library.replacements + rebuildPersonIndex() uploads.state = self seedDefaultsIfNeeded() startLightroomPolling() @@ -497,6 +519,15 @@ final class AppState: ObservableObject { private func rebuildVisible() { var list = items.filter { filter.matches($0) } if filter.suggestionsOnly { list = list.filter { !(openSuggestions(for: $0.id).isEmpty) } } + if filter.team != nil || filter.person != nil || filter.withoutPlayer { + list = list.filter { item in + let p = playerInfo(for: item) + if filter.withoutPlayer { return p == nil } + if let t = filter.team, p?.team?.id != t { return false } + if let n = filter.person, p?.name != n { return false } + return true + } + } let q = searchText.trimmingCharacters(in: .whitespaces).lowercased() if !q.isEmpty { list = list.filter { item in @@ -1122,4 +1153,64 @@ final class AppState: ObservableObject { saveJerseyCache() } + + // MARK: - Matchday + + struct PlayerInfo: Equatable { + var name: String + var number: Int? + var team: JerseyTeam? + var confirmed: Bool + } + + var matchdayActive: Bool { settings.jersey.matchday && settings.jersey.teams.count >= 2 } + + func team(forCode code: String) -> JerseyTeam? { + let c = code.lowercased() + return settings.jersey.teams.first { t in + let p = t.prefix.lowercased() + return !p.isEmpty && c.hasPrefix(p) && c.dropFirst(p.count).allSatisfy(\.isNumber) + } + } + + /// Main player of an image: accepted suggestion / "Persons shown" first, else the top open suggestion. + func playerInfo(for item: PhotoItem) -> PlayerInfo? { + if let name = item.iptc.lists["personInImage"]?.first { + let code = personIndex[name] + let number = code.flatMap { c in Int(c.drop { !$0.isNumber }) } + return PlayerInfo(name: name, number: number, team: code.flatMap { team(forCode: $0) }, confirmed: true) + } + if let s = openSuggestions(for: item.id).first, let rep = s.replacement { + let name = JerseyLogic.personName(replacement: rep, columns: codes.table[(s.code ?? "").lowercased()] ?? []) + return PlayerInfo(name: name, number: s.number, team: settings.jersey.teams.first { $0.id == s.teamID }, confirmed: false) + } + return nil + } + + struct PlayerCount: Identifiable { var id: String { name }; var name: String; var number: Int?; var team: JerseyTeam?; var count: Int } + + /// Players in this folder with number of images (Matchday rail). + var playerCounts: [PlayerCount] { + var map: [String: PlayerCount] = [:] + for item in items { + guard let p = playerInfo(for: item) else { continue } + map[p.name, default: PlayerCount(name: p.name, number: p.number, team: p.team, count: 0)].count += 1 + } + return map.values.sorted { ($0.count, $1.name) > ($1.count, $0.name) } + } + + /// Event and date for the Matchday header (most common IPTC event in the folder). + var matchdayEvent: (event: String, date: String) { + var counts: [String: Int] = [:] + for i in items { if let e = i.iptc.text["event"], !e.isEmpty { counts[e, default: 0] += 1 } } + let event = counts.max { $0.value < $1.value }?.key ?? (folder?.lastPathComponent ?? "") + let f = DateFormatter(); f.dateFormat = "dd.MM.yyyy" + let date = items.compactMap(\.captureDate).min().map { f.string(from: $0) } ?? "" + return (event, date) + } + + func setTeamFilter(_ id: UUID?) { + filter.team = id; filter.person = nil; filter.withoutPlayer = false + } + } diff --git a/Sources/Lichtkasten/Services/Persistence.swift b/Sources/Lichtkasten/Services/Persistence.swift index eb19180..f16e583 100644 --- a/Sources/Lichtkasten/Services/Persistence.swift +++ b/Sources/Lichtkasten/Services/Persistence.swift @@ -73,6 +73,8 @@ struct JerseySettings: Codable, Hashable { var minConfidence = 0.35 var autoAfterIngest = false var separator = ", " + /// Matchday view (team header, player list, team-colored cards) when two teams are set up + var matchday = true init() {} init(from decoder: Decoder) throws { @@ -84,6 +86,7 @@ struct JerseySettings: Codable, Hashable { minConfidence = (try? c.decode(Double.self, forKey: .minConfidence)) ?? d.minConfidence autoAfterIngest = (try? c.decode(Bool.self, forKey: .autoAfterIngest)) ?? d.autoAfterIngest separator = (try? c.decode(String.self, forKey: .separator)) ?? d.separator + matchday = (try? c.decode(Bool.self, forKey: .matchday)) ?? d.matchday } } @@ -98,6 +101,7 @@ struct AppSettings: Codable { /// Largest contact sheet thumbnail size (slider maximum) var maxThumbnailSize: Double = 700 var autoAdvance = true // after rating/tagging jump to next image (PM: "Auto-advance") + var loupePanel = true // IPTC panel next to the loupe (layout B) var ftpDestinations: [FTPDestination] = [] var immich = ImmichSettings() var lightroom = LightroomSettings() @@ -123,6 +127,7 @@ struct AppSettings: Codable { maxZoom = (try? c.decode(Double.self, forKey: .maxZoom)) ?? d.maxZoom maxThumbnailSize = (try? c.decode(Double.self, forKey: .maxThumbnailSize)) ?? d.maxThumbnailSize autoAdvance = (try? c.decode(Bool.self, forKey: .autoAdvance)) ?? d.autoAdvance + loupePanel = (try? c.decode(Bool.self, forKey: .loupePanel)) ?? d.loupePanel ftpDestinations = (try? c.decode([FTPDestination].self, forKey: .ftpDestinations)) ?? d.ftpDestinations immich = (try? c.decode(ImmichSettings.self, forKey: .immich)) ?? d.immich lightroom = (try? c.decode(LightroomSettings.self, forKey: .lightroom)) ?? d.lightroom diff --git a/Sources/Lichtkasten/Views/ContactSheetView.swift b/Sources/Lichtkasten/Views/ContactSheetView.swift index e2a81c0..a22b306 100644 --- a/Sources/Lichtkasten/Views/ContactSheetView.swift +++ b/Sources/Lichtkasten/Views/ContactSheetView.swift @@ -18,6 +18,7 @@ struct ContactSheetView: View { isCursor: state.cursorID == item.id, imageURL: state.previewURL(for: item), badge: state.suggestionBadge(for: item.id), + player: state.matchdayActive ? state.playerInfo(for: item) : nil, onTagClick: { tagClick(item) }) .equatable() .id(item.id) @@ -29,7 +30,7 @@ struct ContactSheetView: View { } .padding(10) } - .background(Color(white: 0.22)) + .background(LK.ground) .onChange(of: state.cursorID) { _, id in if let id { proxy.scrollTo(id) } } @@ -108,113 +109,147 @@ struct ThumbnailCell: View, Equatable { let imageURL: URL /// open jersey suggestions ("#10 #7") let badge: String? + /// Matchday: main player (team color edge + big number) + let player: AppState.PlayerInfo? let onTagClick: () -> Void @State private var image: NSImage? static func == (a: ThumbnailCell, b: ThumbnailCell) -> Bool { - a.item == b.item && a.size == b.size && a.selected == b.selected && a.isCursor == b.isCursor && a.imageURL == b.imageURL && a.badge == b.badge + a.item == b.item && a.size == b.size && a.selected == b.selected && a.isCursor == b.isCursor && a.imageURL == b.imageURL && a.badge == b.badge && a.player == b.player } - /// PM shows the selection as a pale yellow card. - private static let selectedFill = Color(red: 0.93, green: 0.96, blue: 0.68) - - private var dateLine: String { - guard let d = item.captureDate else { return "" } - return ThumbnailCell.dateFormatter.string(from: d) - } - - private static let dateFormatter: DateFormatter = { + private static let timeFormatter: DateFormatter = { let f = DateFormatter() - f.dateFormat = "dd.MM.yyyy - HH:mm:ss" + f.dateFormat = "HH:mm:ss" return f }() - private var cameraLine: String { - var lens: [String] = [] - if let fl = item.exif["FocalLength"] { lens.append(fl.replacingOccurrences(of: ".0 mm", with: "mm").replacingOccurrences(of: " mm", with: "mm")) } - if let f = item.exif["FNumber"] { lens.append(f) } - let left = lens.joined(separator: " ") - let model = item.exif["Model"] ?? "" - return [left, model].filter { !$0.isEmpty }.joined(separator: " - ") + private var timeLine: String { + item.captureDate.map { ThumbnailCell.timeFormatter.string(from: $0) } ?? "" } var body: some View { - let textColor: Color = selected ? .black : .primary - VStack(spacing: 2) { + VStack(alignment: .leading, spacing: 0) { ZStack { + Rectangle().fill(LK.deep) if let image { Image(nsImage: image).resizable().interpolation(.medium).scaledToFit() - .shadow(color: .black.opacity(0.4), radius: 2, y: 1) } else { ProgressView().controlSize(.small) } } - .frame(width: size - 14, height: (size - 14) * 0.75) - .overlay(alignment: .topTrailing) { - if let badge { - Text(badge) - .font(.system(size: 10, weight: .bold).monospacedDigit()) - .foregroundStyle(.white) - .padding(.horizontal, 5).padding(.vertical, 2) - .background(Capsule().fill(Color.blue.opacity(0.85))) - .padding(4) - .help("Spieler-Vorschlag – mit I prüfen und annehmen") + .frame(width: size - 20, height: (size - 20) * 0.72) + .clipShape(RoundedRectangle(cornerRadius: 8)) + // Matchday: team color edge + .overlay(alignment: .leading) { + if let t = player?.team { + UnevenRoundedRectangle(topLeadingRadius: 8, bottomLeadingRadius: 8) + .fill(t.shirtColor.swiftUI).frame(width: 5) } } - .padding(.top, 6) - - VStack(spacing: 0) { - Text(item.filename).lineLimit(1).truncationMode(.middle) - Text(dateLine).lineLimit(1) - Text(item.iptc.text["headline"] ?? " ").lineLimit(1).truncationMode(.middle) - Text(cameraLine.isEmpty ? " " : cameraLine).lineLimit(1) - } - .font(.system(size: 11)) - .foregroundStyle(textColor) - .frame(maxWidth: .infinity) - - HStack(spacing: 6) { - // PM: color class bar with the rating dots/stars inside - ZStack { - Capsule().fill(item.label?.color ?? Color.gray.opacity(0.35)) - HStack(spacing: 6) { - ForEach(1...5, id: \.self) { n in - if n <= item.rating { - Image(systemName: "star.fill").font(.system(size: 8)) - } else { - Circle().frame(width: 3, height: 3) - } + // tag: amber check, top left + .overlay(alignment: .topLeading) { + Button(action: onTagClick) { + Group { + if item.tagged { + Image(systemName: "checkmark") + .font(.system(size: 11, weight: .heavy)) + .foregroundStyle(LK.onAmber) + .frame(width: 22, height: 22) + .background(RoundedRectangle(cornerRadius: 6).fill(LK.amber)) + } else { + RoundedRectangle(cornerRadius: 6).stroke(Color.white.opacity(selected || isCursor ? 0.6 : 0.0), lineWidth: 1.5) + .frame(width: 22, height: 22) } } - .foregroundStyle(item.label == nil ? Color.primary.opacity(0.6) : Color.white) - } - .frame(height: 12) - - Button(action: onTagClick) { - Image(systemName: item.tagged ? "checkmark.square.fill" : "square") - .font(.system(size: 14)) - .foregroundStyle(item.tagged ? (selected ? Color.black : Color.white) : Color.secondary) + .padding(8) + .contentShape(Rectangle()) } .buttonStyle(.plain) .help("Tag (T)") } - .padding(.horizontal, 8) - .padding(.bottom, 6) + // open player suggestion + .overlay(alignment: .bottomTrailing) { + if let badge { + Text(badge) + .font(LK.mono(11, .semibold)) + .foregroundStyle(LK.amber) + .padding(.horizontal, 8).padding(.vertical, 3) + .background(Capsule().fill(LK.deep.opacity(0.88))) + .padding(8) + .help("Spieler-Vorschlag – prüfen mit I oder in der Lupe") + } + } + + if let player { + // Matchday line: number in team color + name + HStack(spacing: 8) { + Text(player.number.map(String.init) ?? "–") + .font(.system(size: 20, weight: .heavy, design: .rounded)) + .foregroundStyle(player.team?.shirtColor.swiftUI ?? LK.text2) + .frame(minWidth: 26, alignment: .leading) + VStack(alignment: .leading, spacing: 1) { + Text(player.name + (player.confirmed ? "" : " ?")) + .font(.system(size: 12, weight: .semibold)).foregroundStyle(LK.text).lineLimit(1) + Text(timeLine).font(LK.mono(11)).foregroundStyle(LK.muted) + } + Spacer(minLength: 2) + stars + } + .padding(.top, 9) + } else { + HStack(spacing: 8) { + Circle().fill(item.label?.lkColor ?? LK.faint).frame(width: 9, height: 9) + Text(item.filename).font(LK.mono(11.5, .medium)).foregroundStyle(LK.text) + .lineLimit(1).truncationMode(.middle) + if !item.companions.isEmpty { + Text(item.companions.map { $0.pathExtension.uppercased() }.joined(separator: "+")) + .font(.system(size: 9, weight: .bold)).foregroundStyle(LK.muted) + } + } + .padding(.top, 9) + HStack { + Text(timeLine).font(LK.mono(11)).foregroundStyle(LK.muted) + if !item.iptc.isEmpty(Self.captionField) { + Image(systemName: "text.alignleft").font(.system(size: 9)).foregroundStyle(LK.muted) + .help("Hat Bildunterschrift") + } + Spacer() + stars + } + .padding(.top, 3) + } } + .padding(10) .frame(width: size) - .background( - RoundedRectangle(cornerRadius: 2) - .fill(selected ? ThumbnailCell.selectedFill : Color(white: 0.30)) - ) + .background(RoundedRectangle(cornerRadius: 12).fill(selected ? LK.selected : LK.card)) .overlay( - RoundedRectangle(cornerRadius: 2) - .strokeBorder(isCursor ? Color.accentColor : .clear, lineWidth: 2) + RoundedRectangle(cornerRadius: 12) + .stroke(selected ? LK.amber : (isCursor ? LK.amber.opacity(0.5) : Color.clear), lineWidth: selected ? 2 : 1) ) + .shadow(color: selected ? LK.amber.opacity(0.18) : .clear, radius: 14, y: 6) + .overlay(alignment: .topTrailing) { + // color class as small tab in the corner (matchday shows team instead of the dot line) + if player != nil, let l = item.label { + Circle().fill(l.lkColor).frame(width: 9, height: 9).padding(16) + } + } .task(id: imageURL) { image = ImageLoader.shared.cachedThumbnail(imageURL) if image == nil { image = await ImageLoader.shared.thumbnail(for: imageURL) } } } + + private static let captionField = IPTCField.byID["caption"]! + + private var stars: some View { + HStack(spacing: 1) { + ForEach(0.. some View { + private func dot(_ c: Color, n: Int, help: String) -> some View { let on = state.filter.colors.contains(n) return Button { toggle(color: n) } label: { - ZStack { - if n == 0 { - Image(systemName: "checkerboard.rectangle").font(.system(size: 12)).foregroundStyle(.secondary) - } else { - c - } - if on { Image(systemName: "checkmark").font(.system(size: 10, weight: .bold)).foregroundStyle(.white).shadow(radius: 1) } - } - .frame(width: 20, height: 20) - .overlay(Rectangle().stroke(on ? Color.white : Color.clear, lineWidth: 1.5)) + Circle().fill(c) + .frame(width: 15, height: 15) + .overlay(Circle().stroke(LK.ground, lineWidth: on ? 2 : 0).padding(-2)) + .overlay(Circle().stroke(on ? c : Color.clear, lineWidth: 2).padding(-4)) + .frame(width: 22, height: 22) + .contentShape(Rectangle()) } .buttonStyle(.plain) .help(help) @@ -253,14 +258,13 @@ struct PMStatusBar: View { var body: some View { HStack(spacing: 12) { if state.loadingMetadata { ProgressView().controlSize(.small) } - Text(summary).lineLimit(1).truncationMode(.middle) + Text(summary).lineLimit(1).truncationMode(.middle).foregroundStyle(LK.text2) Spacer() if state.lrPendingCount > 0 { Label("LR: \(state.lrPendingCount)", systemImage: "hourglass") } if uploads.activeCount > 0 { Label(uploads.rate > 0 ? "\(uploads.activeCount) Upload(s) · \(uploads.rateText)" : "\(uploads.activeCount) Upload(s) …", systemImage: "arrow.up.circle.fill") - .foregroundStyle(Color.accentColor) - .monospacedDigit() + .foregroundStyle(LK.amber) .onTapGesture { state.openWindow("tasks") } } if uploads.failedCount > 0 { @@ -270,10 +274,12 @@ struct PMStatusBar: View { } if !state.statusText.isEmpty { Text(state.statusText).foregroundStyle(.secondary).lineLimit(1) } } - .font(.system(size: 11)) - .padding(.horizontal, 10) - .padding(.vertical, 4) - .background(.bar) + .font(LK.mono(11)) + .foregroundStyle(LK.muted) + .padding(.horizontal, 20) + .frame(height: 30) + .background(LK.ground) + .overlay(alignment: .top) { Rectangle().fill(LK.border).frame(height: 1) } } /// "Ausgewählt 1 von 2189 (3,22 MB) | 2189 gesamt | /Users/…/datei.jpg" like PM. @@ -340,19 +346,29 @@ struct PMSidebar: View { .buttonStyle(.borderless).help("Aufgaben-Fenster (⌘⌥U)") } .frame(minHeight: 80, idealHeight: 150) + + if state.matchdayActive { + panel("Spielerinnen") { MatchdayPlayerList() } accessory: { + if state.filter.person != nil || state.filter.team != nil || state.filter.withoutPlayer { + Button("Alle") { state.setTeamFilter(nil) }.buttonStyle(.borderless).font(.system(size: 11)) + } + } + .frame(minHeight: 120, idealHeight: 260) + } } + .background(LK.panel) } private func panel(_ title: String, @ViewBuilder content: () -> C, @ViewBuilder accessory: () -> A) -> some View { VStack(spacing: 0) { HStack { - Text(title).font(.system(size: 12, weight: .semibold)) + LKSectionLabel(title: title) Spacer() accessory() } - .padding(.horizontal, 10) - .padding(.vertical, 5) - .background(Color.secondary.opacity(0.12)) + .padding(.horizontal, 16) + .padding(.top, 14) + .padding(.bottom, 6) content() } } @@ -433,9 +449,12 @@ struct FolderTreeRow: View { .fontWeight(state.folder == url ? .semibold : .regular) Spacer() } - .padding(.leading, CGFloat(depth) * 14 + 6) - .padding(.vertical, 2) - .background(state.folder == url ? Color.accentColor.opacity(0.25) : Color.clear) + .padding(.leading, CGFloat(depth) * 14 + 10) + .padding(.trailing, 8) + .padding(.vertical, 5) + .foregroundStyle(state.folder == url ? LK.amber : LK.text) + .background(RoundedRectangle(cornerRadius: 7).fill(state.folder == url ? LK.selected : Color.clear)) + .padding(.horizontal, 8) .contentShape(Rectangle()) .onTapGesture(count: 1) { state.open(folder: url) diff --git a/Sources/Lichtkasten/Views/IPTCForm.swift b/Sources/Lichtkasten/Views/IPTCForm.swift index 7664a2e..5718e01 100644 --- a/Sources/Lichtkasten/Views/IPTCForm.swift +++ b/Sources/Lichtkasten/Views/IPTCForm.swift @@ -17,19 +17,18 @@ extension IPTCValues { } } -/// PM's blue section header bar. +/// Section header (same order as PM, Leuchttisch look: amber label + hairline). struct PMSectionHeader: View { let title: String var body: some View { - Text(title) - .font(.system(size: 13, weight: .semibold)) - .foregroundStyle(.white) - .frame(maxWidth: .infinity) - .padding(.vertical, 3) - .background( - Capsule().fill(LinearGradient(colors: [Color(red: 0.30, green: 0.55, blue: 0.90), Color(red: 0.14, green: 0.38, blue: 0.75)], - startPoint: .top, endPoint: .bottom)) - ) + HStack(spacing: 10) { + Text(title.uppercased()) + .font(.system(size: 11, weight: .bold)) + .tracking(1.3) + .foregroundStyle(LK.amber) + Rectangle().fill(LK.border).frame(height: 1) + } + .padding(.top, 6) } } @@ -127,7 +126,7 @@ struct PMFieldRow: View { VStack(alignment: .leading, spacing: 2) { Text(field.pmLabel + ":") .font(.system(size: 12)) - .foregroundStyle(isDirty ? Color.accentColor : .primary) + .foregroundStyle(isDirty ? LK.amber : .primary) .help(field.label) // IIM limit: for keywords etc. it applies to each entry, not to the whole field. if let max = field.iimMaxBytes, !text.contains("{") { diff --git a/Sources/Lichtkasten/Views/IPTCInfoWindow.swift b/Sources/Lichtkasten/Views/IPTCInfoWindow.swift index 3a0997a..5b893fa 100644 --- a/Sources/Lichtkasten/Views/IPTCInfoWindow.swift +++ b/Sources/Lichtkasten/Views/IPTCInfoWindow.swift @@ -96,7 +96,7 @@ struct IPTCInfoWindow: View { if !open.isEmpty, let item { VStack(alignment: .leading, spacing: 6) { HStack { - Image(systemName: "person.text.rectangle").foregroundStyle(Color.accentColor) + Image(systemName: "person.text.rectangle").foregroundStyle(LK.amber) Text("Erkannt:").bold() Spacer() if acceptable.count > 1 { @@ -137,7 +137,7 @@ struct IPTCInfoWindow: View { } } .padding(10) - .background(Color.accentColor.opacity(0.10)) + .background(LK.amber.opacity(0.10)) Divider() } } diff --git a/Sources/Lichtkasten/Views/JerseySetupView.swift b/Sources/Lichtkasten/Views/JerseySetupView.swift index f39a0be..e70fe58 100644 --- a/Sources/Lichtkasten/Views/JerseySetupView.swift +++ b/Sources/Lichtkasten/Views/JerseySetupView.swift @@ -171,7 +171,7 @@ struct JerseySetupView: View { RoundedRectangle(cornerRadius: 4) .fill(Color(red: c.r, green: c.g, blue: c.b)) .frame(width: 34, height: 24) - .overlay(RoundedRectangle(cornerRadius: 4).stroke(active ? Color.accentColor : Color.secondary, lineWidth: active ? 3 : 1)) + .overlay(RoundedRectangle(cornerRadius: 4).stroke(active ? LK.amber : Color.secondary, lineWidth: active ? 3 : 1)) Text(shorts ? "Hose" : "Trikot").font(.caption2) } } diff --git a/Sources/Lichtkasten/Views/LoupeInspector.swift b/Sources/Lichtkasten/Views/LoupeInspector.swift new file mode 100644 index 0000000..fa5144b --- /dev/null +++ b/Sources/Lichtkasten/Views/LoupeInspector.swift @@ -0,0 +1,200 @@ +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 = [] + @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)") + } + } + } + .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 { + 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) + } + } +} diff --git a/Sources/Lichtkasten/Views/MatchdayViews.swift b/Sources/Lichtkasten/Views/MatchdayViews.swift new file mode 100644 index 0000000..9cace4b --- /dev/null +++ b/Sources/Lichtkasten/Views/MatchdayViews.swift @@ -0,0 +1,162 @@ +import SwiftUI +import LichtkastenCore + +/// Layout C in the Leuchttisch look: match header with both teams (kit colors from the jersey setup), +/// event + date from IPTC, counters and team filter chips. +struct MatchdayHeader: View { + @EnvironmentObject var state: AppState + + var body: some View { + let teams = state.settings.jersey.teams + let info = state.matchdayEvent + VStack(spacing: 0) { + HStack(spacing: 24) { + if let home = teams.first { + teamBadge(home, alignTrailing: true).frame(maxWidth: .infinity, alignment: .trailing) + } + VStack(spacing: 2) { + Text(info.event.uppercased()) + .font(.system(size: 11, weight: .bold)).tracking(1.4) + .foregroundStyle(LK.muted).lineLimit(1) + Text(info.date).font(.system(size: 22, weight: .heavy, design: .rounded)).foregroundStyle(LK.text) + } + .padding(.horizontal, 18).padding(.vertical, 6) + .background(RoundedRectangle(cornerRadius: 10).fill(LK.deep)) + .overlay(RoundedRectangle(cornerRadius: 10).stroke(LK.border)) + .frame(maxWidth: 420) + if teams.count > 1 { + teamBadge(teams[1], alignTrailing: false).frame(maxWidth: .infinity, alignment: .leading) + } + counters + } + .padding(.horizontal, 20) + .padding(.vertical, 12) + + HStack(spacing: 8) { + chip("Alle", on: state.filter.team == nil && !state.filter.withoutPlayer && state.filter.person == nil) { + state.setTeamFilter(nil) + } + ForEach(teams) { t in + chip(t.name, color: t.shirtColor.swiftUI, on: state.filter.team == t.id) { state.setTeamFilter(t.id) } + } + chip("Ohne Spielerin", on: state.filter.withoutPlayer) { + state.setTeamFilter(nil); state.filter.withoutPlayer = true + } + if let p = state.filter.person { + chip("✕ " + p, on: true) { state.filter.person = nil } + } + Spacer() + Button("Trikot-Erkennung …") { state.showJerseySetup = true } + .buttonStyle(LKButtonStyle(compact: true)) + Button("Nummern erkennen ⌘⇧J") { state.recognizeJerseys() } + .buttonStyle(LKButtonStyle(primary: true, compact: true)) + .disabled(state.jerseyRunning) + } + .padding(.horizontal, 20) + .padding(.bottom, 10) + } + .background(LK.bar) + .overlay(alignment: .bottom) { Rectangle().fill(LK.border).frame(height: 1) } + } + + private func teamBadge(_ t: JerseyTeam, alignTrailing: Bool) -> some View { + HStack(spacing: 12) { + if alignTrailing { name(t) } + RoundedRectangle(cornerRadius: 8) + .fill(t.shirtColor.swiftUI) + .frame(width: 32, height: 32) + .overlay(RoundedRectangle(cornerRadius: 8).stroke((t.shortsColor ?? t.shirtColor).swiftUI, lineWidth: 3)) + .overlay(RoundedRectangle(cornerRadius: 8).stroke(LK.border, lineWidth: 1)) + if !alignTrailing { name(t) } + } + } + + private func name(_ t: JerseyTeam) -> some View { + Text(t.name.uppercased()) + .font(.system(size: 22, weight: .heavy, design: .rounded)) + .foregroundStyle(LK.text) + .lineLimit(1) + .minimumScaleFactor(0.6) + } + + private var counters: some View { + let tagged = state.items.filter(\.tagged).count + let withPlayer = state.items.filter { state.playerInfo(for: $0)?.confirmed == true }.count + let open = state.items.filter { !state.openSuggestions(for: $0.id).isEmpty }.count + return HStack(spacing: 18) { + counter(tagged, "GETAGGT", highlight: true) + counter(withPlayer, "MIT SPIELERIN") + counter(open, "OFFEN") + } + } + + private func counter(_ n: Int, _ label: String, highlight: Bool = false) -> some View { + VStack(alignment: .trailing, spacing: 0) { + Text("\(n)").font(.system(size: 22, weight: .heavy, design: .rounded)).foregroundStyle(highlight ? LK.amber : LK.text) + Text(label).font(.system(size: 10, weight: .bold)).tracking(1).foregroundStyle(LK.muted) + } + } + + private func chip(_ title: String, color: Color? = nil, on: Bool, action: @escaping () -> Void) -> some View { + Button(action: action) { + HStack(spacing: 6) { + if let color { Circle().fill(color).frame(width: 9, height: 9).overlay(Circle().stroke(LK.border)) } + Text(title).font(.system(size: 12, weight: .bold)) + } + .foregroundStyle(on ? LK.onAmber : LK.text2) + .padding(.horizontal, 12).frame(height: 28) + .background(Capsule().fill(on ? LK.amber : LK.raised)) + .overlay(Capsule().stroke(on ? Color.clear : LK.borderStrong)) + } + .buttonStyle(.plain) + } +} + +/// Sidebar list of players in this folder with number of images – click filters. +struct MatchdayPlayerList: View { + @EnvironmentObject var state: AppState + + var body: some View { + let players = state.playerCounts + ScrollView { + VStack(alignment: .leading, spacing: 2) { + if players.isEmpty { + Text("Noch keine Spielerinnen – Nummern erkennen (⌘⇧J) oder Vorschläge annehmen.") + .font(.system(size: 12)).foregroundStyle(LK.muted).padding(.horizontal, 16) + } + ForEach(players) { p in + let on = state.filter.person == p.name + Button { + state.filter.team = nil; state.filter.withoutPlayer = false + state.filter.person = on ? nil : p.name + } label: { + HStack(spacing: 10) { + Text(p.number.map(String.init) ?? "–") + .font(LK.mono(12, .bold)) + .foregroundStyle(textColor(on: p.team?.shirtColor)) + .frame(width: 28, height: 22) + .background(RoundedRectangle(cornerRadius: 5).fill(p.team?.shirtColor.swiftUI ?? LK.raised)) + Text(p.name).font(.system(size: 13)).lineLimit(1) + Spacer() + Text("\(p.count)").font(LK.mono(12)).foregroundStyle(LK.muted) + } + .foregroundStyle(on ? LK.amber : LK.text) + .padding(.horizontal, 10).padding(.vertical, 5) + .background(RoundedRectangle(cornerRadius: 7).fill(on ? LK.selected : Color.clear)) + .contentShape(Rectangle()) + } + .buttonStyle(.plain) + .padding(.horizontal, 6) + } + } + .padding(.bottom, 8) + } + } + + /// Readable number on the kit color (dark text on light kits). + private func textColor(on c: KitColor?) -> Color { + guard let c else { return LK.text } + let luminance = 0.299 * c.r + 0.587 * c.g + 0.114 * c.b + return luminance > 0.6 ? LK.onAmber : .white + } +} diff --git a/Sources/Lichtkasten/Views/PreviewView.swift b/Sources/Lichtkasten/Views/PreviewView.swift index 0348e25..daa3311 100644 --- a/Sources/Lichtkasten/Views/PreviewView.swift +++ b/Sources/Lichtkasten/Views/PreviewView.swift @@ -7,18 +7,28 @@ struct PreviewView: View { @State private var fullResLoadedFor: String? var body: some View { - ZStack(alignment: .bottom) { - Color.black - if let image { - ZoomableImageView(image: image, maxZoom: CGFloat(state.settings.maxZoom), request: state.zoomRequest) { mag, fit in - state.zoom100 = !fit - state.zoomPercent = Int((mag * 100).rounded()) - if !fit { Task { await loadFullRes() } } + // Layout B: loupe · filmstrip · IPTC panel – in the Leuchttisch look + HStack(spacing: 0) { + VStack(spacing: 0) { + ZStack(alignment: .bottom) { + LK.deep + if let image { + ZoomableImageView(image: image, maxZoom: CGFloat(state.settings.maxZoom), request: state.zoomRequest) { mag, fit in + state.zoom100 = !fit + state.zoomPercent = Int((mag * 100).rounded()) + if !fit { Task { await loadFullRes() } } + } + } else { + ProgressView() + } + if let item = state.cursorItem { infoBar(item) } } - } else { - ProgressView() + Filmstrip() + } + if state.settings.loupePanel { + Divider().overlay(LK.border) + LoupeInspector().frame(width: 380) } - if let item = state.cursorItem { infoBar(item) } } .task(id: state.cursorID) { await load() } } @@ -45,31 +55,82 @@ struct PreviewView: View { } private func infoBar(_ item: PhotoItem) -> some View { - HStack(spacing: 14) { - Image(systemName: item.tagged ? "checkmark.square.fill" : "square") - Text(item.filename).bold() - HStack(spacing: 1) { - ForEach(1...5, id: \.self) { n in Image(systemName: n <= item.rating ? "star.fill" : "star") } - } - .foregroundStyle(.yellow) - if let l = item.label { Circle().fill(l.color).frame(width: 10, height: 10) } + HStack(spacing: 12) { + Text([item.exif["FocalLength"], item.exif["FNumber"].map { "f/\($0)" }, + item.exif["ExposureTime"].map { "\($0) s" }, item.exif["ISO"].map { "ISO \($0)" }] + .compactMap { $0 }.joined(separator: " ")) + .font(LK.mono(12)) + .foregroundStyle(LK.text2) Spacer() - Text([item.exif["Model"], item.exif["LensModel"], item.exif["FocalLength"], - item.exif["ExposureTime"].map { "\($0) s" }, item.exif["FNumber"].map { "f/\($0)" }, - item.exif["ISO"].map { "ISO \($0)" }].compactMap { $0 }.joined(separator: " · ")) - .foregroundStyle(.secondary) - HStack(spacing: 4) { + HStack(spacing: 6) { Button { state.zoom(.zoomOut) } label: { Image(systemName: "minus.magnifyingglass") } - Button { state.zoom(.fit) } label: { Text(state.zoom100 ? "\(state.zoomPercent) %" : "Einpassen").monospacedDigit().frame(minWidth: 70) } + .buttonStyle(LKButtonStyle(compact: true)) + Button { state.zoom(.fit) } label: { Text(state.zoom100 ? "\(state.zoomPercent) %" : "Einpassen").font(LK.mono(12)) } + .buttonStyle(LKButtonStyle(compact: true)) .help("Einpassen (Z)") - Button { state.zoom(.actual) } label: { Text("100 %") } + Button { state.zoom(.actual) } label: { Text("100 %").font(LK.mono(12)) } + .buttonStyle(LKButtonStyle(compact: true)) Button { state.zoom(.zoomIn) } label: { Image(systemName: "plus.magnifyingglass") } + .buttonStyle(LKButtonStyle(compact: true)) + Button { state.settings.loupePanel.toggle() } label: { Image(systemName: "sidebar.right") } + .buttonStyle(LKButtonStyle(compact: true)) + .help("IPTC-Panel ein/aus") } - .buttonStyle(.borderless) } - .font(.callout) - .padding(.horizontal, 14) - .padding(.vertical, 8) - .background(.ultraThinMaterial) + .padding(.horizontal, 16) + .padding(.vertical, 10) + .background(LK.ground.opacity(0.85)) + } +} + +/// Filmstrip under the loupe (layout B): neighbours of the current image, click to jump. +struct Filmstrip: View { + @EnvironmentObject var state: AppState + + var body: some View { + ScrollViewReader { proxy in + ScrollView(.horizontal, showsIndicators: false) { + LazyHStack(spacing: 8) { + ForEach(state.visible) { item in + FilmstripCell(item: item, url: state.previewURL(for: item), current: item.id == state.cursorID) + .equatable() + .id(item.id) + .onTapGesture { state.cursorID = item.id; state.selection = [item.id] } + } + } + .padding(.horizontal, 14) + .padding(.vertical, 12) + } + .frame(height: 104) + .background(LK.ground) + .overlay(alignment: .top) { Rectangle().fill(LK.border).frame(height: 1) } + .onChange(of: state.cursorID) { _, id in if let id { withAnimation(.easeOut(duration: 0.15)) { proxy.scrollTo(id, anchor: .center) } } } + .onAppear { if let id = state.cursorID { proxy.scrollTo(id, anchor: .center) } } + } + } +} + +struct FilmstripCell: View, Equatable { + let item: PhotoItem + let url: URL + let current: Bool + @State private var image: NSImage? + + static func == (a: FilmstripCell, b: FilmstripCell) -> Bool { a.item == b.item && a.url == b.url && a.current == b.current } + + var body: some View { + ZStack(alignment: .leading) { + Rectangle().fill(LK.deep) + if let image { Image(nsImage: image).resizable().scaledToFill() } + Rectangle().fill(item.label?.lkColor ?? .clear).frame(width: 4) + } + .frame(width: 118, height: 78) + .clipShape(RoundedRectangle(cornerRadius: 6)) + .overlay(RoundedRectangle(cornerRadius: 6).stroke(current ? LK.amber : Color.clear, lineWidth: 2)) + .opacity(current ? 1 : 0.72) + .task(id: url) { + image = ImageLoader.shared.cachedThumbnail(url) + if image == nil { image = await ImageLoader.shared.thumbnail(for: url) } + } } } diff --git a/Sources/Lichtkasten/Views/TasksWindow.swift b/Sources/Lichtkasten/Views/TasksWindow.swift index 17deecf..c14b669 100644 --- a/Sources/Lichtkasten/Views/TasksWindow.swift +++ b/Sources/Lichtkasten/Views/TasksWindow.swift @@ -39,7 +39,7 @@ struct TasksWindow: View { HStack { Toggle("Einzelne Upload-Dateien", isOn: $showFiles).toggleStyle(.checkbox) if uploads.rate > 0 { - Label(uploads.rateText, systemImage: "speedometer").monospacedDigit().foregroundStyle(Color.accentColor) + Label(uploads.rateText, systemImage: "speedometer").monospacedDigit().foregroundStyle(LK.amber) } Spacer() Button("Fehlgeschlagene Uploads wiederholen") { uploads.retryFailed() }.disabled(uploads.failedCount == 0) diff --git a/Sources/Lichtkasten/Views/Theme.swift b/Sources/Lichtkasten/Views/Theme.swift new file mode 100644 index 0000000..ce220d6 --- /dev/null +++ b/Sources/Lichtkasten/Views/Theme.swift @@ -0,0 +1,140 @@ +import SwiftUI +import LichtkastenCore + +/// "Leuchttisch" design language: warm graphite ground, amber light as the single accent. +enum LK { + static func hex(_ v: UInt32) -> Color { + Color(red: Double((v >> 16) & 0xFF) / 255, green: Double((v >> 8) & 0xFF) / 255, blue: Double(v & 0xFF) / 255) + } + + // grounds (dark → light) + static let deep = hex(0x120F0B) // inputs, wells + static let ground = hex(0x16130E) // window / contact sheet + static let panel = hex(0x1A1610) // sidebar, side panels + static let bar = hex(0x1C1812) // header bars + static let card = hex(0x1E1A14) // thumbnail cards + static let raised = hex(0x221D16) // buttons, boxes + static let selected = hex(0x2A2318) // selected card / row + static let border = hex(0x2A241B) + static let borderStrong = hex(0x2E271D) + + // text + static let text = hex(0xEDE6DA) + static let text2 = hex(0xB8AE9E) + static let muted = hex(0x8C8272) + static let faint = hex(0x4A4235) + + // accent: the light of the light table + static let amber = hex(0xF2B544) + static let amberSoft = hex(0xF2B544).opacity(0.18) + static let onAmber = hex(0x16130E) + + static let green = hex(0x5DBB63) + static let red = hex(0xE0645A) + + static let mono = Font.system(size: 12, design: .monospaced) + static func mono(_ size: CGFloat, _ weight: Font.Weight = .regular) -> Font { .system(size: size, weight: weight, design: .monospaced) } +} + +extension ColorLabel { + /// Color classes in the Leuchttisch palette (same order as PM: 1 red … 8 gray). + var lkColor: Color { + switch self { + case .red: return LK.hex(0xE0645A) + case .yellow: return LK.hex(0xE4B34C) + case .green: return LK.hex(0x5DBB63) + case .blue: return LK.hex(0x4F8FE0) + case .purple: return LK.hex(0xC467D6) + case .cyan: return LK.hex(0x45BFC9) + case .orange: return LK.hex(0xE58A3B) + case .gray: return LK.hex(0x7A7166) + } + } +} + +extension KitColor { + var swiftUI: Color { Color(red: r, green: g, blue: b) } +} + +/// Small uppercase section label ("FAVORITEN"). +struct LKSectionLabel: View { + let title: String + var body: some View { + Text(title.uppercased()) + .font(.system(size: 11, weight: .bold)) + .tracking(1.2) + .foregroundStyle(LK.muted) + } +} + +/// Primary action (amber) and secondary (raised) buttons. +struct LKButtonStyle: ButtonStyle { + var primary = false + var compact = false + + func makeBody(configuration: Configuration) -> some View { + configuration.label + .font(.system(size: compact ? 12 : 13, weight: primary ? .bold : .semibold)) + .foregroundStyle(primary ? LK.onAmber : LK.text) + .padding(.horizontal, compact ? 10 : 14) + .frame(minHeight: compact ? 26 : 32) + .background( + RoundedRectangle(cornerRadius: compact ? 7 : 9) + .fill(primary ? LK.amber : LK.raised) + ) + .overlay( + RoundedRectangle(cornerRadius: compact ? 7 : 9) + .stroke(primary ? Color.clear : LK.borderStrong, lineWidth: 1) + ) + .opacity(configuration.isPressed ? 0.75 : 1) + .contentShape(Rectangle()) + } +} + +/// Segmented pill control ("Alle | Getaggt | Vorschläge"). +struct LKSegmented: View { + let options: [(T, String)] + @Binding var selection: T + + var body: some View { + HStack(spacing: 0) { + ForEach(options.indices, id: \.self) { i in + let opt = options[i] + let on = opt.0 == selection + Button { selection = opt.0 } label: { + Text(opt.1) + .font(.system(size: 12, weight: on ? .bold : .semibold)) + .foregroundStyle(on ? LK.amber : LK.text2) + .padding(.horizontal, 12) + .frame(height: 26) + .background(RoundedRectangle(cornerRadius: 7).fill(on ? LK.selected : Color.clear)) + .contentShape(Rectangle()) + } + .buttonStyle(.plain) + } + } + .padding(3) + .background(RoundedRectangle(cornerRadius: 10).fill(LK.deep)) + .overlay(RoundedRectangle(cornerRadius: 10).stroke(LK.border)) + } +} + +/// Text field look used in the Leuchttisch panels. +struct LKFieldBackground: ViewModifier { + func body(content: Content) -> some View { + content + .padding(.horizontal, 8) + .padding(.vertical, 6) + .background(RoundedRectangle(cornerRadius: 8).fill(LK.deep)) + .overlay(RoundedRectangle(cornerRadius: 8).stroke(LK.borderStrong)) + } +} + +extension View { + func lkField() -> some View { modifier(LKFieldBackground()) } + + /// Every window: dark Leuchttisch ground and amber accent. + func lkWindow() -> some View { + self.preferredColorScheme(.dark).tint(LK.amber).background(LK.ground) + } +}