Show an alert the first time mark all as read is tapped

This commit is contained in:
Phil Viso 2019-10-07 19:48:58 -05:00
parent 461c681a9d
commit b963d97922
5 changed files with 22 additions and 6 deletions

View File

@ -18,6 +18,7 @@ struct AppDefaults {
static let timelineGroupByFeed = "timelineGroupByFeed"
static let timelineNumberOfLines = "timelineNumberOfLines"
static let timelineSortDirection = "timelineSortDirection"
static let displayMarkAllAsReadUndoTip = "displayMarkAllAsReadUndoTip"
static let refreshInterval = "refreshInterval"
static let lastRefresh = "lastRefresh"
}
@ -67,6 +68,15 @@ struct AppDefaults {
}
}
static var displayMarkAllAsReadUndoTip: Bool {
get {
return bool(for: Key.displayMarkAllAsReadUndoTip)
}
set {
setBool(for: Key.displayMarkAllAsReadUndoTip, newValue)
}
}
static var lastRefresh: Date? {
get {
return date(for: Key.lastRefresh)
@ -90,7 +100,8 @@ struct AppDefaults {
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
Key.timelineGroupByFeed: false,
Key.timelineNumberOfLines: 3,
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue]
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
Key.displayMarkAllAsReadUndoTip: true]
AppDefaults.shared.register(defaults: defaults)
}

View File

@ -12,13 +12,13 @@ import UIKit
struct MarkArticlesReadAlertController {
static func allArticlesAlert(handler: @escaping (UIAlertAction) -> Void) -> UIAlertController {
let message = NSLocalizedString("Mark all articles in all accounts as read?",
let message = NSLocalizedString("Mark all articles in all accounts as read? You can undo this action with a three finger swipe to the right.",
comment: "Mark all articles")
return markAllReadAlert(message: message, handler: handler)
}
static func timelineArticlesAlert(handler: @escaping (UIAlertAction) -> Void) -> UIAlertController {
let message = NSLocalizedString("Mark all articles in this timeline as read?",
let message = NSLocalizedString("Mark all articles in this timeline as read? You can undo this action with a three finger swipe to the right.",
comment: "Mark all articles")
return markAllReadAlert(message: message, handler: handler)
}

View File

@ -344,8 +344,9 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
}
@IBAction func markAllAsRead(_ sender: Any) {
if coordinator.shouldDisplayMarkAllAsReadUndoTip {
if coordinator.displayMarkAllAsReadUndoTip {
let alertController = MarkArticlesReadAlertController.allArticlesAlert { [weak self] _ in
self?.coordinator.displayMarkAllAsReadUndoTip = false
self?.coordinator.markAllAsRead()
}

View File

@ -89,8 +89,9 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
// MARK: Actions
@IBAction func markAllAsRead(_ sender: Any) {
if coordinator.shouldDisplayMarkAllAsReadUndoTip {
if coordinator.displayMarkAllAsReadUndoTip {
let alertController = MarkArticlesReadAlertController.timelineArticlesAlert { [weak self] _ in
self?.coordinator.displayMarkAllAsReadUndoTip = false
self?.coordinator.markAllAsReadInTimeline()
}

View File

@ -83,7 +83,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
}
}
private(set) var shouldDisplayMarkAllAsReadUndoTip = true
var displayMarkAllAsReadUndoTip: Bool {
get { AppDefaults.displayMarkAllAsReadUndoTip }
set { AppDefaults.displayMarkAllAsReadUndoTip = newValue }
}
private let treeControllerDelegate = FeedTreeControllerDelegate()
private lazy var treeController: TreeController = {