Hide timeline First Unread button when detail view displayed.

This commit is contained in:
Maurice Parker 2019-04-22 15:31:34 -05:00
parent 0bfd19ab30
commit b2e080cf8e
2 changed files with 21 additions and 8 deletions

View File

@ -153,6 +153,9 @@
</toolbarItems>
<navigationItem key="navigationItem" title="Timeline" largeTitleDisplayMode="never" id="wcC-1L-ug4"/>
<simulatedToolbarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="nextUnreadButton" destination="2v2-jD-C9k" id="9rf-5I-18f"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="nzm-Gf-Xce" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>

View File

@ -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 {