diff --git a/NetNewsWire/Base.lproj/MainWindow.storyboard b/NetNewsWire/Base.lproj/MainWindow.storyboard index d72404fc0..7793edb1a 100644 --- a/NetNewsWire/Base.lproj/MainWindow.storyboard +++ b/NetNewsWire/Base.lproj/MainWindow.storyboard @@ -445,16 +445,6 @@ - - - - - - - - - - diff --git a/NetNewsWire/MainWindow/Detail/DetailViewController.swift b/NetNewsWire/MainWindow/Detail/DetailViewController.swift index 15004588c..52547bab1 100644 --- a/NetNewsWire/MainWindow/Detail/DetailViewController.swift +++ b/NetNewsWire/MainWindow/Detail/DetailViewController.swift @@ -23,10 +23,6 @@ final class DetailViewController: NSViewController, WKUIDelegate { @IBOutlet var containerView: DetailContainerView! @IBOutlet var statusBarView: DetailStatusBarView! - enum WebViewType { - case regular, search - } - lazy var regularWebViewController = { return createWebViewController() }() @@ -52,7 +48,7 @@ final class DetailViewController: NSViewController, WKUIDelegate { // MARK: - API - func showState(_ state: DetailState, in webViewType: WebViewType) { + func showState(_ state: DetailState, mode: TimelineSourceMode) { // TODO: also to-do is caller } diff --git a/NetNewsWire/MainWindow/MainWindowController.swift b/NetNewsWire/MainWindow/MainWindowController.swift index 7323d10a5..42f0c6d4d 100644 --- a/NetNewsWire/MainWindow/MainWindowController.swift +++ b/NetNewsWire/MainWindow/MainWindowController.swift @@ -11,6 +11,10 @@ import Articles import Account import RSCore +enum TimelineSourceMode { + case regular, search +} + class MainWindowController : NSWindowController, NSUserInterfaceValidations { @IBOutlet var toolbarDelegate: MainWindowToolbarDelegate? diff --git a/NetNewsWire/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/NetNewsWire/MainWindow/Timeline/Cell/TimelineTableCellView.swift index f8dacf6e9..5f0b75a29 100644 --- a/NetNewsWire/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/NetNewsWire/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -68,17 +68,19 @@ class TimelineTableCellView: NSTableCellView { } override init(frame frameRect: NSRect) { - super.init(frame: frameRect) commonInit() } - required init?(coder: NSCoder) { - + required init?(coder: NSCoder) { super.init(coder: coder) commonInit() } - + + convenience init() { + self.init(frame: NSRect.zero) + } + override func setFrameSize(_ newSize: NSSize) { if newSize == self.frame.size { diff --git a/NetNewsWire/MainWindow/Timeline/TimelineTableRowView.swift b/NetNewsWire/MainWindow/Timeline/TimelineTableRowView.swift index 14914f27d..6db9514d8 100644 --- a/NetNewsWire/MainWindow/Timeline/TimelineTableRowView.swift +++ b/NetNewsWire/MainWindow/Timeline/TimelineTableRowView.swift @@ -10,6 +10,14 @@ import AppKit class TimelineTableRowView : NSTableRowView { + init() { + super.init(frame: NSRect.zero) + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + } + private var cellView: TimelineTableCellView? { for oneSubview in subviews { if let foundView = oneSubview as? TimelineTableCellView { diff --git a/NetNewsWire/MainWindow/Timeline/TimelineViewController.swift b/NetNewsWire/MainWindow/Timeline/TimelineViewController.swift index 69e285e4b..7102c75a1 100644 --- a/NetNewsWire/MainWindow/Timeline/TimelineViewController.swift +++ b/NetNewsWire/MainWindow/Timeline/TimelineViewController.swift @@ -11,6 +11,10 @@ import RSCore import Articles import Account +protocol TimelineDelegate: class { + func selectionDidChange(in: TimelineViewController, mode: TimelineSourceMode) +} + class TimelineViewController: NSViewController, UndoableCommandRunner { @IBOutlet var tableView: TimelineTableView! @@ -582,24 +586,39 @@ extension TimelineViewController: NSTableViewDataSource { extension TimelineViewController: NSTableViewDelegate { - func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? { + private static let rowViewIdentifier = NSUserInterfaceItemIdentifier(rawValue: "timelineRow") - let rowView: TimelineTableRowView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "timelineRow"), owner: self) as! TimelineTableRowView + func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? { + if let rowView: TimelineTableRowView = tableView.makeView(withIdentifier: TimelineViewController.rowViewIdentifier, owner: nil) as? TimelineTableRowView { + return rowView + } + let rowView = TimelineTableRowView() + rowView.identifier = TimelineViewController.rowViewIdentifier return rowView } + private static let timelineCellIdentifier = NSUserInterfaceItemIdentifier(rawValue: "timelineCell") + func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { - let cell: TimelineTableCellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "timelineCell"), owner: self) as! TimelineTableCellView - cell.cellAppearance = showAvatars ? cellAppearanceWithAvatar: cellAppearance - - if let article = articles.articleAtRow(row) { - configureTimelineCell(cell, article: article) - } - else { - makeTimelineCellEmpty(cell) + func configure(_ cell: TimelineTableCellView) { + cell.cellAppearance = showAvatars ? cellAppearanceWithAvatar : cellAppearance + if let article = articles.articleAtRow(row) { + configureTimelineCell(cell, article: article) + } + else { + makeTimelineCellEmpty(cell) + } } + if let cell = tableView.makeView(withIdentifier: TimelineViewController.timelineCellIdentifier, owner: nil) as? TimelineTableCellView { + configure(cell) + return cell + } + + let cell = TimelineTableCellView() + cell.identifier = TimelineViewController.timelineCellIdentifier + configure(cell) return cell }