diff --git a/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentImageView.swift b/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentImageView.swift index e29f1aaf..cc5f9921 100644 --- a/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentImageView.swift +++ b/Packages/MediaUI/Sources/MediaUI/MediaUIAttachmentImageView.swift @@ -22,6 +22,23 @@ struct MediaUIAttachmentImageView: View { .progressViewStyle(.circular) } } + .draggable(MediaUIImageTransferable(url: url)) + .contextMenu { + MediaUIShareLink(url: url, type: .image) + Button { + Task { + let transferable = MediaUIImageTransferable(url: url) + UIPasteboard.general.image = UIImage(data: await transferable.fetchData()) + } + } label: { + Label("status.media.contextmenu.copy", systemImage: "doc.on.doc") + } + Button { + UIPasteboard.general.url = url + } label: { + Label("status.action.copy-link", systemImage: "link") + } + } } } } diff --git a/Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift b/Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift new file mode 100644 index 00000000..54e0e1f6 --- /dev/null +++ b/Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift @@ -0,0 +1,16 @@ +import SwiftUI + +struct MediaUIShareLink: View, @unchecked Sendable { + let url: URL + let type: DisplayType + + var body: some View { + if type == .image { + let transferable = MediaUIImageTransferable(url: url) + ShareLink(item: transferable, preview: .init("status.media.contextmenu.share", + image: transferable)) + } else { + ShareLink(item: url) + } + } +} diff --git a/Packages/MediaUI/Sources/MediaUI/ShareToolbarItem.swift b/Packages/MediaUI/Sources/MediaUI/ShareToolbarItem.swift index eab146fd..dd29973f 100644 --- a/Packages/MediaUI/Sources/MediaUI/ShareToolbarItem.swift +++ b/Packages/MediaUI/Sources/MediaUI/ShareToolbarItem.swift @@ -6,13 +6,7 @@ struct ShareToolbarItem: ToolbarContent, @unchecked Sendable { var body: some ToolbarContent { ToolbarItem(placement: .topBarTrailing) { - if type == .image { - let transferable = MediaUIImageTransferable(url: url) - ShareLink(item: transferable, preview: .init("status.media.contextmenu.share", - image: transferable)) - } else { - ShareLink(item: url) - } + MediaUIShareLink(url: url, type: type) } } }