Drop empty space between Account sections
Reuse code for heightForHeader.
This commit is contained in:
parent
e4088aa8f3
commit
97db759242
|
@ -34,3 +34,25 @@ extension UIViewController {
|
|||
navigationItem.largeTitleDisplayMode = theme.detailTitleDisplayMode
|
||||
}
|
||||
}
|
||||
|
||||
extension TableModel {
|
||||
func headerHeight(for section: Int) -> CGFloat {
|
||||
guard let title = header(for: section) else {
|
||||
return 1.0
|
||||
}
|
||||
guard !title.isEmpty else {
|
||||
return 0.0
|
||||
}
|
||||
return UITableView.automaticDimension
|
||||
}
|
||||
|
||||
func footerHeight(for section: Int) -> CGFloat {
|
||||
guard let title = footer(for: section) else {
|
||||
return 1.0
|
||||
}
|
||||
guard !title.isEmpty else {
|
||||
return 0.0
|
||||
}
|
||||
return UITableView.automaticDimension
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ class AccountViewController: UIViewController, TableModelHost {
|
|||
model.add(.noAccount)
|
||||
model.set([], in: .noAccount)
|
||||
|
||||
model.setHeader("", for: .credentials)
|
||||
if guidance != nil {
|
||||
let footer: String
|
||||
if let _ = guidanceURL {
|
||||
|
@ -184,6 +185,10 @@ extension AccountViewController: UITableViewDataSource, UITableViewDelegate, Fie
|
|||
return model.footer(for: section)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
return model.headerHeight(for: section)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
|
||||
var optButton = view.viewWithTag(AccountViewController.footerButtonTag + section) as? UIButton
|
||||
if optButton == nil {
|
||||
|
|
|
@ -219,13 +219,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
|
|||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
guard let title = model.header(for: section) else {
|
||||
return 1.0
|
||||
}
|
||||
guard !title.isEmpty else {
|
||||
return 0.0
|
||||
}
|
||||
return UITableView.automaticDimension
|
||||
return model.headerHeight(for: section)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
|
|
|
@ -593,16 +593,6 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
|||
return model.header(for: section)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
guard let title = model.header(for: section) else {
|
||||
return 1.0
|
||||
}
|
||||
guard !title.isEmpty else {
|
||||
return 0.0
|
||||
}
|
||||
return UITableView.automaticDimension
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
|
||||
let rows = model.rows(for: section)
|
||||
if rows.contains(.providerRefresh), let date = lastInfrastructureUpdate {
|
||||
|
@ -611,6 +601,10 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
|||
return model.footer(for: section)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
return model.headerHeight(for: section)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return model.count(for: section)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue