Manos Chorianopoulos

MyCouponsViewController part4

......@@ -220,6 +220,15 @@ import UIKit
couponFilterSelected = updatedSelected
}
// Update table footer — scrolls with content, never sticky
let itemCount = filteredOffersSection?.itemCount ?? 0
if itemCount > 0 {
tableView.tableFooterView = createFooterView(count: itemCount)
tableView.tableFooterView?.frame = CGRect(x: 0, y: 0, width: tableView.bounds.width, height: 44)
} else {
tableView.tableFooterView = UIView()
}
self.tableView.reloadData()
}
......@@ -282,6 +291,28 @@ import UIKit
}
}
private func createFooterView(count: Int) -> UIView {
let container = UIView()
container.backgroundColor = .clear
let label = UILabel()
label.font = UIFont(name: "PingLCG-Regular", size: 12)
label.textColor = UIColor(rgb: 0x9BA1A6)
label.textAlignment = .center
label.text = "\(count) coupons \u{00B7} Swipe left to remove"
label.translatesAutoresizingMaskIntoConstraints = false
container.addSubview(label)
NSLayoutConstraint.activate([
label.centerXAnchor.constraint(equalTo: container.centerXAnchor),
label.centerYAnchor.constraint(equalTo: container.centerYAnchor),
label.leadingAnchor.constraint(greaterThanOrEqualTo: container.leadingAnchor, constant: 16),
label.trailingAnchor.constraint(lessThanOrEqualTo: container.trailingAnchor, constant: -16)
])
return container
}
private func createEmptyStateCell(_ tableView: UITableView, indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .default, reuseIdentifier: "EmptyStateCell")
cell.selectionStyle = .none
......@@ -400,6 +431,16 @@ extension MyCouponsViewController: ProfileCouponFiltersTableViewCellDelegate {
func didSelectFilter(_ filter: CouponFilterModel) {
self.couponFilterSelected = filter
handleFilterPress(with: filter)
// Refresh table footer count for the newly selected filter
let itemCount = filteredOffersSection?.itemCount ?? 0
if itemCount > 0 {
tableView.tableFooterView = createFooterView(count: itemCount)
tableView.tableFooterView?.frame = CGRect(x: 0, y: 0, width: tableView.bounds.width, height: 44)
} else {
tableView.tableFooterView = UIView()
}
self.tableView.reloadData()
}
}
......