Manos Chorianopoulos

add ProfileViewController empty view

...@@ -386,6 +386,50 @@ import UIKit ...@@ -386,6 +386,50 @@ import UIKit
386 self.filteredOffersSection = activeOffersSection 386 self.filteredOffersSection = activeOffersSection
387 } 387 }
388 } 388 }
389 +
390 + // MARK: - Empty State Helper
391 +
392 + private func getEmptyStateMessage() -> String {
393 + switch couponFilterSelected.title {
394 + case "Ενεργά":
395 + return "Δεν υπάρχουν διαθέσιμα ενεργά κουπόνια"
396 + case "Αγαπημένα":
397 + return "Δεν υπάρχουν διαθέσιμα αγαπημένα κουπόνια"
398 + case "Εξαργυρωμένα":
399 + return "Δεν υπάρχουν διαθέσιμα εξαργυρωμένα κουπόνια"
400 + default:
401 + return "Δεν υπάρχουν διαθέσιμα κουπόνια"
402 + }
403 + }
404 +
405 + private func createEmptyStateCell(_ tableView: UITableView, indexPath: IndexPath) -> UITableViewCell {
406 + let cell = UITableViewCell(style: .default, reuseIdentifier: "EmptyStateCell")
407 + cell.selectionStyle = .none
408 + cell.backgroundColor = .clear
409 + cell.contentView.backgroundColor = .clear
410 +
411 + // Remove any existing subviews
412 + cell.contentView.subviews.forEach { $0.removeFromSuperview() }
413 +
414 + let label = UILabel()
415 + label.text = getEmptyStateMessage()
416 + label.font = UIFont(name: "PingLCG-Regular", size: 16)
417 + label.textColor = UIColor(rgb: 0x8B8B8B)
418 + label.textAlignment = .center
419 + label.numberOfLines = 0
420 + label.translatesAutoresizingMaskIntoConstraints = false
421 +
422 + cell.contentView.addSubview(label)
423 +
424 + NSLayoutConstraint.activate([
425 + label.topAnchor.constraint(equalTo: cell.contentView.topAnchor, constant: 40),
426 + label.bottomAnchor.constraint(equalTo: cell.contentView.bottomAnchor, constant: -40),
427 + label.leadingAnchor.constraint(equalTo: cell.contentView.leadingAnchor, constant: 24),
428 + label.trailingAnchor.constraint(equalTo: cell.contentView.trailingAnchor, constant: -24)
429 + ])
430 +
431 + return cell
432 + }
389 } 433 }
390 434
391 // MARK: - TableView 435 // MARK: - TableView
...@@ -398,10 +442,19 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -398,10 +442,19 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
398 442
399 public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 443 public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
400 // return 1 444 // return 1
445 + if (section == 2) {
446 + if (forYouOffersSection?.count ?? 0 > 0) {
447 + return 1
448 + } else {
449 + return 0
450 + }
451 + }
401 if (section <= 3) { 452 if (section <= 3) {
402 return 1 453 return 1
403 } else { 454 } else {
404 - return filteredOffersSection?.itemCount ?? 0 455 + let itemCount = filteredOffersSection?.itemCount ?? 0
456 + // Show at least 1 row for empty state message when no coupons
457 + return itemCount > 0 ? itemCount : 1
405 } 458 }
406 } 459 }
407 460
...@@ -451,6 +504,12 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -451,6 +504,12 @@ extension ProfileViewController: UITableViewDelegate, UITableViewDataSource {
451 return cell 504 return cell
452 505
453 } else { 506 } else {
507 + // Check if the filtered section is empty — show empty state
508 + let itemCount = filteredOffersSection?.itemCount ?? 0
509 + if itemCount == 0 {
510 + return createEmptyStateCell(tableView, indexPath: indexPath)
511 + }
512 +
454 let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileCouponTableViewCell", for: indexPath) as! ProfileCouponTableViewCell 513 let cell = tableView.dequeueReusableCell(withIdentifier: "ProfileCouponTableViewCell", for: indexPath) as! ProfileCouponTableViewCell
455 if let items = self.filteredOffersSection?.items, 514 if let items = self.filteredOffersSection?.items,
456 indexPath.row < items.count, 515 indexPath.row < items.count,
......