mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 20:16:54 +01:00
Add row swipe action for Mark Read/Unread
This commit is contained in:
parent
59143c2d8f
commit
bc32fc1cb9
@ -746,6 +746,32 @@ extension TimelineViewController: NSTableViewDelegate {
|
|||||||
cell.objectValue = nil
|
cell.objectValue = nil
|
||||||
cell.cellData = TimelineCellData()
|
cell.cellData = TimelineCellData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func toggleArticleRead(_ article: Article) {
|
||||||
|
guard let undoManager = undoManager, let markUnreadCommand = MarkStatusCommand(initialArticles: [article], markingRead: !article.status.read, undoManager: undoManager) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.runCommand(markUnreadCommand)
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: NSTableView, rowActionsForRow row: Int, edge: NSTableView.RowActionEdge) -> [NSTableViewRowAction] {
|
||||||
|
|
||||||
|
if edge == .leading {
|
||||||
|
guard let article = articles.articleAtRow(row) else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
let title = article.status.read ? NSLocalizedString("Mark Unread", comment: "mark unread") : NSLocalizedString("Mark Read", comment: "mark read")
|
||||||
|
|
||||||
|
let action = NSTableViewRowAction(style: .regular, title: title) { (action, row) in
|
||||||
|
self.toggleArticleRead(article);
|
||||||
|
tableView.rowActionsVisible = false
|
||||||
|
}
|
||||||
|
return [action]
|
||||||
|
}
|
||||||
|
|
||||||
|
return []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
|
Loading…
x
Reference in New Issue
Block a user