Skip to content

Commit

Permalink
Fix row height issues (#217)
Browse files Browse the repository at this point in the history
* add estimated heights and change default height for header and footers

* update changelog

* update podspec version
  • Loading branch information
DerCSpringer committed Sep 26, 2023
1 parent 1d535d5 commit 978a4cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The changelog for `ReactiveLists`. Also see the [releases](https://github.com/pl

NEXT
----
0.8.1.9
-----
- Added UITableViewDelegate calls for estimated row, header, footer heights
- Changed default header/footer heights from `leastNormalMagnitude` to 0.0

0.8.1.8
-----
- Added support for CollectionView cells lazy-loading.
Expand Down
2 changes: 1 addition & 1 deletion ReactiveLists.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ReactiveLists"
s.version = "0.8.1.beta.8"
s.version = "0.8.1.beta.9"

s.summary = "React-like API for UITableView and UICollectionView"
s.homepage = "https://github.com/plangrid/ReactiveLists"
Expand Down
19 changes: 17 additions & 2 deletions Sources/TableViewDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ extension TableViewDriver: UITableViewDelegate {
guard let tableViewModel = self.tableViewModel else { return 0 }
return tableViewModel[ifExists: indexPath]?.rowHeight ?? tableViewModel.defaultRowHeight
}
/// :nodoc:
public func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
guard let tableViewModel = self.tableViewModel else { return 0 }
return tableViewModel[ifExists: indexPath]?.rowHeight ?? tableViewModel.defaultRowHeight
}

/// :nodoc:
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
Expand All @@ -340,12 +345,22 @@ extension TableViewDriver: UITableViewDelegate {

/// :nodoc:
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return self.tableViewModel?[ifExists: section]?.headerViewModel?.height(forSection: section, totalSections: self.numberOfSections(in: tableView)) ?? CGFloat.leastNormalMagnitude
return self.tableViewModel?[ifExists: section]?.headerViewModel?.height(forSection: section, totalSections: self.numberOfSections(in: tableView)) ?? 0.0
}

/// :nodoc:
public func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat {
return self.tableViewModel?[ifExists: section]?.headerViewModel?.height(forSection: section, totalSections: self.numberOfSections(in: tableView)) ?? 0.0
}

/// :nodoc:
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return self.tableViewModel?[ifExists: section]?.footerViewModel?.height(forSection: section, totalSections: self.numberOfSections(in: tableView)) ?? CGFloat.leastNormalMagnitude
return self.tableViewModel?[ifExists: section]?.footerViewModel?.height(forSection: section, totalSections: self.numberOfSections(in: tableView)) ?? 0.0
}

/// :nodoc:
public func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat {
return self.tableViewModel?[ifExists: section]?.footerViewModel?.height(forSection: section, totalSections: self.numberOfSections(in: tableView)) ?? 0.0
}

/// :nodoc:
Expand Down

0 comments on commit 978a4cb

Please sign in to comment.