mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Further sizing improvements on iPad. Only show add feed / folder pickers when there is more than 1 item to display.
This commit is contained in:
@@ -12,9 +12,13 @@ import RSCore
|
||||
|
||||
class AddFolderViewController: UITableViewController, AddContainerViewControllerChild {
|
||||
|
||||
@IBOutlet weak var nameTextField: UITextField!
|
||||
@IBOutlet weak var accountLabel: UILabel!
|
||||
@IBOutlet weak var accountPickerView: UIPickerView!
|
||||
@IBOutlet private weak var nameTextField: UITextField!
|
||||
@IBOutlet private weak var accountLabel: UILabel!
|
||||
@IBOutlet private weak var accountPickerView: UIPickerView!
|
||||
|
||||
private var shouldDisplayPicker: Bool {
|
||||
return accounts.count > 1
|
||||
}
|
||||
|
||||
private var accounts: [Account]!
|
||||
|
||||
@@ -25,10 +29,16 @@ class AddFolderViewController: UITableViewController, AddContainerViewController
|
||||
super.viewDidLoad()
|
||||
|
||||
accounts = AccountManager.shared.sortedActiveAccounts
|
||||
|
||||
nameTextField.delegate = self
|
||||
accountLabel.text = (accounts[0] as DisplayNameProvider).nameForDisplay
|
||||
|
||||
accountPickerView.dataSource = self
|
||||
accountPickerView.delegate = self
|
||||
if shouldDisplayPicker {
|
||||
accountPickerView.dataSource = self
|
||||
accountPickerView.delegate = self
|
||||
} else {
|
||||
accountPickerView.isHidden = true
|
||||
}
|
||||
|
||||
// I couldn't figure out the gap at the top of the UITableView, so I took a hammer to it.
|
||||
tableView.contentInset = UIEdgeInsets(top: -28, left: 0, bottom: 0, right: 0)
|
||||
@@ -53,6 +63,13 @@ class AddFolderViewController: UITableViewController, AddContainerViewController
|
||||
delegate?.readyToAdd(state: !(nameTextField.text?.isEmpty ?? false))
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
if section == 1 && !shouldDisplayPicker {
|
||||
return 1
|
||||
}
|
||||
|
||||
return super.tableView(tableView, numberOfRowsInSection: section)
|
||||
}
|
||||
}
|
||||
|
||||
extension AddFolderViewController: UIPickerViewDataSource, UIPickerViewDelegate {
|
||||
@@ -74,3 +91,12 @@ extension AddFolderViewController: UIPickerViewDataSource, UIPickerViewDelegate
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension AddFolderViewController: UITextFieldDelegate {
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user