44 lines
1.6 KiB
Swift
44 lines
1.6 KiB
Swift
import SwiftUI
|
|
|
|
/// Text the agent wrote to `.clean-copy`: edit it, then copy it as plain text.
|
|
struct CleanCopyOverlay: View {
|
|
let store: CleanCopyStore
|
|
var onCopy: () -> Void
|
|
var onClose: () -> Void
|
|
|
|
var body: some View {
|
|
OverlayShell(.sized(width: 780), onDismiss: onClose) {
|
|
VStack(spacing: 0) {
|
|
OverlayHeader(systemImage: "doc.on.clipboard", title: "From Claude", detail: CleanCopyStore.fileName) {
|
|
Button(action: onCopy) {
|
|
HStack(spacing: 8) {
|
|
Text("Copy")
|
|
Keycap("⌘↩", style: .onAmber, small: true)
|
|
}
|
|
}
|
|
.buttonStyle(.primary)
|
|
}
|
|
OverlayTextEditor(text: Binding(get: { store.text }, set: { store.text = $0 }), onKey: handle)
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
Text("copied as plain text · \(store.characterCount) characters")
|
|
.typeRole(Typography.meta)
|
|
.foregroundStyle(Palette.text4)
|
|
.padding(.horizontal, 20)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.frame(height: 34)
|
|
.hairline(.top)
|
|
}
|
|
.frame(maxHeight: .infinity)
|
|
}
|
|
}
|
|
|
|
private func handle(_ key: OverlayKey) -> Bool {
|
|
switch key {
|
|
case .commandEnter: onCopy()
|
|
case .escape: onClose()
|
|
default: return false
|
|
}
|
|
return true
|
|
}
|
|
}
|