diff --git a/Tusker/Screens/Compose/Drafts/DraftTableViewCell.xib b/Tusker/Screens/Compose/Drafts/DraftTableViewCell.xib index f83c9da5..1f7cfe1f 100644 --- a/Tusker/Screens/Compose/Drafts/DraftTableViewCell.xib +++ b/Tusker/Screens/Compose/Drafts/DraftTableViewCell.xib @@ -1,10 +1,10 @@ - + - + @@ -17,25 +17,26 @@ - + - + - + diff --git a/Tusker/Screens/Compose/Drafts/DraftsTableViewController.swift b/Tusker/Screens/Compose/Drafts/DraftsTableViewController.swift index 6e3c9c71..fde1dee3 100644 --- a/Tusker/Screens/Compose/Drafts/DraftsTableViewController.swift +++ b/Tusker/Screens/Compose/Drafts/DraftsTableViewController.swift @@ -61,6 +61,22 @@ class DraftsTableViewController: UITableViewController { dismiss(animated: true) } + override func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { + return .delete + } + + override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { + return true + } + + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + guard editingStyle == .delete else { return } + DraftsManager.shared.remove(draft(for: indexPath)) + tableView.deleteRows(at: [indexPath], with: .automatic) + } + + // MARK: - Interaction + @objc func cancelPressed() { delegate?.draftSelectionCanceled() dismiss(animated: true)