2019-03-21 06:10:22 +01:00
|
|
|
//
|
2019-05-01 18:05:55 +02:00
|
|
|
// AccountsDetailViewController.swift
|
2019-03-21 06:10:22 +01:00
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 3/20/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import AppKit
|
|
|
|
import Account
|
|
|
|
|
2019-05-01 18:05:55 +02:00
|
|
|
final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate {
|
2019-03-21 06:10:22 +01:00
|
|
|
|
2019-04-30 13:38:18 +02:00
|
|
|
@IBOutlet weak var typeLabel: NSTextField!
|
|
|
|
@IBOutlet weak var nameTextField: NSTextField!
|
2019-05-02 12:41:44 +02:00
|
|
|
@IBOutlet weak var activeButton: NSButtonCell!
|
2019-05-04 23:10:58 +02:00
|
|
|
@IBOutlet weak var credentialsButton: NSButton!
|
2019-04-30 13:38:18 +02:00
|
|
|
|
2019-05-04 23:10:58 +02:00
|
|
|
private var accountsWindowController: NSWindowController?
|
|
|
|
private var account: Account?
|
2019-03-21 06:10:22 +01:00
|
|
|
|
|
|
|
init(account: Account) {
|
2019-05-01 18:05:55 +02:00
|
|
|
super.init(nibName: "AccountsDetail", bundle: nil)
|
2019-03-21 06:10:22 +01:00
|
|
|
self.account = account
|
|
|
|
}
|
|
|
|
|
|
|
|
public required init?(coder: NSCoder) {
|
|
|
|
super.init(coder: coder)
|
|
|
|
}
|
2019-04-30 13:38:18 +02:00
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
2019-05-04 23:10:58 +02:00
|
|
|
|
2019-04-30 13:38:18 +02:00
|
|
|
nameTextField.delegate = self
|
|
|
|
typeLabel.stringValue = account?.defaultName ?? ""
|
|
|
|
nameTextField.stringValue = account?.name ?? ""
|
2019-05-02 12:41:44 +02:00
|
|
|
activeButton.state = account?.isActive ?? false ? .on : .off
|
2019-05-04 23:10:58 +02:00
|
|
|
credentialsButton.isHidden = account?.type ?? .onMyMac == .onMyMac
|
2019-04-30 13:38:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func controlTextDidEndEditing(_ obj: Notification) {
|
|
|
|
if !nameTextField.stringValue.isEmpty {
|
|
|
|
account?.name = nameTextField.stringValue
|
|
|
|
} else {
|
|
|
|
account?.name = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-02 12:41:44 +02:00
|
|
|
@IBAction func active(_ sender: NSButtonCell) {
|
|
|
|
account?.isActive = sender.state == .on ? true : false
|
|
|
|
}
|
|
|
|
|
2019-05-04 23:10:58 +02:00
|
|
|
@IBAction func credentials(_ sender: Any) {
|
|
|
|
|
|
|
|
guard let account = account else { return }
|
|
|
|
|
|
|
|
switch account.type {
|
|
|
|
case .feedbin:
|
|
|
|
let accountsFeedbinWindowController = AccountsFeedbinWindowController()
|
|
|
|
accountsFeedbinWindowController.account = account
|
|
|
|
accountsFeedbinWindowController.runSheetOnWindow(self.view.window!)
|
|
|
|
accountsWindowController = accountsFeedbinWindowController
|
2019-06-23 15:31:04 +02:00
|
|
|
case .freshRSS:
|
|
|
|
let accountsFreshRSSWindowController = AccountsReaderAPIWindowController()
|
|
|
|
accountsFreshRSSWindowController.accountType = account.type
|
|
|
|
accountsFreshRSSWindowController.account = account
|
|
|
|
accountsFreshRSSWindowController.runSheetOnWindow(self.view.window!)
|
|
|
|
accountsWindowController = accountsFreshRSSWindowController
|
2019-09-18 01:18:06 +02:00
|
|
|
case .feedly:
|
|
|
|
assertionFailure("Implement feedly logout window controller")
|
|
|
|
break
|
2019-05-04 23:10:58 +02:00
|
|
|
default:
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-03-21 06:10:22 +01:00
|
|
|
}
|