Design-Fixes: Einstellungen nicht mehr abgeschnitten (gruppierte Formulare, warme Zeilen), Ingest-Kartenliste als Karten mit Leerzustand, Upload-Fenster neu (Ziel-Karten, Optionen, Zusammenfassung)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
1 parent
54f5742a60
commit
22b2611228
4 files changed
+245
-76
No files matched your search
@@ -1,73 +1,185 @@
|
||||
import SwiftUI
|
||||
import LichtkastenCore
|
||||
|
||||
/// ⌘U – PM "Upload Photos" dialog for the selected images.
|
||||
/// ⌘U – upload dialog in the Leuchttisch look: destinations as cards, options of the chosen one, summary.
|
||||
struct UploadWindow: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@Environment(\.dismissWindow) private var dismissWindow
|
||||
@AppStorage("lastUploadTarget") private var target = ""
|
||||
|
||||
private var destination: FTPDestination? { state.settings.ftpDestinations.first { $0.id.uuidString == target } }
|
||||
private var destIndex: Int? { state.settings.ftpDestinations.firstIndex { $0.id.uuidString == target } }
|
||||
|
||||
private var variant: UploadVariant {
|
||||
target == "immich" ? state.settings.immich.variant : destination?.variant ?? .jpeg
|
||||
}
|
||||
|
||||
private var files: [URL] { state.selectedItems.flatMap { state.uploadFiles(for: $0, variant: variant) } }
|
||||
private var totalBytes: Int64 {
|
||||
files.reduce(0) { sum, f in sum + (((try? FileManager.default.attributesOfItem(atPath: f.path)[.size]) as? NSNumber)?.int64Value ?? 0) }
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 14) {
|
||||
Text("Bilder hochladen").font(.title3.bold())
|
||||
Form {
|
||||
Picker("Ziel", selection: $target) {
|
||||
Text("– bitte wählen –").tag("")
|
||||
ForEach(state.settings.ftpDestinations) { d in Text(d.name).tag(d.id.uuidString) }
|
||||
if state.settings.immich.enabled { Text("Immich").tag("immich") }
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
// header
|
||||
HStack(spacing: 14) {
|
||||
Image(systemName: "icloud.and.arrow.up")
|
||||
.font(.system(size: 20, weight: .semibold))
|
||||
.foregroundStyle(LK.onAmber)
|
||||
.frame(width: 42, height: 42)
|
||||
.background(RoundedRectangle(cornerRadius: 11).fill(LK.amber))
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("Bilder hochladen").font(.system(size: 18, weight: .bold)).foregroundStyle(LK.text)
|
||||
Text(summary).font(LK.mono(12)).foregroundStyle(LK.text2)
|
||||
}
|
||||
if let d = destination {
|
||||
LabeledContent("Server", value: "\(d.proto.rawValue) · \(d.host):\(d.port)")
|
||||
if let i = state.settings.ftpDestinations.firstIndex(where: { $0.id == d.id }) {
|
||||
TextField("Zielordner", text: $state.settings.ftpDestinations[i].remoteDirectory)
|
||||
TextField("Umbenennen (leer = Originalname)", text: $state.settings.ftpDestinations[i].renamePattern)
|
||||
Picker("Dateien", selection: $state.settings.ftpDestinations[i].variant) {
|
||||
ForEach(UploadVariant.allCases, id: \.self) { Text($0.rawValue).tag($0) }
|
||||
Spacer()
|
||||
}
|
||||
.padding(22)
|
||||
|
||||
Rectangle().fill(LK.border).frame(height: 1)
|
||||
|
||||
ScrollView {
|
||||
VStack(alignment: .leading, spacing: 18) {
|
||||
LKSectionLabel(title: "Ziel")
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 220), spacing: 12)], spacing: 12) {
|
||||
ForEach(state.settings.ftpDestinations) { d in
|
||||
destinationCard(id: d.id.uuidString, icon: "server.rack", title: d.name,
|
||||
subtitle: d.host.isEmpty ? "Server fehlt" : d.host,
|
||||
detail: d.remoteDirectory, warning: credentialsMissing(d))
|
||||
}
|
||||
if state.settings.immich.enabled {
|
||||
destinationCard(id: "immich", icon: "photo.stack", title: "Immich",
|
||||
subtitle: URL(string: state.settings.immich.serverURL)?.host ?? state.settings.immich.serverURL,
|
||||
detail: albumPreview, warning: false)
|
||||
}
|
||||
}
|
||||
if d.username.isEmpty || Keychain.get(d.keychainAccount) == nil {
|
||||
Label("Benutzer/Passwort fehlen – Einstellungen → FTP", systemImage: "exclamationmark.triangle.fill")
|
||||
.foregroundStyle(.orange)
|
||||
|
||||
if let i = destIndex {
|
||||
LKSectionLabel(title: "Optionen").padding(.top, 4)
|
||||
VStack(spacing: 0) {
|
||||
optionRow("Zielordner") {
|
||||
TextField("/", text: $state.settings.ftpDestinations[i].remoteDirectory).textFieldStyle(.plain).lkField()
|
||||
}
|
||||
divider
|
||||
optionRow("Umbenennen") {
|
||||
TextField("leer = Originalname, z. B. {isodate}_{filenamebase}", text: $state.settings.ftpDestinations[i].renamePattern)
|
||||
.textFieldStyle(.plain).lkField()
|
||||
}
|
||||
divider
|
||||
optionRow("Dateien") {
|
||||
LKSegmented(options: UploadVariant.allCases.map { ($0, $0.rawValue) },
|
||||
selection: $state.settings.ftpDestinations[i].variant)
|
||||
}
|
||||
}
|
||||
.background(RoundedRectangle(cornerRadius: 12).fill(LK.card))
|
||||
.overlay(RoundedRectangle(cornerRadius: 12).stroke(LK.border))
|
||||
} else if target == "immich" {
|
||||
LKSectionLabel(title: "Optionen").padding(.top, 4)
|
||||
VStack(spacing: 0) {
|
||||
optionRow("Album-Muster") {
|
||||
TextField("{event}", text: $state.settings.immich.albumName).textFieldStyle(.plain).lkField()
|
||||
}
|
||||
divider
|
||||
optionRow("Dateien") {
|
||||
LKSegmented(options: UploadVariant.allCases.map { ($0, $0.rawValue) }, selection: $state.settings.immich.variant)
|
||||
}
|
||||
}
|
||||
.background(RoundedRectangle(cornerRadius: 12).fill(LK.card))
|
||||
.overlay(RoundedRectangle(cornerRadius: 12).stroke(LK.border))
|
||||
}
|
||||
|
||||
if files.count < state.selectedItems.count {
|
||||
Label("\(state.selectedItems.count - files.count) Bild(er) ohne JPEG – zuerst in Lightroom exportieren (⌘⌥L).",
|
||||
systemImage: "exclamationmark.triangle.fill")
|
||||
.font(.system(size: 12)).foregroundStyle(LK.amber)
|
||||
}
|
||||
if let d = destination, credentialsMissing(d) {
|
||||
Label("Benutzer oder Passwort fehlen – „Server verwalten …“", systemImage: "key.fill")
|
||||
.font(.system(size: 12)).foregroundStyle(LK.red)
|
||||
}
|
||||
} else if target == "immich" {
|
||||
LabeledContent("Server", value: state.settings.immich.serverURL)
|
||||
let albums = Set(state.selectedItems.map { state.immichAlbum(for: $0) }.filter { !$0.isEmpty })
|
||||
LabeledContent("Album", value: albums.isEmpty ? "– kein Album –" : albums.sorted().joined(separator: ", "))
|
||||
TextField("Album-Muster", text: $state.settings.immich.albumName, prompt: Text("{event}"))
|
||||
}
|
||||
LabeledContent("Auswahl", value: "\(state.selectedItems.count) Bild(er) → \(files.count) Datei(en)")
|
||||
if files.count < state.selectedItems.count {
|
||||
Text("Einige Bilder haben kein JPEG – zuerst in Lightroom exportieren (⌘⌥L).")
|
||||
.font(.caption).foregroundStyle(.orange)
|
||||
}
|
||||
.padding(22)
|
||||
}
|
||||
.lkForm()
|
||||
|
||||
Rectangle().fill(LK.border).frame(height: 1)
|
||||
HStack {
|
||||
SettingsLink { Text("Server verwalten …") }
|
||||
SettingsLink { Text("Server verwalten …") }.buttonStyle(LKButtonStyle())
|
||||
Spacer()
|
||||
Button("Abbrechen") { dismissWindow(id: "upload") }.keyboardShortcut(.cancelAction)
|
||||
Button("Hochladen") {
|
||||
Button("Abbrechen") { dismissWindow(id: "upload") }
|
||||
.buttonStyle(LKButtonStyle())
|
||||
.keyboardShortcut(.cancelAction)
|
||||
Button("\(files.count) Datei(en) hochladen") {
|
||||
state.upload(to: target)
|
||||
state.openWindow("tasks")
|
||||
dismissWindow(id: "upload")
|
||||
}
|
||||
.buttonStyle(LKButtonStyle(primary: true))
|
||||
.keyboardShortcut(.defaultAction)
|
||||
.buttonStyle(.borderedProminent)
|
||||
.disabled(target.isEmpty || files.isEmpty)
|
||||
}
|
||||
.padding(18)
|
||||
}
|
||||
.padding(18)
|
||||
.frame(width: 560)
|
||||
.frame(width: 620)
|
||||
.frame(minHeight: 460)
|
||||
.background(LK.ground)
|
||||
.onAppear {
|
||||
if target.isEmpty, let first = state.settings.ftpDestinations.first { target = first.id.uuidString }
|
||||
if target.isEmpty || (destination == nil && target != "immich"),
|
||||
let first = state.settings.ftpDestinations.first { target = first.id.uuidString }
|
||||
}
|
||||
}
|
||||
|
||||
private var summary: String {
|
||||
let n = state.selectedItems.count
|
||||
let size = ByteCountFormatter.string(fromByteCount: totalBytes, countStyle: .file)
|
||||
return "\(n) Bild\(n == 1 ? "" : "er") ausgewählt · \(files.count) Datei(en) · \(size)"
|
||||
}
|
||||
|
||||
private var albumPreview: String {
|
||||
let albums = Set(state.selectedItems.map { state.immichAlbum(for: $0) }.filter { !$0.isEmpty })
|
||||
return albums.isEmpty ? "kein Album" : "Album: " + albums.sorted().joined(separator: ", ")
|
||||
}
|
||||
|
||||
private func credentialsMissing(_ d: FTPDestination) -> Bool {
|
||||
d.username.isEmpty || Keychain.get(d.keychainAccount) == nil
|
||||
}
|
||||
|
||||
private var divider: some View { Rectangle().fill(LK.border).frame(height: 1).padding(.leading, 14) }
|
||||
|
||||
private func optionRow<C: View>(_ label: String, @ViewBuilder content: () -> C) -> some View {
|
||||
HStack(spacing: 14) {
|
||||
Text(label).font(.system(size: 13)).foregroundStyle(LK.text2).frame(width: 110, alignment: .leading)
|
||||
content()
|
||||
}
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.vertical, 10)
|
||||
}
|
||||
|
||||
private func destinationCard(id: String, icon: String, title: String, subtitle: String, detail: String, warning: Bool) -> some View {
|
||||
let on = target == id
|
||||
return Button { target = id } label: {
|
||||
HStack(alignment: .top, spacing: 12) {
|
||||
Image(systemName: icon)
|
||||
.font(.system(size: 16, weight: .semibold))
|
||||
.foregroundStyle(on ? LK.onAmber : LK.text2)
|
||||
.frame(width: 34, height: 34)
|
||||
.background(RoundedRectangle(cornerRadius: 9).fill(on ? LK.amber : LK.raised))
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
HStack(spacing: 6) {
|
||||
Text(title).font(.system(size: 14, weight: .bold)).foregroundStyle(LK.text).lineLimit(1)
|
||||
if warning { Image(systemName: "key.fill").font(.system(size: 10)).foregroundStyle(LK.red) }
|
||||
}
|
||||
Text(subtitle).font(LK.mono(11)).foregroundStyle(LK.muted).lineLimit(1).truncationMode(.middle)
|
||||
Text(detail).font(LK.mono(11)).foregroundStyle(on ? LK.amber : LK.text2).lineLimit(1).truncationMode(.middle)
|
||||
}
|
||||
Spacer(minLength: 0)
|
||||
if on { Image(systemName: "checkmark.circle.fill").foregroundStyle(LK.amber) }
|
||||
}
|
||||
.padding(12)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.background(RoundedRectangle(cornerRadius: 12).fill(on ? LK.selected : LK.card))
|
||||
.overlay(RoundedRectangle(cornerRadius: 12).stroke(on ? LK.amber : LK.border, lineWidth: on ? 2 : 1))
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user