mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-10 19:20:59 +00:00
Add context menu and draggability to attachment image views (#2142)
* Factor out MediaUIShareLink * Add share link to attachment image view * Make attachment image views draggable * Add copy actions to attachment image view
This commit is contained in:
parent
4f9cb2e86a
commit
9af98c3921
3 changed files with 34 additions and 7 deletions
|
@ -22,6 +22,23 @@ struct MediaUIAttachmentImageView: View {
|
||||||
.progressViewStyle(.circular)
|
.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")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift
Normal file
16
Packages/MediaUI/Sources/MediaUI/MediaUIShareLink.swift
Normal file
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,13 +6,7 @@ struct ShareToolbarItem: ToolbarContent, @unchecked Sendable {
|
||||||
|
|
||||||
var body: some ToolbarContent {
|
var body: some ToolbarContent {
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
if type == .image {
|
MediaUIShareLink(url: url, type: type)
|
||||||
let transferable = MediaUIImageTransferable(url: url)
|
|
||||||
ShareLink(item: transferable, preview: .init("status.media.contextmenu.share",
|
|
||||||
image: transferable))
|
|
||||||
} else {
|
|
||||||
ShareLink(item: url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue