Add context menu action for deleting draft so it's accessible by cursor

This commit is contained in:
Shadowfacts 2022-06-08 23:42:40 -04:00
parent 92efee6f46
commit f702df2f15
1 changed files with 12 additions and 0 deletions

View File

@ -110,6 +110,18 @@ class DraftsTableViewController: UITableViewController {
tableView.deleteRows(at: [indexPath], with: .automatic) 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 // MARK: - Interaction
@objc func cancelPressed() { @objc func cancelPressed() {