Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default table header height and table footer height configurable #1339

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions Source/Core/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,13 @@ open class FormViewController: UIViewController, FormViewControllerProtocol, For
/// Defines the behaviour of the navigation between rows
public var navigationOptions: RowNavigationOptions?
private var tableViewStyle: UITableViewStyle = .grouped


/// Defines default header height if no header view has been provided
public var defaultHeaderHeight = UITableViewAutomaticDimension

/// Defines default footer height if no footer view has been provided
public var defaultFooterHeight = UITableViewAutomaticDimension

public init(style: UITableViewStyle) {
super.init(nibName: nil, bundle: nil)
Expand Down Expand Up @@ -798,15 +805,29 @@ extension FormViewController : UITableViewDelegate {
}

open func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return height(specifiedHeight: form[section].header?.height,
sectionView: self.tableView(tableView, viewForHeaderInSection: section),
sectionTitle: self.tableView(tableView, titleForHeaderInSection: section))
if let height = form[section].header?.height {
return height()
}
guard let view = form[section].header?.viewForSection(form[section], type: .header) else {
return defaultHeaderHeight
}
guard view.bounds.height != 0 else {
return defaultHeaderHeight
}
return view.bounds.height
}

open func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return height(specifiedHeight: form[section].footer?.height,
sectionView: self.tableView(tableView, viewForFooterInSection: section),
sectionTitle: self.tableView(tableView, titleForFooterInSection: section))
if let height = form[section].footer?.height {
return height()
}
guard let view = form[section].footer?.viewForSection(form[section], type: .footer) else {
return defaultFooterHeight
}
guard view.bounds.height != 0 else {
return defaultFooterHeight
}
return view.bounds.height
}

open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
Expand Down