Manos Chorianopoulos

MyCouponsViewController part4

...@@ -220,6 +220,15 @@ import UIKit ...@@ -220,6 +220,15 @@ import UIKit
220 couponFilterSelected = updatedSelected 220 couponFilterSelected = updatedSelected
221 } 221 }
222 222
223 + // Update table footer — scrolls with content, never sticky
224 + let itemCount = filteredOffersSection?.itemCount ?? 0
225 + if itemCount > 0 {
226 + tableView.tableFooterView = createFooterView(count: itemCount)
227 + tableView.tableFooterView?.frame = CGRect(x: 0, y: 0, width: tableView.bounds.width, height: 44)
228 + } else {
229 + tableView.tableFooterView = UIView()
230 + }
231 +
223 self.tableView.reloadData() 232 self.tableView.reloadData()
224 } 233 }
225 234
...@@ -282,6 +291,28 @@ import UIKit ...@@ -282,6 +291,28 @@ import UIKit
282 } 291 }
283 } 292 }
284 293
294 + private func createFooterView(count: Int) -> UIView {
295 + let container = UIView()
296 + container.backgroundColor = .clear
297 +
298 + let label = UILabel()
299 + label.font = UIFont(name: "PingLCG-Regular", size: 12)
300 + label.textColor = UIColor(rgb: 0x9BA1A6)
301 + label.textAlignment = .center
302 + label.text = "\(count) coupons \u{00B7} Swipe left to remove"
303 + label.translatesAutoresizingMaskIntoConstraints = false
304 +
305 + container.addSubview(label)
306 + NSLayoutConstraint.activate([
307 + label.centerXAnchor.constraint(equalTo: container.centerXAnchor),
308 + label.centerYAnchor.constraint(equalTo: container.centerYAnchor),
309 + label.leadingAnchor.constraint(greaterThanOrEqualTo: container.leadingAnchor, constant: 16),
310 + label.trailingAnchor.constraint(lessThanOrEqualTo: container.trailingAnchor, constant: -16)
311 + ])
312 +
313 + return container
314 + }
315 +
285 private func createEmptyStateCell(_ tableView: UITableView, indexPath: IndexPath) -> UITableViewCell { 316 private func createEmptyStateCell(_ tableView: UITableView, indexPath: IndexPath) -> UITableViewCell {
286 let cell = UITableViewCell(style: .default, reuseIdentifier: "EmptyStateCell") 317 let cell = UITableViewCell(style: .default, reuseIdentifier: "EmptyStateCell")
287 cell.selectionStyle = .none 318 cell.selectionStyle = .none
...@@ -400,6 +431,16 @@ extension MyCouponsViewController: ProfileCouponFiltersTableViewCellDelegate { ...@@ -400,6 +431,16 @@ extension MyCouponsViewController: ProfileCouponFiltersTableViewCellDelegate {
400 func didSelectFilter(_ filter: CouponFilterModel) { 431 func didSelectFilter(_ filter: CouponFilterModel) {
401 self.couponFilterSelected = filter 432 self.couponFilterSelected = filter
402 handleFilterPress(with: filter) 433 handleFilterPress(with: filter)
434 +
435 + // Refresh table footer count for the newly selected filter
436 + let itemCount = filteredOffersSection?.itemCount ?? 0
437 + if itemCount > 0 {
438 + tableView.tableFooterView = createFooterView(count: itemCount)
439 + tableView.tableFooterView?.frame = CGRect(x: 0, y: 0, width: tableView.bounds.width, height: 44)
440 + } else {
441 + tableView.tableFooterView = UIView()
442 + }
443 +
403 self.tableView.reloadData() 444 self.tableView.reloadData()
404 } 445 }
405 } 446 }
......