diff --git a/Frameworks/Account/AccountManager.swift b/Frameworks/Account/AccountManager.swift
index f9f4b406b..b6b02a628 100644
--- a/Frameworks/Account/AccountManager.swift
+++ b/Frameworks/Account/AccountManager.swift
@@ -12,8 +12,8 @@ import Articles
let AccountsDidChangeNotification = "AccountsDidChangeNotification"
-private let localAccountFolderName = "OnMyMac"
-private let localAccountIdentifier = "OnMyMac"
+private let defaultAccountFolderName = "OnMyMac"
+private let defaultAccountIdentifier = "OnMyMac"
public final class AccountManager: UnreadCountProvider {
@@ -74,7 +74,7 @@ public final class AccountManager: UnreadCountProvider {
abort()
}
- defaultAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: localAccountIdentifier)!
+ defaultAccount = Account(dataFolder: localAccountFolder, type: .onMyMac, accountID: defaultAccountIdentifier)!
accountsDictionary[defaultAccount.accountID] = defaultAccount
readNonLocalAccountsFromDisk()
@@ -164,7 +164,7 @@ public final class AccountManager: UnreadCountProvider {
filenames?.forEach { (oneFilename) in
- guard oneFilename != localAccountFolderName else {
+ guard oneFilename != defaultAccountFolderName else {
return
}
if let oneAccount = createAccount(oneFilename) {
diff --git a/Mac/AppImages.swift b/Mac/AppImages.swift
index 672eed882..c99342a91 100644
--- a/Mac/AppImages.swift
+++ b/Mac/AppImages.swift
@@ -32,4 +32,10 @@ struct AppImages {
return image
}()
+ static var accountFeedbin: RSImage! = {
+ let image = RSImage(named: "accountFeedbin")
+ image?.isTemplate = true
+ return image
+ }()
+
}
diff --git a/Mac/Base.lproj/Preferences.storyboard b/Mac/Base.lproj/Preferences.storyboard
index 615d8c1a1..1b6c15388 100644
--- a/Mac/Base.lproj/Preferences.storyboard
+++ b/Mac/Base.lproj/Preferences.storyboard
@@ -345,6 +345,9 @@
+
+
+
diff --git a/Mac/Preferences/Accounts/AccountAdd.xib b/Mac/Preferences/Accounts/AccountAdd.xib
new file mode 100644
index 000000000..6b4b65405
--- /dev/null
+++ b/Mac/Preferences/Accounts/AccountAdd.xib
@@ -0,0 +1,114 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Mac/Preferences/Accounts/AccountAddTableCellView.swift b/Mac/Preferences/Accounts/AccountAddTableCellView.swift
new file mode 100644
index 000000000..16ad084db
--- /dev/null
+++ b/Mac/Preferences/Accounts/AccountAddTableCellView.swift
@@ -0,0 +1,16 @@
+//
+// AccountAddTableCellView.swift
+// NetNewsWire
+//
+// Created by Maurice Parker on 5/1/19.
+// Copyright © 2019 Ranchero Software. All rights reserved.
+//
+
+import Cocoa
+
+class AccountAddTableCellView: NSTableCellView {
+
+ @IBOutlet weak var accountImageView: NSImageView?
+ @IBOutlet weak var accountNameLabel: NSTextField?
+
+}
diff --git a/Mac/Preferences/Accounts/AccountAddViewController.swift b/Mac/Preferences/Accounts/AccountAddViewController.swift
new file mode 100644
index 000000000..73058fba8
--- /dev/null
+++ b/Mac/Preferences/Accounts/AccountAddViewController.swift
@@ -0,0 +1,85 @@
+//
+// AccountAddViewController.swift
+// NetNewsWire
+//
+// Created by Maurice Parker on 5/1/19.
+// Copyright © 2019 Ranchero Software. All rights reserved.
+//
+
+import Cocoa
+
+class AccountAddViewController: NSViewController {
+
+ @IBOutlet weak var tableView: NSTableView!
+
+ init() {
+ super.init(nibName: "AccountAdd", bundle: nil)
+ }
+
+ public required init?(coder: NSCoder) {
+ super.init(coder: coder)
+ }
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+ tableView.dataSource = self
+ tableView.delegate = self
+ }
+
+}
+
+// MARK: - NSTableViewDataSource
+
+extension AccountAddViewController: NSTableViewDataSource {
+
+ func numberOfRows(in tableView: NSTableView) -> Int {
+ return 2
+ }
+
+ func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
+ return nil
+ }
+}
+
+// MARK: - NSTableViewDelegate
+
+extension AccountAddViewController: NSTableViewDelegate {
+
+ private static let cellIdentifier = NSUserInterfaceItemIdentifier(rawValue: "AccountCell")
+
+ func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
+
+ if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? AccountAddTableCellView {
+ switch row {
+ case 0:
+ cell.accountNameLabel?.stringValue = NSLocalizedString("Local", comment: "Local")
+ cell.accountImageView?.image = AppImages.accountLocal
+ case 1:
+ cell.accountNameLabel?.stringValue = NSLocalizedString("Feedbin", comment: "Feedbin")
+ cell.accountImageView?.image = AppImages.accountFeedbin
+ default:
+ break
+ }
+ return cell
+ }
+ return nil
+ }
+
+ func tableViewSelectionDidChange(_ notification: Notification) {
+
+// let selectedRow = tableView.selectedRow
+// guard selectedRow != -1 else {
+// return
+// }
+//
+// let account = sortedAccounts[selectedRow]
+//
+// let controller = AccountDetailViewController(account: account)
+// addChild(controller)
+// controller.view.translatesAutoresizingMaskIntoConstraints = false
+// detailView.addSubview(controller.view)
+// detailView.rs_addFullSizeConstraints(forSubview: controller.view)
+
+ }
+
+}
diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift
index f7398e58a..cc56633d4 100644
--- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift
+++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift
@@ -18,20 +18,25 @@ final class AccountsPreferencesViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
- NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
- }
-
- override func viewWillAppear() {
+
updateSortedAccounts()
- tableView.reloadData()
+ tableView.delegate = self
+ tableView.dataSource = self
+
+ NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
+ showController(AccountAddViewController())
+
}
- override func viewWillDisappear() {
- super.viewWillDisappear()
- resetContainerView()
+ @IBAction func addAccount(_ sender: Any) {
+ showController(AccountAddViewController())
+ }
+
+ @IBAction func removeAccount(_ sender: Any) {
}
@objc func displayNameDidChange(_ note: Notification) {
+ updateSortedAccounts()
tableView.reloadData()
}
@@ -83,11 +88,8 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
let account = sortedAccounts[selectedRow]
let controller = AccountDetailViewController(account: account)
- addChild(controller)
- controller.view.translatesAutoresizingMaskIntoConstraints = false
- detailView.addSubview(controller.view)
- detailView.rs_addFullSizeConstraints(forSubview: controller.view)
-
+ showController(controller)
+
}
}
@@ -100,11 +102,18 @@ private extension AccountsPreferencesViewController {
sortedAccounts = AccountManager.shared.sortedAccounts
}
- func resetContainerView() {
+ func showController(_ controller: NSViewController) {
+
if let controller = children.first {
children.removeAll()
controller.view.removeFromSuperview()
}
+
+ addChild(controller)
+ controller.view.translatesAutoresizingMaskIntoConstraints = false
+ detailView.addSubview(controller.view)
+ detailView.rs_addFullSizeConstraints(forSubview: controller.view)
+
}
}
diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj
index 1c03a2424..3b2ff0456 100644
--- a/NetNewsWire.xcodeproj/project.pbxproj
+++ b/NetNewsWire.xcodeproj/project.pbxproj
@@ -113,6 +113,9 @@
51EF0F7E2277A57D0050506E /* MasterTimelineAccessibilityCellLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F7D2277A57D0050506E /* MasterTimelineAccessibilityCellLayout.swift */; };
51EF0F802277A8330050506E /* MasterTimelineCellLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F7F2277A8330050506E /* MasterTimelineCellLayout.swift */; };
51EF0F8C2279BEEB0050506E /* AccountDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F8B2279BEEB0050506E /* AccountDetailViewController.swift */; };
+ 51EF0F8E2279C9260050506E /* AccountAdd.xib in Resources */ = {isa = PBXBuildFile; fileRef = 51EF0F8D2279C9260050506E /* AccountAdd.xib */; };
+ 51EF0F902279C9500050506E /* AccountAddViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F8F2279C9500050506E /* AccountAddViewController.swift */; };
+ 51EF0F922279CA620050506E /* AccountAddTableCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EF0F912279CA620050506E /* AccountAddTableCellView.swift */; };
51F85BE5227217D000C787DC /* RefreshIntervalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51F85BDB2272162F00C787DC /* RefreshIntervalViewController.swift */; };
51F85BE7227245FC00C787DC /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51F85BE6227245FC00C787DC /* AboutViewController.swift */; };
51F85BEB22724CB600C787DC /* About.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 51F85BEA22724CB600C787DC /* About.rtf */; };
@@ -673,6 +676,9 @@
51EF0F7D2277A57D0050506E /* MasterTimelineAccessibilityCellLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineAccessibilityCellLayout.swift; sourceTree = ""; };
51EF0F7F2277A8330050506E /* MasterTimelineCellLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineCellLayout.swift; sourceTree = ""; };
51EF0F8B2279BEEB0050506E /* AccountDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountDetailViewController.swift; sourceTree = ""; };
+ 51EF0F8D2279C9260050506E /* AccountAdd.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountAdd.xib; sourceTree = ""; };
+ 51EF0F8F2279C9500050506E /* AccountAddViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountAddViewController.swift; sourceTree = ""; };
+ 51EF0F912279CA620050506E /* AccountAddTableCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountAddTableCellView.swift; sourceTree = ""; };
51F85BDB2272162F00C787DC /* RefreshIntervalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshIntervalViewController.swift; sourceTree = ""; };
51F85BE6227245FC00C787DC /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = ""; };
51F85BEA22724CB600C787DC /* About.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = About.rtf; sourceTree = ""; };
@@ -1559,6 +1565,9 @@
84C9FC7022629E1200D921D6 /* AccountsTableViewBackgroundView.swift */,
84C9FC7122629E1200D921D6 /* AccountsControlsBackgroundView.swift */,
84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */,
+ 51EF0F8D2279C9260050506E /* AccountAdd.xib */,
+ 51EF0F8F2279C9500050506E /* AccountAddViewController.swift */,
+ 51EF0F912279CA620050506E /* AccountAddTableCellView.swift */,
84C9FC7422629E1200D921D6 /* AccountDetail.xib */,
51EF0F8B2279BEEB0050506E /* AccountDetailViewController.swift */,
);
@@ -2153,6 +2162,7 @@
845479881FEB77C000AD8B59 /* TimelineKeyboardShortcuts.plist in Resources */,
848362FF2262A30E00DA1D35 /* template.html in Resources */,
848363082262A3DD00DA1D35 /* Main.storyboard in Resources */,
+ 51EF0F8E2279C9260050506E /* AccountAdd.xib in Resources */,
84C9FC8F22629E8F00D921D6 /* NetNewsWire.sdef in Resources */,
84C9FC7D22629E1200D921D6 /* AccountDetail.xib in Resources */,
84C9FC8C22629E8F00D921D6 /* KeyboardShortcuts.html in Resources */,
@@ -2348,6 +2358,7 @@
8405DD9922153B6B008CE1BF /* TimelineContainerView.swift in Sources */,
D5A2678C20130ECF00A8D3C0 /* Author+Scriptability.swift in Sources */,
84F2D5371FC22FCC00998D64 /* PseudoFeed.swift in Sources */,
+ 51EF0F902279C9500050506E /* AccountAddViewController.swift in Sources */,
D57BE6E0204CD35F00D11AAC /* NSScriptCommand+NetNewsWire.swift in Sources */,
D553738B20186C20006D8857 /* Article+Scriptability.swift in Sources */,
845EE7C11FC2488C00854A1F /* SmartFeed.swift in Sources */,
@@ -2399,6 +2410,7 @@
841ABA5E20145E9200980E11 /* FolderInspectorViewController.swift in Sources */,
845213231FCA5B11003B6E93 /* ImageDownloader.swift in Sources */,
51EF0F8C2279BEEB0050506E /* AccountDetailViewController.swift in Sources */,
+ 51EF0F922279CA620050506E /* AccountAddTableCellView.swift in Sources */,
849A97431ED9EAA9007D329B /* AddFolderWindowController.swift in Sources */,
8405DDA522168C62008CE1BF /* TimelineContainerViewController.swift in Sources */,
844B5B671FEA18E300C7C76A /* MainWIndowKeyboardHandler.swift in Sources */,