Merge pull request #1522 from hartlco/1485-Add-mark-below-mark-above-as-read
Replace “Mark Older as Read” actions with “Mark Above/Below as Read” actions #1485
This commit is contained in:
commit
b7f3612686
|
@ -117,11 +117,11 @@ struct AppAssets {
|
|||
return UIImage(systemName: "asterisk.circle")!
|
||||
}()
|
||||
|
||||
static var markOlderAsReadDownImage: UIImage = {
|
||||
static var markBelowAsReadImage: UIImage = {
|
||||
return UIImage(systemName: "arrowtriangle.down.circle")!
|
||||
}()
|
||||
|
||||
static var markOlderAsReadUpImage: UIImage = {
|
||||
static var markAboveAsReadImage: UIImage = {
|
||||
return UIImage(systemName: "arrowtriangle.up.circle")!
|
||||
}()
|
||||
|
||||
|
|
|
@ -168,8 +168,8 @@ private extension KeyboardManager {
|
|||
let toggleReadTitle = NSLocalizedString("Toggle Read Status", comment: "Toggle Read Status")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: toggleReadTitle, action: "toggleRead:", input: "u", modifiers: [.command, .shift]))
|
||||
|
||||
let markOlderAsReadTitle = NSLocalizedString("Mark Older as Read", comment: "Mark Older as Read")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: markOlderAsReadTitle, action: "markOlderArticlesAsRead:", input: "k", modifiers: [.command, .shift]))
|
||||
let markOlderAsReadTitle = NSLocalizedString("Mark Below as Read", comment: "Mark Below as Read")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: markOlderAsReadTitle, action: "markBelowAsRead:", input: "k", modifiers: [.command, .shift]))
|
||||
|
||||
let toggleStarredTitle = NSLocalizedString("Toggle Starred Status", comment: "Toggle Starred Status")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: toggleStarredTitle, action: "toggleStarred:", input: "l", modifiers: [.command, .shift]))
|
||||
|
|
|
@ -246,7 +246,13 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||
popoverController.sourceRect = CGRect(x: view.frame.size.width/2, y: view.frame.size.height/2, width: 1, height: 1)
|
||||
}
|
||||
|
||||
alert.addAction(self.markOlderAsReadAlertAction(article, completion: completion))
|
||||
if let action = self.markAboveAsReadAlertAction(article, completion: completion) {
|
||||
alert.addAction(action)
|
||||
}
|
||||
|
||||
if let action = self.markBelowAsReadAlertAction(article, completion: completion) {
|
||||
alert.addAction(action)
|
||||
}
|
||||
|
||||
if let action = self.discloseFeedAlertAction(article, completion: completion) {
|
||||
alert.addAction(action)
|
||||
|
@ -293,7 +299,14 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||
var actions = [UIAction]()
|
||||
actions.append(self.toggleArticleReadStatusAction(article))
|
||||
actions.append(self.toggleArticleStarStatusAction(article))
|
||||
actions.append(self.markOlderAsReadAction(article))
|
||||
|
||||
if let action = self.markAboveAsReadAction(article) {
|
||||
actions.append(action)
|
||||
}
|
||||
|
||||
if let action = self.markBelowAsReadAction(article) {
|
||||
actions.append(action)
|
||||
}
|
||||
|
||||
if let action = self.discloseFeedAction(article) {
|
||||
actions.append(action)
|
||||
|
@ -637,19 +650,53 @@ private extension MasterTimelineViewController {
|
|||
return action
|
||||
}
|
||||
|
||||
func markOlderAsReadAction(_ article: Article) -> UIAction {
|
||||
let title = NSLocalizedString("Mark Older as Read", comment: "Mark Older as Read")
|
||||
let image = coordinator.sortDirection == .orderedDescending ? AppAssets.markOlderAsReadDownImage : AppAssets.markOlderAsReadUpImage
|
||||
func markAboveAsReadAction(_ article: Article) -> UIAction? {
|
||||
guard coordinator.canMarkAboveAsRead(for: article) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Mark Above as Read", comment: "Mark Above as Read")
|
||||
let image = AppAssets.markAboveAsReadImage
|
||||
let action = UIAction(title: title, image: image) { [weak self] action in
|
||||
self?.coordinator.markAsReadOlderArticlesInTimeline(article)
|
||||
self?.coordinator.markAboveAsRead(article)
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
func markOlderAsReadAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction {
|
||||
let title = NSLocalizedString("Mark Older as Read", comment: "Mark Older as Read")
|
||||
func markBelowAsReadAction(_ article: Article) -> UIAction? {
|
||||
guard coordinator.canMarkBelowAsRead(for: article) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Mark Below as Read", comment: "Mark Below as Read")
|
||||
let image = AppAssets.markBelowAsReadImage
|
||||
let action = UIAction(title: title, image: image) { [weak self] action in
|
||||
self?.coordinator.markBelowAsRead(article)
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
func markAboveAsReadAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
|
||||
guard coordinator.canMarkAboveAsRead(for: article) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Mark Above as Read", comment: "Mark Above as Read")
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
|
||||
self?.coordinator.markAsReadOlderArticlesInTimeline(article)
|
||||
self?.coordinator.markAboveAsRead(article)
|
||||
completion(true)
|
||||
}
|
||||
return action
|
||||
}
|
||||
|
||||
func markBelowAsReadAlertAction(_ article: Article, completion: @escaping (Bool) -> Void) -> UIAlertAction? {
|
||||
guard coordinator.canMarkBelowAsRead(for: article) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Mark Below as Read", comment: "Mark Below as Read")
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
|
||||
self?.coordinator.markBelowAsRead(article)
|
||||
completion(true)
|
||||
}
|
||||
return action
|
||||
|
|
|
@ -54,8 +54,8 @@ class RootSplitViewController: UISplitViewController {
|
|||
coordinator.selectNextUnread()
|
||||
}
|
||||
|
||||
@objc func markOlderArticlesAsRead(_ sender: Any?) {
|
||||
coordinator.markAsReadOlderArticlesInTimeline()
|
||||
@objc func markBelowAsRead(_ sender: Any?) {
|
||||
coordinator.markBelowAsRead()
|
||||
}
|
||||
|
||||
@objc func markUnread(_ sender: Any?) {
|
||||
|
|
|
@ -871,18 +871,44 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||
masterNavigationController.popViewController(animated: true)
|
||||
}
|
||||
|
||||
func markAsReadOlderArticlesInTimeline() {
|
||||
if let article = currentArticle {
|
||||
markAsReadOlderArticlesInTimeline(article)
|
||||
}
|
||||
func canMarkAboveAsRead(for article: Article) -> Bool {
|
||||
return articles.first != article
|
||||
}
|
||||
|
||||
func markAsReadOlderArticlesInTimeline(_ article: Article) {
|
||||
let articlesToMark = articles.filter { $0.logicalDatePublished < article.logicalDatePublished }
|
||||
if articlesToMark.isEmpty {
|
||||
func markAboveAsRead(_ article: Article) {
|
||||
guard let position = articles.firstIndex(of: article) else {
|
||||
return
|
||||
}
|
||||
markAllAsRead(articlesToMark)
|
||||
|
||||
let articlesAbove = articles[..<position]
|
||||
markAllAsRead(Array(articlesAbove))
|
||||
}
|
||||
|
||||
func canMarkBelowAsRead(for article: Article) -> Bool {
|
||||
return articles.last != article
|
||||
}
|
||||
|
||||
func markBelowAsRead() {
|
||||
guard let currentArticle = currentArticle else {
|
||||
return
|
||||
}
|
||||
|
||||
markBelowAsRead(currentArticle)
|
||||
}
|
||||
|
||||
func markBelowAsRead(_ article: Article) {
|
||||
guard let position = articles.firstIndex(of: article) else {
|
||||
return
|
||||
}
|
||||
|
||||
var articlesBelow = Array(articles[position...])
|
||||
|
||||
guard !articlesBelow.isEmpty else {
|
||||
return
|
||||
}
|
||||
|
||||
articlesBelow.removeFirst()
|
||||
markAllAsRead(articlesBelow)
|
||||
}
|
||||
|
||||
func markAsReadForCurrentArticle() {
|
||||
|
|
Loading…
Reference in New Issue