WP-4a: menu-bar shell, AppModel, session strip per SPEC-A2b + integration contracts
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
import ShotdeckCore
|
||||
|
||||
struct SessionStrip: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
|
||||
var body: some View {
|
||||
if model.session.captures.isEmpty {
|
||||
Text("Nothing captured yet.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
.frame(maxWidth: .infinity, minHeight: 64, alignment: .leading)
|
||||
} else {
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(alignment: .top, spacing: 6) {
|
||||
ForEach(model.session.captures) { capture in
|
||||
SessionThumb(capture: capture)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(height: 64)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct SessionThumb: View {
|
||||
@Environment(AppModel.self) private var model
|
||||
let capture: Capture
|
||||
@State private var hovering = false
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .topLeading) {
|
||||
thumbnail
|
||||
Text("\(capture.sequence)")
|
||||
.font(.system(size: 9, weight: .bold))
|
||||
.foregroundStyle(.white)
|
||||
.padding(.horizontal, 4)
|
||||
.padding(.vertical, 1)
|
||||
.background(.black.opacity(0.65))
|
||||
.clipShape(RoundedRectangle(cornerRadius: 2, style: .continuous))
|
||||
.padding(3)
|
||||
if hovering {
|
||||
VStack {
|
||||
Spacer()
|
||||
Button("Remove") {
|
||||
Task { await model.removeCapture(id: capture.id) }
|
||||
}
|
||||
.font(.system(size: 10, weight: .semibold))
|
||||
.buttonStyle(.plain)
|
||||
.foregroundStyle(.white)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.vertical, 3)
|
||||
.background(.black.opacity(0.7))
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(height: 64)
|
||||
.clipped()
|
||||
.onHover { hovering = $0 }
|
||||
.help(DubaiTime.stamp(capture.capturedAt))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var thumbnail: some View {
|
||||
let url = model.paths.sessionDirectory(model.session.id).appendingPathComponent(capture.fileName)
|
||||
if let image = NSImage(contentsOf: url) {
|
||||
Image(nsImage: image)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(height: 64)
|
||||
} else {
|
||||
Rectangle()
|
||||
.fill(Color.secondary.opacity(0.2))
|
||||
.frame(width: 64, height: 64)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user