Continue rewiring progress.

This commit is contained in:
Brent Simmons 2019-02-17 22:00:04 -08:00
parent 80761b4a83
commit 076df956f9
3 changed files with 13 additions and 12 deletions

View File

@ -38,6 +38,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
private static var detailViewMinimumThickness = 384
private var sidebarViewController: SidebarViewController!
private var timelineContainerViewController: TimelineContainerViewController!
private var detailViewController: DetailViewController!
// MARK: - NSWindowController
@ -72,6 +73,8 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
timelineContainerViewController = splitViewController?.splitViewItems[1].viewController as? TimelineContainerViewController
timelineContainerViewController.delegate = self
detailViewController = splitViewController?.splitViewItems[2].viewController as? DetailViewController
NotificationCenter.default.addObserver(self, selector: #selector(applicationWillTerminate(_:)), name: NSApplication.willTerminateNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(refreshProgressDidChange(_:)), name: .AccountRefreshDidBegin, object: nil)
@ -208,13 +211,9 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
@IBAction func scrollOrGoToNextUnread(_ sender: Any?) {
guard let detailViewController = detailViewController else {
return
}
detailViewController.canScrollDown { (canScroll) in
NSCursor.setHiddenUntilMouseMoves(true)
canScroll ? detailViewController.scrollPageDown(sender) : self.nextUnread(sender)
canScroll ? self.detailViewController.scrollPageDown(sender) : self.nextUnread(sender)
}
}
@ -439,10 +438,6 @@ private extension MainWindowController {
return splitViewController?.splitViewItems[2]
}
var detailViewController: DetailViewController? {
return splitViewController?.splitViewItems[2].viewController as? DetailViewController
}
var selectedArticles: [Article]? {
return timelineViewController?.selectedArticles
}

View File

@ -10,12 +10,12 @@ import AppKit
class TimelineTableView: NSTableView {
@IBOutlet var keyboardDelegate: KeyboardDelegate!
weak var keyboardDelegate: KeyboardDelegate?
// MARK: - NSResponder
override func keyDown(with event: NSEvent) {
if keyboardDelegate.keydown(event, in: self) {
if keyboardDelegate?.keydown(event, in: self) ?? false {
return
}
super.keyDown(with: event)

View File

@ -117,6 +117,8 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner {
return selectedArticles.count == 1 ? selectedArticles.first : nil
}
private let keyboardDelegate = TimelineKeyboardDelegate()
convenience init(delegate: TimelineDelegate) {
self.init(nibName: "TimelineTableView", bundle: nil)
self.delegate = delegate
@ -132,7 +134,8 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner {
tableView.target = self
tableView.doubleAction = #selector(openArticleInBrowser(_:))
tableView.setDraggingSourceOperationMask(.copy, forLocal: false)
tableView.keyboardDelegate = keyboardDelegate
if !didRegisterForNotifications {
NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil)
@ -628,6 +631,8 @@ extension TimelineViewController: NSTableViewDelegate {
private func postTimelineSelectionDidChangeNotification(_ selectedArticles: ArticleArray?) {
delegate?.timelineSelectionDidChange(self, selectedArticles: selectedArticles)
var userInfo = UserInfoDictionary()
if let selectedArticles = selectedArticles {
userInfo[UserInfoKey.articles] = selectedArticles
@ -635,6 +640,7 @@ extension TimelineViewController: NSTableViewDelegate {
userInfo[UserInfoKey.view] = tableView
NotificationCenter.default.post(name: .TimelineSelectionDidChange, object: self, userInfo: userInfo)
}
private func configureTimelineCell(_ cell: TimelineTableCellView, article: Article) {