Manos Chorianopoulos

add ProfileViewController empty view

......@@ -386,6 +386,50 @@ import UIKit
self.filteredOffersSection = activeOffersSection
}
}
// MARK: - Empty State Helper
private func getEmptyStateMessage() -> String {
switch couponFilterSelected.title {
case "Ενεργά":
return "Δεν υπάρχουν διαθέσιμα ενεργά κουπόνια"
case "Αγαπημένα":
return "Δεν υπάρχουν διαθέσιμα αγαπημένα κουπόνια"
case "Εξαργυρωμένα":
return "Δεν υπάρχουν διαθέσιμα εξαργυρωμένα κουπόνια"
default:
return "Δεν υπάρχουν διαθέσιμα κουπόνια"
}
}
private func createEmptyStateCell(_ tableView: UITableView, indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .default, reuseIdentifier: "EmptyStateCell")
cell.selectionStyle = .none
cell.backgroundColor = .clear
cell.contentView.backgroundColor = .clear
// Remove any existing subviews
cell.contentView.subviews.forEach { $0.removeFromSuperview() }
let label = UILabel()
label.text = getEmptyStateMessage()
label.font = UIFont(name: "PingLCG-Regular", size: 16)
label.textColor = UIColor(rgb: 0x8B8B8B)
label.textAlignment = .center
label.numberOfLines = 0
label.translatesAutoresizingMaskIntoConstraints = false
cell.contentView.addSubview(label)
NSLayoutConstraint.activate([
label.topAnchor.constraint(equalTo: cell.contentView.topAnchor, constant: 40),
label.bottomAnchor.constraint(equalTo: cell.contentView.bottomAnchor, constant: -40),
label.leadingAnchor.constraint(equalTo: cell.contentView.leadingAnchor, constant: 24),
label.trailingAnchor.constraint(equalTo: cell.contentView.trailingAnchor, constant: -24)
])
return cell
}
}
// MARK: - TableView
......@@ -398,10 +442,19 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return 1
if (section == 2) {
if (forYouOffersSection?.count ?? 0 > 0) {
return 1
} else {
return 0
}
}
if (section <= 3) {
return 1
} else {
return filteredOffersSection?.itemCount ?? 0
let itemCount = filteredOffersSection?.itemCount ?? 0
// Show at least 1 row for empty state message when no coupons
return itemCount > 0 ? itemCount : 1
}
}
......@@ -451,6 +504,12 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
return cell
} else {
// Check if the filtered section is empty — show empty state
let itemCount = filteredOffersSection?.itemCount ?? 0
if itemCount == 0 {
return createEmptyStateCell(tableView, indexPath: indexPath)
}
let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileCouponTableViewCell", for: indexPath) as! ProfileCouponTableViewCell
if let items = self.filteredOffersSection?.items,
indexPath.row < items.count,
......