Add Feed Inspector

This commit is contained in:
Maurice Parker
2019-09-27 19:45:09 -05:00
parent 17c33b75e9
commit ca4a7f8b0b
4 changed files with 140 additions and 1 deletions

View File

@@ -46,6 +46,8 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange), name: .DisplayNameDidChange, object: nil)
// Setup the Search Controller
searchController.delegate = self
@@ -129,6 +131,10 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
coordinator.navigateToDetail()
}
@objc func showFeedInspector(_ sender: UITapGestureRecognizer) {
coordinator.showFeedInspector()
}
// MARK: API
func restoreSelectionIfNecessary() {
@@ -365,6 +371,10 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
updateProgressIndicatorIfNeeded()
}
@objc func displayNameDidChange(_ note: Notification) {
titleView?.label.text = coordinator.timelineName
}
// MARK: Reloading
func queueReloadAvailableCells() {
@@ -454,12 +464,21 @@ private extension MasterTimelineViewController {
}
func resetUI() {
title = coordinator.timelineName
if let titleView = Bundle.main.loadNibNamed("MasterTimelineTitleView", owner: self, options: nil)?[0] as? MasterTimelineTitleView {
self.titleView = titleView
titleView.imageView.image = coordinator.timelineFavicon
titleView.label.text = coordinator.timelineName
if coordinator.timelineFetcher is Feed {
let width = titleView.sizeThatFits(CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)).width
titleView.widthAnchor.constraint(equalToConstant: width).isActive = true
titleView.heightAnchor.constraint(equalToConstant: 44.0).isActive = true
let tap = UITapGestureRecognizer(target: self, action:#selector(showFeedInspector(_:)))
titleView.addGestureRecognizer(tap)
}
navigationItem.titleView = titleView
}