mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-14 02:15:31 +01:00
43f175d71a
Delegate which was responsible to dismiss AddAccountViewController whenever presented view controller dismissed is not needed. So removing it simply will go to previous screen from where user comes.
58 lines
1.6 KiB
Swift
58 lines
1.6 KiB
Swift
//
|
|
// LocalAccountViewController.swift
|
|
// NetNewsWire-iOS
|
|
//
|
|
// Created by Maurice Parker on 5/19/19.
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Account
|
|
|
|
class LocalAccountViewController: UITableViewController {
|
|
|
|
@IBOutlet weak var nameTextField: UITextField!
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
navigationItem.title = Account.defaultLocalAccountName
|
|
nameTextField.delegate = self
|
|
|
|
tableView.register(ImageHeaderView.self, forHeaderFooterViewReuseIdentifier: "SectionHeader")
|
|
}
|
|
|
|
@IBAction func cancel(_ sender: Any) {
|
|
dismiss(animated: true, completion: nil)
|
|
}
|
|
|
|
@IBAction func add(_ sender: Any) {
|
|
let account = AccountManager.shared.createAccount(type: .onMyMac)
|
|
account.name = nameTextField.text
|
|
dismiss(animated: true, completion: nil)
|
|
}
|
|
|
|
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
return section == 0 ? ImageHeaderView.rowHeight : super.tableView(tableView, heightForHeaderInSection: section)
|
|
}
|
|
|
|
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
if section == 0 {
|
|
let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as! ImageHeaderView
|
|
headerView.imageView.image = AppAssets.image(for: .onMyMac)
|
|
return headerView
|
|
} else {
|
|
return super.tableView(tableView, viewForHeaderInSection: section)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension LocalAccountViewController: UITextFieldDelegate {
|
|
|
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
|
textField.resignFirstResponder()
|
|
return true
|
|
}
|
|
|
|
}
|