53 lines
1.6 KiB
Swift
53 lines
1.6 KiB
Swift
import SwiftUI
|
|||
|
|
|
||
|
|
struct CapturesView: View {
|
||
|
|
let captures: [Capture]
|
||
|
|
|
||
|
|
var body: some View {
|
||
|
|
ScrollView {
|
||
|
|
LazyVStack(alignment: .leading, spacing: 20) {
|
||
|
|
ForEach(captures.reversed()) { c in
|
||
|
|
CaptureItem(capture: c)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.padding(16)
|
||
|
|
}
|
||
|
|
.background(Palette.bg)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private struct CaptureItem: View {
|
||
|
|
let capture: Capture
|
||
|
|
@ViewState private var image: PlatformImage?
|
||
|
|
|
||
|
|
var body: some View {
|
||
|
|
VStack(alignment: .leading, spacing: 6) {
|
||
|
|
HStack(alignment: .firstTextBaseline, spacing: 8) {
|
||
|
|
Text(capture.tool)
|
||
|
|
.font(Fonts.font(13, weight: 700))
|
||
|
|
Text(clockText(capture.when))
|
||
|
|
.foregroundStyle(Palette.muted)
|
||
|
|
Spacer(minLength: 0)
|
||
|
|
}
|
||
|
|
if !capture.note.isEmpty {
|
||
|
|
Text(verbatim: capture.note)
|
||
|
|
.font(Fonts.font(12, mono: true))
|
||
|
|
.foregroundStyle(Palette.muted)
|
||
|
|
.lineLimit(4)
|
||
|
|
.textSelection(.enabled)
|
||
|
|
}
|
||
|
|
if let image {
|
||
|
|
Image(platformImage: image)
|
||
|
|
.resizable()
|
||
|
|
.scaledToFit()
|
||
|
|
.frame(maxWidth: image.size.width, alignment: .leading)
|
||
|
|
.clipShape(RoundedRectangle(cornerRadius: 6))
|
||
|
|
.overlay(RoundedRectangle(cornerRadius: 6).stroke(Palette.border))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.task(id: capture.id) {
|
||
|
|
image = Data(base64Encoded: capture.base64).flatMap { PlatformImage(data: $0) }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|