NetNewsWire/Mac/Preferences/Accounts/AccountDetailViewController...

44 lines
979 B
Swift
Raw Normal View History

//
// LocalAccountPreferencesViewController.swift
// NetNewsWire
//
// Created by Brent Simmons on 3/20/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import AppKit
import Account
2019-05-01 13:49:50 +02:00
final class AccountDetailViewController: NSViewController, NSTextFieldDelegate {
@IBOutlet weak var typeLabel: NSTextField!
@IBOutlet weak var nameTextField: NSTextField!
private weak var account: Account?
init(account: Account) {
2019-05-01 13:49:50 +02:00
super.init(nibName: "AccountDetail", bundle: nil)
self.account = account
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
}
override func viewDidLoad() {
super.viewDidLoad()
nameTextField.delegate = self
typeLabel.stringValue = account?.defaultName ?? ""
nameTextField.stringValue = account?.name ?? ""
}
func controlTextDidEndEditing(_ obj: Notification) {
if !nameTextField.stringValue.isEmpty {
account?.name = nameTextField.stringValue
} else {
account?.name = nil
}
}
}