Explicity identify the addable account types, allowing for a contingent list given factors such as macOS API availability.
This commit is contained in:
parent
86a302f787
commit
f27b7029de
|
@ -15,6 +15,8 @@ class AccountsAddViewController: NSViewController {
|
||||||
|
|
||||||
private var accountsAddWindowController: NSWindowController?
|
private var accountsAddWindowController: NSWindowController?
|
||||||
|
|
||||||
|
private let addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .freshRSS]
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
super.init(nibName: "AccountsAdd", bundle: nil)
|
super.init(nibName: "AccountsAdd", bundle: nil)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +41,7 @@ class AccountsAddViewController: NSViewController {
|
||||||
extension AccountsAddViewController: NSTableViewDataSource {
|
extension AccountsAddViewController: NSTableViewDataSource {
|
||||||
|
|
||||||
func numberOfRows(in tableView: NSTableView) -> Int {
|
func numberOfRows(in tableView: NSTableView) -> Int {
|
||||||
return 3
|
return addableAccountTypes.count
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
|
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
|
||||||
|
@ -56,14 +58,14 @@ extension AccountsAddViewController: NSTableViewDelegate {
|
||||||
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
||||||
|
|
||||||
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? AccountsAddTableCellView {
|
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? AccountsAddTableCellView {
|
||||||
switch row {
|
switch addableAccountTypes[row] {
|
||||||
case 0:
|
case .onMyMac:
|
||||||
cell.accountNameLabel?.stringValue = Account.defaultLocalAccountName
|
cell.accountNameLabel?.stringValue = Account.defaultLocalAccountName
|
||||||
cell.accountImageView?.image = AppAssets.accountLocal
|
cell.accountImageView?.image = AppAssets.accountLocal
|
||||||
case 1:
|
case .feedbin:
|
||||||
cell.accountNameLabel?.stringValue = NSLocalizedString("Feedbin", comment: "Feedbin")
|
cell.accountNameLabel?.stringValue = NSLocalizedString("Feedbin", comment: "Feedbin")
|
||||||
cell.accountImageView?.image = AppAssets.accountFeedbin
|
cell.accountImageView?.image = AppAssets.accountFeedbin
|
||||||
case 2:
|
case .freshRSS:
|
||||||
cell.accountNameLabel?.stringValue = NSLocalizedString("FreshRSS", comment: "FreshRSS")
|
cell.accountNameLabel?.stringValue = NSLocalizedString("FreshRSS", comment: "FreshRSS")
|
||||||
cell.accountImageView?.image = AppAssets.accountFreshRSS
|
cell.accountImageView?.image = AppAssets.accountFreshRSS
|
||||||
default:
|
default:
|
||||||
|
@ -81,16 +83,16 @@ extension AccountsAddViewController: NSTableViewDelegate {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
switch selectedRow {
|
switch addableAccountTypes[selectedRow] {
|
||||||
case 0:
|
case .onMyMac:
|
||||||
let accountsAddLocalWindowController = AccountsAddLocalWindowController()
|
let accountsAddLocalWindowController = AccountsAddLocalWindowController()
|
||||||
accountsAddLocalWindowController.runSheetOnWindow(self.view.window!)
|
accountsAddLocalWindowController.runSheetOnWindow(self.view.window!)
|
||||||
accountsAddWindowController = accountsAddLocalWindowController
|
accountsAddWindowController = accountsAddLocalWindowController
|
||||||
case 1:
|
case .feedbin:
|
||||||
let accountsFeedbinWindowController = AccountsFeedbinWindowController()
|
let accountsFeedbinWindowController = AccountsFeedbinWindowController()
|
||||||
accountsFeedbinWindowController.runSheetOnWindow(self.view.window!)
|
accountsFeedbinWindowController.runSheetOnWindow(self.view.window!)
|
||||||
accountsAddWindowController = accountsFeedbinWindowController
|
accountsAddWindowController = accountsFeedbinWindowController
|
||||||
case 2:
|
case .freshRSS:
|
||||||
let accountsReaderAPIWindowController = AccountsReaderAPIWindowController()
|
let accountsReaderAPIWindowController = AccountsReaderAPIWindowController()
|
||||||
accountsReaderAPIWindowController.accountType = .freshRSS
|
accountsReaderAPIWindowController.accountType = .freshRSS
|
||||||
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
|
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
|
||||||
|
|
Loading…
Reference in New Issue