Create TimelineDataSource as part of making TimelineViewController less big.
This commit is contained in:
parent
21f262e953
commit
673686ca68
|
@ -17,6 +17,7 @@
|
||||||
840D61A12029031E009BC708 /* Evergreen_iOSUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D61A02029031E009BC708 /* Evergreen_iOSUITests.swift */; };
|
840D61A12029031E009BC708 /* Evergreen_iOSUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D61A02029031E009BC708 /* Evergreen_iOSUITests.swift */; };
|
||||||
8414AD251FCF5A1E00955102 /* TimelineHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8414AD241FCF5A1E00955102 /* TimelineHeaderView.swift */; };
|
8414AD251FCF5A1E00955102 /* TimelineHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8414AD241FCF5A1E00955102 /* TimelineHeaderView.swift */; };
|
||||||
84162A152038C12C00035290 /* MarkCommandValidationStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */; };
|
84162A152038C12C00035290 /* MarkCommandValidationStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */; };
|
||||||
|
84162A252038C1E000035290 /* TimelineDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84162A242038C1E000035290 /* TimelineDataSource.swift */; };
|
||||||
841ABA4E20145E7300980E11 /* NothingInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */; };
|
841ABA4E20145E7300980E11 /* NothingInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */; };
|
||||||
841ABA5E20145E9200980E11 /* FolderInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */; };
|
841ABA5E20145E9200980E11 /* FolderInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */; };
|
||||||
841ABA6020145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */; };
|
841ABA6020145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */; };
|
||||||
|
@ -534,6 +535,7 @@
|
||||||
840D61A22029031E009BC708 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
840D61A22029031E009BC708 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
8414AD241FCF5A1E00955102 /* TimelineHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineHeaderView.swift; sourceTree = "<group>"; };
|
8414AD241FCF5A1E00955102 /* TimelineHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineHeaderView.swift; sourceTree = "<group>"; };
|
||||||
84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkCommandValidationStatus.swift; sourceTree = "<group>"; };
|
84162A142038C12C00035290 /* MarkCommandValidationStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkCommandValidationStatus.swift; sourceTree = "<group>"; };
|
||||||
|
84162A242038C1E000035290 /* TimelineDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineDataSource.swift; sourceTree = "<group>"; };
|
||||||
841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NothingInspectorViewController.swift; sourceTree = "<group>"; };
|
841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NothingInspectorViewController.swift; sourceTree = "<group>"; };
|
||||||
841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderInspectorViewController.swift; sourceTree = "<group>"; };
|
841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderInspectorViewController.swift; sourceTree = "<group>"; };
|
||||||
841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuiltinSmartFeedInspectorViewController.swift; sourceTree = "<group>"; };
|
841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuiltinSmartFeedInspectorViewController.swift; sourceTree = "<group>"; };
|
||||||
|
@ -980,6 +982,7 @@
|
||||||
children = (
|
children = (
|
||||||
849A976B1ED9EBC8007D329B /* TimelineViewController.swift */,
|
849A976B1ED9EBC8007D329B /* TimelineViewController.swift */,
|
||||||
84E8E0DA202EC49300562D8F /* TimelineViewController+ContextualMenus.swift */,
|
84E8E0DA202EC49300562D8F /* TimelineViewController+ContextualMenus.swift */,
|
||||||
|
84162A242038C1E000035290 /* TimelineDataSource.swift */,
|
||||||
84F204DF1FAACBB30076E152 /* ArticleArray.swift */,
|
84F204DF1FAACBB30076E152 /* ArticleArray.swift */,
|
||||||
849A97691ED9EBC8007D329B /* TimelineTableRowView.swift */,
|
849A97691ED9EBC8007D329B /* TimelineTableRowView.swift */,
|
||||||
849A976A1ED9EBC8007D329B /* TimelineTableView.swift */,
|
849A976A1ED9EBC8007D329B /* TimelineTableView.swift */,
|
||||||
|
@ -1973,6 +1976,7 @@
|
||||||
84B99C9D1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift in Sources */,
|
84B99C9D1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift in Sources */,
|
||||||
849A97541ED9EAC0007D329B /* AddFeedWindowController.swift in Sources */,
|
849A97541ED9EAC0007D329B /* AddFeedWindowController.swift in Sources */,
|
||||||
849A976D1ED9EBC8007D329B /* TimelineTableView.swift in Sources */,
|
849A976D1ED9EBC8007D329B /* TimelineTableView.swift in Sources */,
|
||||||
|
84162A252038C1E000035290 /* TimelineDataSource.swift in Sources */,
|
||||||
84D52E951FE588BB00D14F5B /* DetailStatusBarView.swift in Sources */,
|
84D52E951FE588BB00D14F5B /* DetailStatusBarView.swift in Sources */,
|
||||||
D5E4CC64202C1AC1009B4FFC /* MainWindowController+Scriptability.swift in Sources */,
|
D5E4CC64202C1AC1009B4FFC /* MainWindowController+Scriptability.swift in Sources */,
|
||||||
84B99C671FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift in Sources */,
|
84B99C671FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift in Sources */,
|
||||||
|
|
|
@ -569,7 +569,7 @@
|
||||||
</tableColumn>
|
</tableColumn>
|
||||||
</tableColumns>
|
</tableColumns>
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="dataSource" destination="36G-bQ-b96" id="OpB-zC-ItJ"/>
|
<outlet property="dataSource" destination="7kA-tA-2n7" id="Tdx-DB-Zjs"/>
|
||||||
<outlet property="delegate" destination="36G-bQ-b96" id="s1m-42-GQ4"/>
|
<outlet property="delegate" destination="36G-bQ-b96" id="s1m-42-GQ4"/>
|
||||||
<outlet property="keyboardDelegate" destination="ZOV-xh-WJE" id="HiG-Bz-vD0"/>
|
<outlet property="keyboardDelegate" destination="ZOV-xh-WJE" id="HiG-Bz-vD0"/>
|
||||||
<outlet property="menu" destination="gb5-z4-YPr" id="pey-0u-ogu"/>
|
<outlet property="menu" destination="gb5-z4-YPr" id="pey-0u-ogu"/>
|
||||||
|
@ -605,6 +605,7 @@
|
||||||
</view>
|
</view>
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="contextualMenuDelegate" destination="iD1-KK-gFc" id="b0j-aW-e4B"/>
|
<outlet property="contextualMenuDelegate" destination="iD1-KK-gFc" id="b0j-aW-e4B"/>
|
||||||
|
<outlet property="dataSource" destination="7kA-tA-2n7" id="heZ-eT-SZ6"/>
|
||||||
<outlet property="tableView" destination="DRs-j8-R9a" id="2AG-SP-7n2"/>
|
<outlet property="tableView" destination="DRs-j8-R9a" id="2AG-SP-7n2"/>
|
||||||
</connections>
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
|
@ -635,6 +636,7 @@
|
||||||
<outlet property="timelineViewController" destination="36G-bQ-b96" id="oE9-uV-TNi"/>
|
<outlet property="timelineViewController" destination="36G-bQ-b96" id="oE9-uV-TNi"/>
|
||||||
</connections>
|
</connections>
|
||||||
</customObject>
|
</customObject>
|
||||||
|
<customObject id="7kA-tA-2n7" customClass="TimelineDataSource" customModule="Evergreen" customModuleProvider="target"/>
|
||||||
</objects>
|
</objects>
|
||||||
<point key="canvasLocation" x="62" y="394"/>
|
<point key="canvasLocation" x="62" y="394"/>
|
||||||
</scene>
|
</scene>
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
//
|
||||||
|
// TimelineDataSource.swift
|
||||||
|
// Evergreen
|
||||||
|
//
|
||||||
|
// Created by Brent Simmons on 2/17/18.
|
||||||
|
// Copyright © 2018 Ranchero Software. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import AppKit
|
||||||
|
|
||||||
|
@objc final class TimelineDataSource: NSObject, NSTableViewDataSource {
|
||||||
|
|
||||||
|
var articles = ArticleArray()
|
||||||
|
|
||||||
|
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||||
|
|
||||||
|
return articles.count
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
|
||||||
|
|
||||||
|
return articles.articleAtRow(row) ?? nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> NSPasteboardWriting? {
|
||||||
|
|
||||||
|
guard let article = articles.articleAtRow(row) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return ArticlePasteboardWriter(article: article)
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||||
|
|
||||||
@IBOutlet var tableView: TimelineTableView!
|
@IBOutlet var tableView: TimelineTableView!
|
||||||
@IBOutlet var contextualMenuDelegate: TimelineContextualMenuDelegate?
|
@IBOutlet var contextualMenuDelegate: TimelineContextualMenuDelegate?
|
||||||
|
@IBOutlet var dataSource: TimelineDataSource!
|
||||||
|
|
||||||
var selectedArticles: [Article] {
|
var selectedArticles: [Article] {
|
||||||
return Array(articles.articlesForIndexes(tableView.selectedRowIndexes))
|
return Array(articles.articlesForIndexes(tableView.selectedRowIndexes))
|
||||||
|
@ -28,6 +29,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||||
var articles = ArticleArray() {
|
var articles = ArticleArray() {
|
||||||
didSet {
|
didSet {
|
||||||
if articles != oldValue {
|
if articles != oldValue {
|
||||||
|
dataSource.articles = articles
|
||||||
updateShowAvatars()
|
updateShowAvatars()
|
||||||
tableView.reloadData()
|
tableView.reloadData()
|
||||||
}
|
}
|
||||||
|
@ -37,7 +39,6 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||||
var undoableCommands = [UndoableCommand]()
|
var undoableCommands = [UndoableCommand]()
|
||||||
private var cellAppearance: TimelineCellAppearance!
|
private var cellAppearance: TimelineCellAppearance!
|
||||||
private var cellAppearanceWithAvatar: TimelineCellAppearance!
|
private var cellAppearanceWithAvatar: TimelineCellAppearance!
|
||||||
|
|
||||||
private var showFeedNames = false {
|
private var showFeedNames = false {
|
||||||
didSet {
|
didSet {
|
||||||
if showFeedNames != oldValue {
|
if showFeedNames != oldValue {
|
||||||
|
|
Loading…
Reference in New Issue