diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index c6282b4a3..896d499ba 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -93,6 +93,7 @@ 51C452B1226510E600C03939 /* InitialFeedDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97A01ED9F180007D329B /* InitialFeedDownloader.swift */; }; 51C452B42265141B00C03939 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51C452B32265141B00C03939 /* WebKit.framework */; }; 51C452B82265178500C03939 /* styleSheet.css in Resources */ = {isa = PBXBuildFile; fileRef = 51C452B72265178500C03939 /* styleSheet.css */; }; + 51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84702AA31FA27AC0006B8943 /* MarkStatusCommand.swift */; }; 51EC114C2149FE3300B296E3 /* FolderTreeMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EC114B2149FE3300B296E3 /* FolderTreeMenu.swift */; }; 6581C73820CED60100F4AD34 /* SafariExtensionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6581C73720CED60100F4AD34 /* SafariExtensionHandler.swift */; }; 6581C73A20CED60100F4AD34 /* SafariExtensionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6581C73920CED60100F4AD34 /* SafariExtensionViewController.swift */; }; @@ -2135,6 +2136,7 @@ 51C452772265091600C03939 /* MultilineUILabelSizer.swift in Sources */, 51C452A522650A2D00C03939 /* SmallIconProvider.swift in Sources */, 51C452A122650A1900C03939 /* FeaturedImageDownloader.swift in Sources */, + 51D5948722668EFA00DFC836 /* MarkStatusCommand.swift in Sources */, 51C4525C226508DF00C03939 /* String-Extensions.swift in Sources */, 51C452792265091600C03939 /* MasterTimelineTableViewCell.swift in Sources */, 51C452852265093600C03939 /* AddFeedFolderPickerData.swift in Sources */, diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index 37d4b8323..3895a8bfe 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -13,11 +13,15 @@ - + + + + + @@ -115,13 +119,15 @@ - - + + - + - + + + @@ -130,11 +136,15 @@ - + + + + + @@ -181,18 +191,27 @@ - + + + + + + + + + + + + + + - - - - - + @@ -264,10 +283,9 @@ - - + diff --git a/iOS/Master/MasterViewController.swift b/iOS/Master/MasterViewController.swift index 762e2f9ca..4a73646c7 100644 --- a/iOS/Master/MasterViewController.swift +++ b/iOS/Master/MasterViewController.swift @@ -8,11 +8,13 @@ import UIKit import Account +import Articles import RSCore import RSTree -class MasterViewController: UITableViewController { +class MasterViewController: UITableViewController, UndoableCommandRunner { + var undoableCommands = [UndoableCommand]() var animatingChanges = false let treeControllerDelegate = MasterTreeControllerDelegate() @@ -20,6 +22,10 @@ class MasterViewController: UITableViewController { return TreeController(delegate: treeControllerDelegate) }() + override var canBecomeFirstResponder: Bool { + return true + } + override func viewDidLoad() { super.viewDidLoad() @@ -42,7 +48,17 @@ class MasterViewController: UITableViewController { clearsSelectionOnViewWillAppear = splitViewController!.isCollapsed super.viewWillAppear(animated) } - + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + becomeFirstResponder() + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + resignFirstResponder() + } + @objc private func refreshAccounts(_ sender: Any) { AccountManager.shared.refreshAll() } @@ -175,6 +191,40 @@ class MasterViewController: UITableViewController { // MARK: Actions + @IBAction func markAllAsRead(_ sender: Any) { + + let title = NSLocalizedString("Mark All Read", comment: "Mark All Read") + let message = NSLocalizedString("Mark all articles in all accounts as read?", comment: "Mark all articles") + let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) + + let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel") + let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel) + alertController.addAction(cancelAction) + + let markTitle = NSLocalizedString("Mark All Read", comment: "Mark All Read") + let markAction = UIAlertAction(title: markTitle, style: .default) { [weak self] (action) in + + let accounts = AccountManager.shared.accounts + var articles = Set
() + accounts.forEach { account in + articles.formUnion(account.fetchUnreadArticles()) + } + + guard let undoManager = self?.undoManager, + let markReadCommand = MarkStatusCommand(initialArticles: Array(articles), markingRead: true, undoManager: undoManager) else { + return + } + + self?.runCommand(markReadCommand) + + } + + alertController.addAction(markAction) + + present(alertController, animated: true) + + } + @IBAction func add(_ sender: UIBarButtonItem) { let feedViewController = UIStoryboard.add.instantiateInitialViewController()! feedViewController.modalPresentationStyle = .popover