I would like to know, what is the cleanest and easiest way to add footer to tableview?
Now I do a hardcoding:
func tableView(_ tableView: UITableView,
viewForFooterInSection section: Int) -> UIView? {
if viewModel.shouldShowPremiumBanner {
let footerView: LibraryFooterView = tableView.dequeueReusableHeaderFooter()
footerView.viewModel = LibraryFooterViewModel(navigator: Locator.navigator,
localStorage: Locator.localStorage)
self.tableView.tableFooterView = footerView
return footerView
}
return nil
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if viewModel.shouldShowPremiumBanner {
return estimatedSectionFooterHeight
}
return .leastNormalMagnitude
}