2019-05-01 17:28:13 +02:00
|
|
|
//
|
2019-05-01 18:05:55 +02:00
|
|
|
// AccountsAddViewController.swift
|
2019-05-01 17:28:13 +02:00
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/1/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2019-05-01 19:37:13 +02:00
|
|
|
import AppKit
|
2019-05-19 23:52:21 +02:00
|
|
|
import Account
|
2019-05-01 17:28:13 +02:00
|
|
|
|
2019-05-01 18:05:55 +02:00
|
|
|
class AccountsAddViewController: NSViewController {
|
2019-05-01 17:28:13 +02:00
|
|
|
|
|
|
|
@IBOutlet weak var tableView: NSTableView!
|
|
|
|
|
2019-05-01 19:37:13 +02:00
|
|
|
private var accountsAddWindowController: NSWindowController?
|
|
|
|
|
2019-05-01 17:28:13 +02:00
|
|
|
init() {
|
2019-05-01 18:05:55 +02:00
|
|
|
super.init(nibName: "AccountsAdd", bundle: nil)
|
2019-05-01 17:28:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public required init?(coder: NSCoder) {
|
|
|
|
super.init(coder: coder)
|
|
|
|
}
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
2019-05-01 19:37:13 +02:00
|
|
|
|
2019-05-01 17:28:13 +02:00
|
|
|
super.viewDidLoad()
|
2019-05-01 19:37:13 +02:00
|
|
|
|
2019-05-01 17:28:13 +02:00
|
|
|
tableView.dataSource = self
|
|
|
|
tableView.delegate = self
|
|
|
|
|
2019-05-01 19:37:13 +02:00
|
|
|
}
|
|
|
|
|
2019-05-01 17:28:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - NSTableViewDataSource
|
|
|
|
|
2019-05-01 18:05:55 +02:00
|
|
|
extension AccountsAddViewController: NSTableViewDataSource {
|
2019-05-01 17:28:13 +02:00
|
|
|
|
|
|
|
func numberOfRows(in tableView: NSTableView) -> Int {
|
2019-05-28 19:08:15 +02:00
|
|
|
return 3
|
2019-05-01 17:28:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - NSTableViewDelegate
|
|
|
|
|
2019-05-01 18:05:55 +02:00
|
|
|
extension AccountsAddViewController: NSTableViewDelegate {
|
2019-05-01 17:28:13 +02:00
|
|
|
|
|
|
|
private static let cellIdentifier = NSUserInterfaceItemIdentifier(rawValue: "AccountCell")
|
|
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
|
|
|
2019-05-01 18:05:55 +02:00
|
|
|
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? AccountsAddTableCellView {
|
2019-05-01 17:28:13 +02:00
|
|
|
switch row {
|
|
|
|
case 0:
|
2019-05-19 23:52:21 +02:00
|
|
|
cell.accountNameLabel?.stringValue = Account.defaultLocalAccountName
|
2019-05-21 12:42:40 +02:00
|
|
|
cell.accountImageView?.image = AppAssets.accountLocal
|
2019-05-01 17:28:13 +02:00
|
|
|
case 1:
|
|
|
|
cell.accountNameLabel?.stringValue = NSLocalizedString("Feedbin", comment: "Feedbin")
|
2019-05-21 12:42:40 +02:00
|
|
|
cell.accountImageView?.image = AppAssets.accountFeedbin
|
2019-05-28 19:08:15 +02:00
|
|
|
case 2:
|
2019-06-19 22:40:03 +02:00
|
|
|
cell.accountNameLabel?.stringValue = NSLocalizedString("Reader API", comment: "Reader API")
|
|
|
|
cell.accountImageView?.image = AppAssets.accountReader
|
2019-05-01 17:28:13 +02:00
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
return cell
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
|
|
|
|
2019-05-01 19:37:13 +02:00
|
|
|
let selectedRow = tableView.selectedRow
|
|
|
|
guard selectedRow != -1 else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
switch selectedRow {
|
|
|
|
case 0:
|
|
|
|
let accountsAddLocalWindowController = AccountsAddLocalWindowController()
|
|
|
|
accountsAddLocalWindowController.runSheetOnWindow(self.view.window!)
|
|
|
|
accountsAddWindowController = accountsAddLocalWindowController
|
2019-05-03 01:17:52 +02:00
|
|
|
case 1:
|
2019-05-04 23:10:58 +02:00
|
|
|
let accountsFeedbinWindowController = AccountsFeedbinWindowController()
|
|
|
|
accountsFeedbinWindowController.runSheetOnWindow(self.view.window!)
|
|
|
|
accountsAddWindowController = accountsFeedbinWindowController
|
2019-05-28 19:08:15 +02:00
|
|
|
case 2:
|
2019-06-19 18:25:37 +02:00
|
|
|
let accountsReaderAPIWindowController = AccountsReaderAPIWindowController()
|
|
|
|
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
|
|
|
|
accountsAddWindowController = accountsReaderAPIWindowController
|
2019-05-01 19:37:13 +02:00
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
tableView.selectRowIndexes([], byExtendingSelection: false)
|
2019-05-01 17:28:13 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|