From f702df2f15251fefd1dda56dcdfc4c23ed65b880 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 8 Jun 2022 23:42:40 -0400 Subject: [PATCH] Add context menu action for deleting draft so it's accessible by cursor --- .../Screens/Drafts/DraftsTableViewController.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Tusker/Screens/Drafts/DraftsTableViewController.swift b/Tusker/Screens/Drafts/DraftsTableViewController.swift index 3a981864fe..81a0a829b8 100644 --- a/Tusker/Screens/Drafts/DraftsTableViewController.swift +++ b/Tusker/Screens/Drafts/DraftsTableViewController.swift @@ -110,6 +110,18 @@ class DraftsTableViewController: UITableViewController { tableView.deleteRows(at: [indexPath], with: .automatic) } + override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { + return UIContextMenuConfiguration(actionProvider: { _ in + return UIMenu(children: [ + UIAction(title: "Delete Draft", image: UIImage(systemName: "trash"), attributes: .destructive, handler: { [unowned self] _ in + DraftsManager.shared.remove(self.draft(for: indexPath)) + drafts.remove(at: indexPath.row) + tableView.deleteRows(at: [indexPath], with: .automatic) + }) + ]) + }) + } + // MARK: - Interaction @objc func cancelPressed() {