Add context menu action to remove attachments in Compose

This commit is contained in:
Shadowfacts 2021-06-18 11:32:17 -04:00
parent 27e05cc72d
commit ebb0770198
1 changed files with 13 additions and 1 deletions

View File

@ -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() {