From b2e080cf8e7761a719a61a8e20f200033e09adea Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 22 Apr 2019 15:31:34 -0500 Subject: [PATCH] Hide timeline First Unread button when detail view displayed. --- iOS/Base.lproj/Main.storyboard | 3 +++ .../MasterTimelineViewController.swift | 26 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/iOS/Base.lproj/Main.storyboard b/iOS/Base.lproj/Main.storyboard index ccccd140a..5b8bd465f 100644 --- a/iOS/Base.lproj/Main.storyboard +++ b/iOS/Base.lproj/Main.storyboard @@ -153,6 +153,9 @@ + + + diff --git a/iOS/Timeline/MasterTimelineViewController.swift b/iOS/Timeline/MasterTimelineViewController.swift index 618c93383..4f7365af1 100644 --- a/iOS/Timeline/MasterTimelineViewController.swift +++ b/iOS/Timeline/MasterTimelineViewController.swift @@ -20,17 +20,11 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner return navState?.showFeedNames ?? false ? rowHeightWithFeedName : rowHeightWithoutFeedName } + @IBOutlet weak var nextUnreadButton: UIBarButtonItem! + weak var navState: NavigationStateController? var undoableCommands = [UndoableCommand]() - var detailViewController: DetailViewController? { - if let split = splitViewController { - let controllers = split.viewControllers - return (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController - } - return nil - } - override var canBecomeFirstResponder: Bool { return true } @@ -56,6 +50,8 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner refreshControl = UIRefreshControl() refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged) + splitViewController?.delegate = self + } override func viewDidAppear(_ animated: Bool) { @@ -339,6 +335,20 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner } +extension MasterTimelineViewController: UISplitViewControllerDelegate { + + func splitViewController(_ svc: UISplitViewController, willChangeTo displayMode: UISplitViewController.DisplayMode) { + if displayMode == .allVisible { + nextUnreadButton.isEnabled = false + nextUnreadButton.title = "" + } else { + nextUnreadButton.isEnabled = false + nextUnreadButton.title = NSLocalizedString("First Unread", comment: "First Unread") + } + } + +} + // MARK: Private private extension MasterTimelineViewController {