PM-Prefs (Tag/Farbe/Sterne) lesen+schreiben, Datum Capture Time, Zoom bis einstellbarem Maximum, Ingest im PM-Aufbau (gesperrt/RAW-Filter, Sequenz, inkrementell, Auswerfen), App-Icon
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
c0ee93995f
commit
8effd1af0c
25 files changed
+885
-131
No files matched your search
@@ -4,37 +4,43 @@ import LichtkastenCore
|
||||
struct PreviewView: View {
|
||||
@EnvironmentObject var state: AppState
|
||||
@State private var image: NSImage?
|
||||
@State private var fullResLoadedFor: String?
|
||||
|
||||
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)
|
||||
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) }
|
||||
}
|
||||
.onTapGesture(count: 2) { state.previewMode = false }
|
||||
.task(id: "\(state.cursorID ?? "")|\(state.zoom100)") { await load() }
|
||||
.task(id: state.cursorID) { 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 {
|
||||
if let big = await ImageLoader.shared.preview(for: url, maxPixel: state.zoom100 ? 9000 : 3200), state.cursorID == item.id {
|
||||
image = big
|
||||
fullResLoadedFor = state.zoom100 ? item.id : nil
|
||||
}
|
||||
}
|
||||
|
||||
/// Zooming in needs the full-resolution image (fit view uses a 3200 px preview).
|
||||
private func loadFullRes() async {
|
||||
guard let item = state.cursorItem, fullResLoadedFor != item.id else { return }
|
||||
fullResLoadedFor = item.id
|
||||
let url = state.previewURL(for: item)
|
||||
if let full = await Task.detached(priority: .userInitiated, operation: { ImageLoader.makeImage(url, maxPixel: 9000, minAcceptable: 4000) }).value,
|
||||
state.cursorID == item.id {
|
||||
image = full
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +58,14 @@ struct PreviewView: View {
|
||||
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)
|
||||
HStack(spacing: 4) {
|
||||
Button { state.zoom(.zoomOut) } label: { Image(systemName: "minus.magnifyingglass") }
|
||||
Button { state.zoom(.fit) } label: { Text(state.zoom100 ? "\(state.zoomPercent) %" : "Einpassen").monospacedDigit().frame(minWidth: 70) }
|
||||
.help("Einpassen (Z)")
|
||||
Button { state.zoom(.actual) } label: { Text("100 %") }
|
||||
Button { state.zoom(.zoomIn) } label: { Image(systemName: "plus.magnifyingglass") }
|
||||
}
|
||||
.buttonStyle(.borderless)
|
||||
}
|
||||
.font(.callout)
|
||||
.padding(.horizontal, 14)
|
||||
|
||||
Reference in new issue
Block a user