2019-05-19 21:18:11 +02:00
|
|
|
//
|
|
|
|
// AddLocalAccountViewController.swift
|
|
|
|
// NetNewsWire-iOS
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/19/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import Account
|
|
|
|
|
|
|
|
class AddLocalAccountViewController: UIViewController {
|
|
|
|
|
2019-05-24 17:07:17 +02:00
|
|
|
@IBOutlet weak var cancelBarButtonItem: UIBarButtonItem!
|
2019-05-19 23:52:21 +02:00
|
|
|
@IBOutlet private weak var localAccountNameLabel: UILabel!
|
2019-05-19 21:18:11 +02:00
|
|
|
@IBOutlet weak var nameTextField: UITextField!
|
2019-05-19 23:52:21 +02:00
|
|
|
|
2019-05-20 02:03:50 +02:00
|
|
|
weak var delegate: AddAccountDismissDelegate?
|
|
|
|
|
2019-05-19 23:52:21 +02:00
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
|
|
|
|
localAccountNameLabel.text = Account.defaultLocalAccountName
|
|
|
|
nameTextField.delegate = self
|
|
|
|
}
|
2019-05-20 02:03:50 +02:00
|
|
|
|
2019-05-24 17:07:17 +02:00
|
|
|
@IBAction func cancel(_ sender: Any) {
|
2019-06-03 12:04:03 +02:00
|
|
|
dismiss(animated: true, completion: nil)
|
|
|
|
delegate?.dismiss()
|
2019-05-24 17:07:17 +02:00
|
|
|
}
|
|
|
|
|
2019-05-23 03:29:00 +02:00
|
|
|
@IBAction func addAccountTapped(_ sender: Any) {
|
2019-05-19 21:18:11 +02:00
|
|
|
let account = AccountManager.shared.createAccount(type: .onMyMac)
|
|
|
|
account.name = nameTextField.text
|
2019-06-03 12:04:03 +02:00
|
|
|
dismiss(animated: true, completion: nil)
|
|
|
|
delegate?.dismiss()
|
2019-05-19 21:18:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-05-19 23:52:21 +02:00
|
|
|
|
|
|
|
extension AddLocalAccountViewController: UITextFieldDelegate {
|
|
|
|
|
|
|
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
|
|
|
textField.resignFirstResponder()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|