From ebb077019862f5a13ab9db230c2b1d61d64b5b9e Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 18 Jun 2021 11:32:17 -0400 Subject: [PATCH] Add context menu action to remove attachments in Compose --- Tusker/Screens/Compose/ComposeAttachmentRow.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Tusker/Screens/Compose/ComposeAttachmentRow.swift b/Tusker/Screens/Compose/ComposeAttachmentRow.swift index 15929762..96d0e356 100644 --- a/Tusker/Screens/Compose/ComposeAttachmentRow.swift +++ b/Tusker/Screens/Compose/ComposeAttachmentRow.swift @@ -41,6 +41,16 @@ struct ComposeAttachmentRow: View { Label("Recognize Text", systemImage: "doc.text.viewfinder") } } + + if #available(iOS 15.0, *) { + Button(action: self.removeAttachment) { + Label("Delete", systemImage: "trash") + }.foregroundStyle(.red) + } else { + Button(action: self.removeAttachment) { + Label("Delete", systemImage: "trash") + } + } } switch mode { @@ -126,7 +136,9 @@ struct ComposeAttachmentRow: View { } private func removeAttachment() { - draft.attachments.removeAll { $0.id == attachment.id } + withAnimation { + draft.attachments.removeAll { $0.id == attachment.id } + } } private func editDrawing() {