Create TimelineTableRowView and TimelineTableCellView in code.
This commit is contained in:
parent
8df96613c4
commit
9220cee0bb
|
@ -445,16 +445,6 @@
|
||||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
<prototypeCellViews>
|
|
||||||
<tableCellView identifier="timelineCell" id="58o-U2-ss4" customClass="TimelineTableCellView" customModule="NetNewsWire" customModuleProvider="target">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="447" height="68"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
|
||||||
</tableCellView>
|
|
||||||
<customView identifier="timelineRow" id="54E-Vz-WND" customClass="TimelineTableRowView" customModule="NetNewsWire" customModuleProvider="target">
|
|
||||||
<rect key="frame" x="0.0" y="68" width="447" height="96"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
|
||||||
</customView>
|
|
||||||
</prototypeCellViews>
|
|
||||||
</tableColumn>
|
</tableColumn>
|
||||||
</tableColumns>
|
</tableColumns>
|
||||||
<connections>
|
<connections>
|
||||||
|
|
|
@ -23,10 +23,6 @@ final class DetailViewController: NSViewController, WKUIDelegate {
|
||||||
@IBOutlet var containerView: DetailContainerView!
|
@IBOutlet var containerView: DetailContainerView!
|
||||||
@IBOutlet var statusBarView: DetailStatusBarView!
|
@IBOutlet var statusBarView: DetailStatusBarView!
|
||||||
|
|
||||||
enum WebViewType {
|
|
||||||
case regular, search
|
|
||||||
}
|
|
||||||
|
|
||||||
lazy var regularWebViewController = {
|
lazy var regularWebViewController = {
|
||||||
return createWebViewController()
|
return createWebViewController()
|
||||||
}()
|
}()
|
||||||
|
@ -52,7 +48,7 @@ final class DetailViewController: NSViewController, WKUIDelegate {
|
||||||
|
|
||||||
// MARK: - API
|
// MARK: - API
|
||||||
|
|
||||||
func showState(_ state: DetailState, in webViewType: WebViewType) {
|
func showState(_ state: DetailState, mode: TimelineSourceMode) {
|
||||||
// TODO: also to-do is caller
|
// TODO: also to-do is caller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,10 @@ import Articles
|
||||||
import Account
|
import Account
|
||||||
import RSCore
|
import RSCore
|
||||||
|
|
||||||
|
enum TimelineSourceMode {
|
||||||
|
case regular, search
|
||||||
|
}
|
||||||
|
|
||||||
class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||||
|
|
||||||
@IBOutlet var toolbarDelegate: MainWindowToolbarDelegate?
|
@IBOutlet var toolbarDelegate: MainWindowToolbarDelegate?
|
||||||
|
|
|
@ -68,17 +68,19 @@ class TimelineTableCellView: NSTableCellView {
|
||||||
}
|
}
|
||||||
|
|
||||||
override init(frame frameRect: NSRect) {
|
override init(frame frameRect: NSRect) {
|
||||||
|
|
||||||
super.init(frame: frameRect)
|
super.init(frame: frameRect)
|
||||||
commonInit()
|
commonInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
|
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
commonInit()
|
commonInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convenience init() {
|
||||||
|
self.init(frame: NSRect.zero)
|
||||||
|
}
|
||||||
|
|
||||||
override func setFrameSize(_ newSize: NSSize) {
|
override func setFrameSize(_ newSize: NSSize) {
|
||||||
|
|
||||||
if newSize == self.frame.size {
|
if newSize == self.frame.size {
|
||||||
|
|
|
@ -10,6 +10,14 @@ import AppKit
|
||||||
|
|
||||||
class TimelineTableRowView : NSTableRowView {
|
class TimelineTableRowView : NSTableRowView {
|
||||||
|
|
||||||
|
init() {
|
||||||
|
super.init(frame: NSRect.zero)
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder: NSCoder) {
|
||||||
|
super.init(coder: coder)
|
||||||
|
}
|
||||||
|
|
||||||
private var cellView: TimelineTableCellView? {
|
private var cellView: TimelineTableCellView? {
|
||||||
for oneSubview in subviews {
|
for oneSubview in subviews {
|
||||||
if let foundView = oneSubview as? TimelineTableCellView {
|
if let foundView = oneSubview as? TimelineTableCellView {
|
||||||
|
|
|
@ -11,6 +11,10 @@ import RSCore
|
||||||
import Articles
|
import Articles
|
||||||
import Account
|
import Account
|
||||||
|
|
||||||
|
protocol TimelineDelegate: class {
|
||||||
|
func selectionDidChange(in: TimelineViewController, mode: TimelineSourceMode)
|
||||||
|
}
|
||||||
|
|
||||||
class TimelineViewController: NSViewController, UndoableCommandRunner {
|
class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||||
|
|
||||||
@IBOutlet var tableView: TimelineTableView!
|
@IBOutlet var tableView: TimelineTableView!
|
||||||
|
@ -582,24 +586,39 @@ extension TimelineViewController: NSTableViewDataSource {
|
||||||
|
|
||||||
extension TimelineViewController: NSTableViewDelegate {
|
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
|
return rowView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static let timelineCellIdentifier = NSUserInterfaceItemIdentifier(rawValue: "timelineCell")
|
||||||
|
|
||||||
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
||||||
|
|
||||||
let cell: TimelineTableCellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "timelineCell"), owner: self) as! TimelineTableCellView
|
func configure(_ cell: TimelineTableCellView) {
|
||||||
cell.cellAppearance = showAvatars ? cellAppearanceWithAvatar: cellAppearance
|
cell.cellAppearance = showAvatars ? cellAppearanceWithAvatar : cellAppearance
|
||||||
|
if let article = articles.articleAtRow(row) {
|
||||||
if let article = articles.articleAtRow(row) {
|
configureTimelineCell(cell, article: article)
|
||||||
configureTimelineCell(cell, article: article)
|
}
|
||||||
}
|
else {
|
||||||
else {
|
makeTimelineCellEmpty(cell)
|
||||||
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
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue