Paste images in iPhone message boxes; let hands drive the simulator
This commit is contained in:
@@ -183,6 +183,16 @@ final class ImageDrafts {
|
||||
}
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
private struct PastedImage: Transferable {
|
||||
let data: Data
|
||||
|
||||
static var transferRepresentation: some TransferRepresentation {
|
||||
DataRepresentation(importedContentType: .image) { PastedImage(data: $0) }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(macOS)
|
||||
struct ComposerTarget {
|
||||
let paste: @MainActor (NSPasteboard) -> Bool
|
||||
@@ -242,6 +252,12 @@ private struct ImageInput: ViewModifier {
|
||||
content
|
||||
#if os(macOS)
|
||||
.focusedValue(\.composer, ComposerTarget(paste: { pb in store.images.add(key, pasteboard: pb, overlays) }))
|
||||
#else
|
||||
.pasteDestination(for: PastedImage.self) { pasted in
|
||||
for p in pasted {
|
||||
store.images.add(key, p.data, name: nil, overlays)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
.overlay {
|
||||
if targeted {
|
||||
|
||||
Reference in New Issue
Block a user