Manos Chorianopoulos

MyCoupons part2

......@@ -115,47 +115,91 @@ extension UIViewController {
// self.navigationController?.navigationBar.layoutIfNeeded()
// }
func setBackButton(_ icon:String = "ic_back_4") {
func setBackButton(_ icon: String = "ic_back_4") {
self.navigationItem.setHidesBackButton(true, animated: false)
let button = UIButton(type: .custom)
button.frame = CGRect(x: 0, y: 0, width: 24, height: 24)
button.frame = CGRect(x: 0, y: 0, width: 15, height: 15)
button.imageView?.contentMode = .scaleAspectFit
if let img = UIImage(named: icon, in: Bundle.frameworkResourceBundle, compatibleWith: nil) {
button.setImage(img, for: .normal)
button.setImage(img.withRenderingMode(.alwaysOriginal), for: .normal)
}
button.addTarget(self, action: #selector(moveToBack(_:)), for: .touchUpInside)
let leftBarButtonItem = UIBarButtonItem(customView: view )
let leftBarButtonItem = UIBarButtonItem(customView: button)
NSLayoutConstraint.activate([
leftBarButtonItem.customView!.widthAnchor.constraint(equalToConstant: 15),
leftBarButtonItem.customView!.heightAnchor.constraint(equalToConstant: 15)
])
self.navigationItem.leftBarButtonItem = leftBarButtonItem
self.navigationItem.title = ""
// Add backgroundColor
// Nav bar appearance — white background
if #available(iOS 15, *) {
let navigationBarAppearance = UINavigationBarAppearance()
navigationBarAppearance.configureWithDefaultBackground()
// navigationBarAppearance.configureWithTransparentBackground()
navigationBarAppearance.backgroundColor = .white
navigationBarAppearance.shadowColor = .clear
navigationItem.standardAppearance = navigationBarAppearance
navigationItem.compactAppearance = navigationBarAppearance
navigationItem.scrollEdgeAppearance = navigationBarAppearance
} else {
navigationController?.navigationBar.barTintColor = UIColor.white
navigationController?.navigationBar.tintColor = UIColor.white
// navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.barTintColor = .white
navigationController?.navigationBar.tintColor = .white
}
// Remove navigationBar bottom border
// self.navigationController?.navigationBar.hideBottomHairline()
self.navigationController?.hideHairline()
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for:.default)
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.layoutIfNeeded()
}
// func setBackButton(_ icon:String = "ic_back_4") {
// self.navigationItem.setHidesBackButton(true, animated: false)
// let button = UIButton(type: .custom)
// button.frame = CGRect(x: 0, y: 0, width: 24, height: 24)
// button.imageView?.contentMode = .scaleAspectFit
// if let img = UIImage(named: icon, in: Bundle.frameworkResourceBundle, compatibleWith: nil) {
// button.setImage(img, for: .normal)
// }
// button.addTarget(self, action: #selector(moveToBack(_:)), for: .touchUpInside)
// let leftBarButtonItem = UIBarButtonItem(customView: view )
// self.navigationItem.leftBarButtonItem = leftBarButtonItem
// self.navigationItem.title = ""
// // Add backgroundColor
// if #available(iOS 15, *) {
// let navigationBarAppearance = UINavigationBarAppearance()
// navigationBarAppearance.configureWithDefaultBackground()
// navigationBarAppearance.backgroundColor = .white
// navigationItem.standardAppearance = navigationBarAppearance
// navigationItem.compactAppearance = navigationBarAppearance
// navigationItem.scrollEdgeAppearance = navigationBarAppearance
// } else {
// navigationController?.navigationBar.barTintColor = UIColor.white
// navigationController?.navigationBar.tintColor = UIColor.white
// // navigationController?.navigationBar.isTranslucent = false
// }
// // Remove navigationBar bottom border
// // self.navigationController?.navigationBar.hideBottomHairline()
// self.navigationController?.hideHairline()
// self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for:.default)
// self.navigationController?.navigationBar.shadowImage = UIImage()
// self.navigationController?.navigationBar.layoutIfNeeded()
// }
@objc func moveToBack(_ sender:UIButton){
self.navigationController?.popViewController(animated: true)
......
......@@ -13,7 +13,7 @@ protocol ProfileCouponFiltersTableViewCellDelegate: AnyObject {
@objc(ProfileCouponFiltersTableViewCell)
public class ProfileCouponFiltersTableViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
// @IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var collectionView: UICollectionView!
weak var delegate: ProfileCouponFiltersTableViewCellDelegate?
......@@ -24,9 +24,9 @@ public class ProfileCouponFiltersTableViewCell: UITableViewCell {
public override func awakeFromNib() {
super.awakeFromNib()
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 18)
titleLabel.textColor = UIColor(rgb: 0x000F1E)
titleLabel.text = "Τα κουπόνια μου"
// titleLabel.font = UIFont(name: "PingLCG-Bold", size: 18)
// titleLabel.textColor = UIColor(rgb: 0x000F1E)
// titleLabel.text = "Τα κουπόνια μου"
// UPDATED: Safe XIB registration for collection view cells
registerCollectionViewCells()
......@@ -62,9 +62,9 @@ public class ProfileCouponFiltersTableViewCell: UITableViewCell {
// Configure collection view layout
if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 15
layout.minimumLineSpacing = 4
layout.minimumInteritemSpacing = 0
layout.sectionInset = UIEdgeInsets(top: 8, left: 24, bottom: 8, right: 24)
layout.sectionInset = UIEdgeInsets(top: 8, left: 18, bottom: 8, right: 18)
layout.estimatedItemSize = CGSize(width: 100, height: 43)
}
......@@ -101,7 +101,7 @@ extension ProfileCouponFiltersTableViewCell: UICollectionViewDataSource, UIColle
if let filter = self.data?[indexPath.row] {
// let isSelected = self.data?[indexPath.row].title == "Ενεργά"
// let isSelected = self.data?[indexPath.row].title == self.couponFilterSelected.title
let isSelected = self.data?[indexPath.row].title == self.couponFilterSelected?.title ?? "Ενεργά"
let isSelected = self.data?[indexPath.row].title == self.couponFilterSelected?.title ?? "Valid"
cell.configureCell(data: filter, isSelected: isSelected)
}
return cell;
......@@ -121,7 +121,7 @@ extension ProfileCouponFiltersTableViewCell: UICollectionViewDataSource, UIColle
// Calculate width based on text content
let text = filter.title
let font = UIFont(name: "PingLCG-Regular", size: 16) ?? UIFont.systemFont(ofSize: 16)
let font = UIFont(name: "PingLCG-Regular", size: 14) ?? UIFont.systemFont(ofSize: 14)
let textSize = text.size(withAttributes: [.font: font])
// Add padding for button design (16pt left + 16pt right = 32pt total)
......@@ -133,7 +133,7 @@ extension ProfileCouponFiltersTableViewCell: UICollectionViewDataSource, UIColle
// Distance Between Item Cells
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 15
return 4
}
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
......@@ -142,6 +142,6 @@ extension ProfileCouponFiltersTableViewCell: UICollectionViewDataSource, UIColle
// Cell Margin
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 24, bottom: 0, right: 24)
return UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18)
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
......@@ -12,21 +12,15 @@
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="ProfileCouponFiltersTableViewCell" rowHeight="161" id="KGk-i7-Jjw" customClass="ProfileCouponFiltersTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="161"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="161"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1kR-zd-duR" userLabel="ParentView">
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1kR-zd-duR" userLabel="ParentView">
<rect key="frame" x="0.0" y="0.0" width="320" height="161"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mga-ND-qoh">
<rect key="frame" x="24" y="26" width="272" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="Ddn-dN-xH1">
<rect key="frame" x="0.0" y="83" width="320" height="48"/>
<rect key="frame" x="0.0" y="20" width="320" height="48"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="5nG-1p-kic"/>
......@@ -46,13 +40,10 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Ddn-dN-xH1" firstAttribute="top" secondItem="mga-ND-qoh" secondAttribute="bottom" constant="40" id="1gh-45-u6h"/>
<constraint firstItem="Ddn-dN-xH1" firstAttribute="leading" secondItem="1kR-zd-duR" secondAttribute="leading" id="3IU-v8-7cI"/>
<constraint firstItem="mga-ND-qoh" firstAttribute="top" secondItem="1kR-zd-duR" secondAttribute="top" constant="26" id="J0I-v0-uwq"/>
<constraint firstAttribute="trailing" secondItem="mga-ND-qoh" secondAttribute="trailing" constant="24" id="Ss1-zq-znd"/>
<constraint firstItem="Ddn-dN-xH1" firstAttribute="top" secondItem="1kR-zd-duR" secondAttribute="top" constant="20" id="Q1i-MS-acw"/>
<constraint firstAttribute="bottom" secondItem="Ddn-dN-xH1" secondAttribute="bottom" constant="30" id="VdN-By-srg"/>
<constraint firstAttribute="trailing" secondItem="Ddn-dN-xH1" secondAttribute="trailing" id="W06-Yi-lzm"/>
<constraint firstItem="mga-ND-qoh" firstAttribute="leading" secondItem="1kR-zd-duR" secondAttribute="leading" constant="24" id="sEy-GV-Pjr"/>
</constraints>
</view>
</subviews>
......@@ -68,7 +59,6 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="collectionView" destination="Ddn-dN-xH1" id="RzU-o5-6Dw"/>
<outlet property="titleLabel" destination="mga-ND-qoh" id="TxL-cQ-O1P"/>
</connections>
<point key="canvasLocation" x="68.702290076335871" y="29.929577464788736"/>
</tableViewCell>
......
......@@ -11,31 +11,47 @@ import UIKit
public class ProfileFilterCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var parentView: UIView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var couponsCountView: UIView!
@IBOutlet weak var couponsCountLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
self.couponsCountView.widthAnchor.constraint(greaterThanOrEqualToConstant: 18).isActive = true
self.couponsCountView.layer.borderWidth = 1.0
self.couponsCountView.layer.cornerRadius = 9
self.couponsCountLabel.text = "0"
self.couponsCountLabel.font = UIFont(name: "PingLCG-Regular", size: 12)
self.couponsCountLabel.textAlignment = .center
}
func configureCell(data: CouponFilterModel, isSelected: Bool) {
if (isSelected) {
parentView.backgroundColor = UIColor(rgb: 0x000F1E)
parentView.layer.cornerRadius = 4.0
parentView.layer.borderWidth = 0
parentView.backgroundColor = UIColor(rgb: 0x002430)
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 16)
titleLabel.font = UIFont(name: "PingLCG-Regular", size: 14)
titleLabel.textColor = UIColor(rgb: 0xFFFFFF)
self.couponsCountView.layer.borderColor = UIColor(rgb: 0xFFFFFF).cgColor
self.couponsCountLabel.textColor = UIColor(rgb: 0xFFFFFF)
} else {
parentView.backgroundColor = .clear
parentView.layer.borderWidth = 2
parentView.layer.borderColor = UIColor(rgb: 0x56586A).cgColor
parentView.layer.cornerRadius = 4.0
parentView.backgroundColor = UIColor(rgb: 0xF1F2F4)
titleLabel.font = UIFont(name: "PingLCG-Bold", size: 16)
titleLabel.textColor = UIColor(rgb: 0x00111B)
titleLabel.font = UIFont(name: "PingLCG-Regular", size: 14)
titleLabel.textColor = UIColor(rgb: 0x1D2023)
self.couponsCountView.layer.borderColor = UIColor(rgb: 0x1D2023).cgColor
self.couponsCountLabel.textColor = UIColor(rgb: 0x1D2023)
}
parentView.layer.cornerRadius = parentView.bounds.height / 2
parentView.clipsToBounds = true
titleLabel.text = data.title
self.couponsCountLabel.text = String(data.count)
self.couponsCountLabel.frame.size.width = self.couponsCountLabel.intrinsicContentSize.width
self.couponsCountLabel.frame.size.height = self.couponsCountLabel.intrinsicContentSize.height
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
......@@ -20,19 +20,39 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NgU-Qp-M8l" userLabel="ParentView">
<rect key="frame" x="0.0" y="0.0" width="145" height="43"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xq0-AN-QT6">
<rect key="frame" x="17" y="11.333333333333334" width="111" height="20.333333333333329"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xq0-AN-QT6">
<rect key="frame" x="17" y="11.333333333333334" width="41.333333333333343" height="20.333333333333329"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lpG-Ug-Up3" userLabel="CouponsCountView">
<rect key="frame" x="29" y="12.666666666666664" width="96" height="18"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XeO-tG-bFk" userLabel="CouponsCountLabel">
<rect key="frame" x="5" y="-1.6666666666666661" width="86" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="XeO-tG-bFk" firstAttribute="leading" secondItem="lpG-Ug-Up3" secondAttribute="leading" constant="5" id="R5p-Hi-6u5"/>
<constraint firstItem="XeO-tG-bFk" firstAttribute="centerY" secondItem="lpG-Ug-Up3" secondAttribute="centerY" id="fWU-dR-twV"/>
<constraint firstAttribute="trailing" secondItem="XeO-tG-bFk" secondAttribute="trailing" constant="5" id="tje-zA-iZF"/>
<constraint firstAttribute="height" constant="18" id="vHB-SL-xqZ"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="lpG-Ug-Up3" secondAttribute="trailing" constant="17" id="6zS-oa-YiB"/>
<constraint firstAttribute="height" constant="43" id="KOh-gz-4af"/>
<constraint firstItem="Xq0-AN-QT6" firstAttribute="centerY" secondItem="NgU-Qp-M8l" secondAttribute="centerY" id="aI4-7F-CI7"/>
<constraint firstAttribute="trailing" secondItem="Xq0-AN-QT6" secondAttribute="trailing" constant="17" id="hKh-jv-VQR"/>
<constraint firstItem="lpG-Ug-Up3" firstAttribute="leading" secondItem="Xq0-AN-QT6" secondAttribute="trailing" constant="10" id="hKh-jv-VQR"/>
<constraint firstItem="Xq0-AN-QT6" firstAttribute="leading" secondItem="NgU-Qp-M8l" secondAttribute="leading" constant="17" id="na6-tV-KQZ"/>
<constraint firstItem="lpG-Ug-Up3" firstAttribute="centerY" secondItem="NgU-Qp-M8l" secondAttribute="centerY" id="plg-Ar-0Oy"/>
</constraints>
</view>
</subviews>
......@@ -47,6 +67,8 @@
</constraints>
<size key="customSize" width="145" height="43"/>
<connections>
<outlet property="couponsCountLabel" destination="XeO-tG-bFk" id="6dD-pl-b5f"/>
<outlet property="couponsCountView" destination="lpG-Ug-Up3" id="kgW-3I-uEK"/>
<outlet property="parentView" destination="NgU-Qp-M8l" id="qhP-z2-cWY"/>
<outlet property="titleLabel" destination="Xq0-AN-QT6" id="Hft-IP-ITh"/>
</connections>
......
......@@ -9,5 +9,7 @@
import Foundation
struct CouponFilterModel {
let id: String
let title: String
let count: Int
}
......
......@@ -30,18 +30,20 @@ import UIKit
private var isLoading: Bool = true
private var loadingIndicator: UIActivityIndicatorView?
let couponFilters: [CouponFilterModel] = [
CouponFilterModel(title: "Ενεργά"),
CouponFilterModel(title: "Αγαπημένα"),
CouponFilterModel(title: "Εξαργυρωμένα")
var couponFilters: [CouponFilterModel] = [
CouponFilterModel(id: "active", title: "Valid", count: 0),
CouponFilterModel(id: "expired", title: "Expired", count: 0),
// CouponFilterModel(title: "Favorites"),
// CouponFilterModel(title: "Redeemed")
]
var couponFilterSelected: CouponFilterModel = CouponFilterModel(title: "Ενεργά")
var couponFilterSelected: CouponFilterModel = CouponFilterModel(id: "active", title: "Valid", count: 0)
var forYouOffersSection: SectionModel?
var activeOffersSection: SectionModel?
var favoriteOffersSection: SectionModel?
var redeemedOffersSection: SectionModel?
var expiredOffersSection: SectionModel?
var filteredOffersSection: SectionModel?
public override func viewDidLoad() {
......@@ -160,19 +162,19 @@ import UIKit
func initializeSections() {
// Προτάσεις για εσένα — empty for now
let forYouOffers: [CouponItemModel] = []
forYouOffersSection = SectionModel(
sectionType: .myRewardsHorizontalCouponsets,
title: "Προτάσεις για εσένα",
items: forYouOffers,
itemType: .coupons
)
// let forYouOffers: [CouponItemModel] = []
// forYouOffersSection = SectionModel(
// sectionType: .myRewardsHorizontalCouponsets,
// title: "Προτάσεις για εσένα",
// items: forYouOffers,
// itemType: .coupons
// )
// Active Coupons — status == 1
let activeCoupons = allCoupons.filter { $0.status == 1 }
activeOffersSection = SectionModel(
sectionType: .profileCoupon,
title: "Ενεργά",
title: "Valid",
items: activeCoupons,
itemType: .coupons
)
......@@ -198,6 +200,26 @@ import UIKit
itemType: .coupons
)
// expiredOffersSection Coupons — status == 0
let expiredCoupons = allCoupons.filter { $0.status == -1 }
expiredOffersSection = SectionModel(
sectionType: .profileCoupon,
title: "Expired",
items: expiredCoupons,
itemType: .coupons
)
// Update filter counts dynamically based on fetched coupons
couponFilters = [
CouponFilterModel(id: "active", title: "Valid", count: activeCoupons.count),
CouponFilterModel(id: "expired", title: "Expired", count: expiredCoupons.count)
]
// Sync couponFilterSelected with updated count
if let updatedSelected = couponFilters.first(where: { $0.id == couponFilterSelected.id }) {
couponFilterSelected = updatedSelected
}
self.tableView.reloadData()
}
......@@ -209,13 +231,25 @@ import UIKit
}
private func handleFilterPress(with filter: CouponFilterModel) {
switch (filter.title) {
case "Ενεργά":
// switch (filter.title) {
// case "Ενεργά":
// self.filteredOffersSection = activeOffersSection
// case "Αγαπημένα":
// self.filteredOffersSection = favoriteOffersSection
// case "Εξαργυρωμένα":
// self.filteredOffersSection = redeemedOffersSection
// default:
// self.filteredOffersSection = activeOffersSection
// }
switch (filter.id) {
case "active":
self.filteredOffersSection = activeOffersSection
case "Αγαπημένα":
self.filteredOffersSection = favoriteOffersSection
case "Εξαργυρωμένα":
self.filteredOffersSection = redeemedOffersSection
case "expired":
self.filteredOffersSection = expiredOffersSection
// case "favorite":
// self.filteredOffersSection = favoriteOffersSection
// case "redeemed":
// self.filteredOffersSection = redeemedOffersSection
default:
self.filteredOffersSection = activeOffersSection
}
......@@ -224,13 +258,25 @@ import UIKit
// MARK: - Empty State Helper
private func getEmptyStateMessage() -> String {
switch couponFilterSelected.title {
case "Ενεργά":
// switch couponFilterSelected.title {
// case "Ενεργά":
// return "Δεν υπάρχουν διαθέσιμα ενεργά κουπόνια"
// case "Αγαπημένα":
// return "Δεν υπάρχουν διαθέσιμα αγαπημένα κουπόνια"
// case "Εξαργυρωμένα":
// return "Δεν υπάρχουν διαθέσιμα εξαργυρωμένα κουπόνια"
// default:
// return "Δεν υπάρχουν διαθέσιμα κουπόνια"
// }
switch couponFilterSelected.id {
case "active":
return "Δεν υπάρχουν διαθέσιμα ενεργά κουπόνια"
case "Αγαπημένα":
case "favorite":
return "Δεν υπάρχουν διαθέσιμα αγαπημένα κουπόνια"
case "Εξαργυρωμένα":
case "redeemed":
return "Δεν υπάρχουν διαθέσιμα εξαργυρωμένα κουπόνια"
case "expired":
return "Δεν υπάρχουν διαθέσιμα ληγμένα κουπόνια"
default:
return "Δεν υπάρχουν διαθέσιμα κουπόνια"
}
......
......@@ -28,12 +28,12 @@
<color key="separatorColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="sectionIndexBackgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="dataSource" destination="-1" id="yKP-hs-r89"/>
<outlet property="delegate" destination="-1" id="hPq-MZ-iBl"/>
<outlet property="dataSource" destination="-1" id="bkg-UZ-tNq"/>
<outlet property="delegate" destination="-1" id="3bZ-Xs-qXL"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="5Lc-C5-PjX" firstAttribute="leading" secondItem="3MR-Lq-Ca1" secondAttribute="leading" id="E1N-Fh-MGi"/>
<constraint firstItem="5Lc-C5-PjX" firstAttribute="top" secondItem="3MR-Lq-Ca1" secondAttribute="top" id="oMH-QW-fBP"/>
......