Lichtkasten v0.1: Culling, IPTC (PM-kompatibel), Vorlagen, FTP/Immich, Lightroom-Bridge
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
37 files changed
+4431
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import SwiftUI
|
||||
import LichtkastenCore
|
||||
|
||||
struct PreviewView: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@State private var image: NSImage?
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .bottom) {
|
||||
Color.black
|
||||
if let image {
|
||||
if state.zoom100 {
|
||||
ScrollView([.horizontal, .vertical]) {
|
||||
Image(nsImage: image)
|
||||
.frame(width: image.size.width / (NSScreen.main?.backingScaleFactor ?? 2),
|
||||
height: image.size.height / (NSScreen.main?.backingScaleFactor ?? 2))
|
||||
}
|
||||
} else {
|
||||
Image(nsImage: image).resizable().scaledToFit().padding(8)
|
||||
}
|
||||
} else {
|
||||
ProgressView()
|
||||
}
|
||||
if let item = state.cursorItem { infoBar(item) }
|
||||
}
|
||||
.onTapGesture(count: 2) { state.previewMode = false }
|
||||
.task(id: "\(state.cursorID ?? "")|\(state.zoom100)") { await load() }
|
||||
}
|
||||
|
||||
private func load() async {
|
||||
guard let item = state.cursorItem else { image = nil; return }
|
||||
let url = state.previewURL(for: item)
|
||||
// Show the thumbnail immediately, then the big preview.
|
||||
image = ImageLoader.shared.cachedPreview(url) ?? ImageLoader.shared.cachedThumbnail(url)
|
||||
let maxPixel = state.zoom100 ? 8000 : 3200
|
||||
if let big = await ImageLoader.shared.preview(for: url, maxPixel: maxPixel), state.cursorID == item.id {
|
||||
image = big
|
||||
}
|
||||
}
|
||||
|
||||
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) }
|
||||
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)
|
||||
Text(state.zoom100 ? "100 % (Z)" : "Einpassen (Z)").foregroundStyle(.secondary)
|
||||
}
|
||||
.font(.callout)
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.vertical, 8)
|
||||
.background(.ultraThinMaterial)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user