From 1a448770aef9fbed5889099f3e4b1f55e98493c4 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 24 Mar 2019 12:33:43 -0700 Subject: [PATCH] Continue progress on accounts UI in Preferences. --- NetNewsWire.xcodeproj/project.pbxproj | 6 ++ NetNewsWire/Base.lproj/Preferences.storyboard | 10 +++- .../AccountsPreferencesViewController.swift | 55 ++++++++++++++++++- .../Accounts/AccountsTableCellView.swift | 14 +++++ 4 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 NetNewsWire/Preferences/Accounts/AccountsTableCellView.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 128ba7644..c4e9302b7 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -318,6 +318,8 @@ 84F1F06A2243455C00DA0616 /* LocalAccount.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84F1F0682243455C00DA0616 /* LocalAccount.xib */; }; 84F1F06C2243457C00DA0616 /* LocalAccountPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F1F06B2243457C00DA0616 /* LocalAccountPreferencesViewController.swift */; }; 84F1F06D2243457C00DA0616 /* LocalAccountPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F1F06B2243457C00DA0616 /* LocalAccountPreferencesViewController.swift */; }; + 84F1F0702246C1D800DA0616 /* AccountsTableCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F1F06F2246C1D800DA0616 /* AccountsTableCellView.swift */; }; + 84F1F0712246C1D800DA0616 /* AccountsTableCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F1F06F2246C1D800DA0616 /* AccountsTableCellView.swift */; }; 84F204E01FAACBB30076E152 /* ArticleArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F204DF1FAACBB30076E152 /* ArticleArray.swift */; }; 84F2D5371FC22FCC00998D64 /* PseudoFeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F2D5351FC22FCB00998D64 /* PseudoFeed.swift */; }; 84F2D5381FC22FCC00998D64 /* TodayFeedDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F2D5361FC22FCB00998D64 /* TodayFeedDelegate.swift */; }; @@ -923,6 +925,7 @@ 84F1F0552242038B00DA0616 /* AccountsTableViewBackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsTableViewBackgroundView.swift; sourceTree = ""; }; 84F1F0682243455C00DA0616 /* LocalAccount.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LocalAccount.xib; sourceTree = ""; }; 84F1F06B2243457C00DA0616 /* LocalAccountPreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalAccountPreferencesViewController.swift; sourceTree = ""; }; + 84F1F06F2246C1D800DA0616 /* AccountsTableCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsTableCellView.swift; sourceTree = ""; }; 84F204CD1FAACB660076E152 /* FeedListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListViewController.swift; sourceTree = ""; }; 84F204DF1FAACBB30076E152 /* ArticleArray.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleArray.swift; sourceTree = ""; }; 84F2D5351FC22FCB00998D64 /* PseudoFeed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PseudoFeed.swift; sourceTree = ""; }; @@ -1139,6 +1142,7 @@ isa = PBXGroup; children = ( 842AE5B82241F37B004A742C /* AccountsPreferencesViewController.swift */, + 84F1F06F2246C1D800DA0616 /* AccountsTableCellView.swift */, 842AE5B72241F37B004A742C /* AccountsControlsBackgroundView.swift */, 84F1F0552242038B00DA0616 /* AccountsTableViewBackgroundView.swift */, 84F1F0672243455C00DA0616 /* Local */, @@ -2467,6 +2471,7 @@ 840F7C3321BDA4B40057E851 /* SidebarOutlineView.swift in Sources */, 840F7C3421BDA4B40057E851 /* Author+Scriptability.swift in Sources */, 840F7C3521BDA4B40057E851 /* PseudoFeed.swift in Sources */, + 84F1F0712246C1D800DA0616 /* AccountsTableCellView.swift in Sources */, 840F7C3621BDA4B40057E851 /* NSScriptCommand+NetNewsWire.swift in Sources */, 840F7C3821BDA4B40057E851 /* Article+Scriptability.swift in Sources */, 840F7C3921BDA4B40057E851 /* SmartFeed.swift in Sources */, @@ -2668,6 +2673,7 @@ 849A977B1ED9EC04007D329B /* UnreadIndicatorView.swift in Sources */, 84B99C9D1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift in Sources */, 849A97541ED9EAC0007D329B /* AddFeedWindowController.swift in Sources */, + 84F1F0702246C1D800DA0616 /* AccountsTableCellView.swift in Sources */, 849A976D1ED9EBC8007D329B /* TimelineTableView.swift in Sources */, 84D52E951FE588BB00D14F5B /* DetailStatusBarView.swift in Sources */, D5E4CC64202C1AC1009B4FFC /* MainWindowController+Scriptability.swift in Sources */, diff --git a/NetNewsWire/Base.lproj/Preferences.storyboard b/NetNewsWire/Base.lproj/Preferences.storyboard index 29c0a2f0a..88683e2cd 100644 --- a/NetNewsWire/Base.lproj/Preferences.storyboard +++ b/NetNewsWire/Base.lproj/Preferences.storyboard @@ -175,7 +175,7 @@ - + @@ -246,10 +246,10 @@ - + - + @@ -290,6 +290,10 @@ + + + + diff --git a/NetNewsWire/Preferences/Accounts/AccountsPreferencesViewController.swift b/NetNewsWire/Preferences/Accounts/AccountsPreferencesViewController.swift index 4fbe17ad4..68ff8b66b 100644 --- a/NetNewsWire/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/NetNewsWire/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -7,10 +7,61 @@ // import AppKit +import Account final class AccountsPreferencesViewController: NSViewController { - override func viewDidLoad() { - super.viewDidLoad() + private var sortedAccounts = [Account]() + + override func viewWillAppear() { + updateSortedAccounts() + } +} + +// MARK: - NSTableViewDataSource + +extension AccountsPreferencesViewController: NSTableViewDataSource { + + func numberOfRows(in tableView: NSTableView) -> Int { + return sortedAccounts.count + } + + func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? { + return sortedAccounts[row] + } +} + +// MARK: - NSTableViewDelegate + +extension AccountsPreferencesViewController: NSTableViewDelegate { + + private static let cellIdentifier = NSUserInterfaceItemIdentifier(rawValue: "AccountCell") + + func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { + + func configure(_ cell: AccountsTableCellView) { + } + + if let cell = tableView.makeView(withIdentifier: AccountsPreferencesViewController.cellIdentifier, owner: nil) as? AccountsTableCellView { + configure(cell) + return cell + } + + let cell = AccountsTableCellView() + cell.identifier = AccountsPreferencesViewController.cellIdentifier + configure(cell) + return cell + } + + func tableViewSelectionDidChange(_ notification: Notification) { + } +} + +// MARK: - Private + +private extension AccountsPreferencesViewController { + + func updateSortedAccounts() { + sortedAccounts = AccountManager.shared.sortedAccounts } } diff --git a/NetNewsWire/Preferences/Accounts/AccountsTableCellView.swift b/NetNewsWire/Preferences/Accounts/AccountsTableCellView.swift new file mode 100644 index 000000000..e2bd57a36 --- /dev/null +++ b/NetNewsWire/Preferences/Accounts/AccountsTableCellView.swift @@ -0,0 +1,14 @@ +// +// AccountsTableCellView.swift +// NetNewsWire +// +// Created by Brent Simmons on 3/23/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import AppKit + +final class AccountsTableCellView: NSTableCellView { + + +}