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

Fix row height issues #217

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
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
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
Loading