ProfileCouponTableViewCell.swift 2.72 KB
//
//  ProfileCouponTableViewCell.swift
//  SwiftWarplyFramework
//
//  Created by Manos Chorianopoulos on 29/5/25.
//

import UIKit

@objc public class ProfileCouponTableViewCell: UITableViewCell {
    @IBOutlet weak var parentView: UIView!
    @IBOutlet weak var bannerImage: UIImageView!
    @IBOutlet weak var favoriteImage: UIImageView!
    @IBOutlet weak var discountView: UIView!
    @IBOutlet weak var discountLabel: UILabel!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var subtitleLabel: UILabel!
    @IBOutlet weak var expirationLabel: UILabel!
    @IBOutlet weak var logoImage: UIImageView!
    
    public override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        parentView.layer.borderWidth = 1.0
        parentView.layer.borderColor = UIColor(rgb: 0xCCCCCC).cgColor
        parentView.layer.cornerRadius = 8.0
        parentView.clipsToBounds = true
        
        discountView.layer.cornerRadius = 34.0
        
    }
    
    func configureCell(data: OfferModel) {
        bannerImage.image = UIImage(named: data.bannerImage, in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
        favoriteImage.image = UIImage(named: data.isFavorite ? "favorite_filled" : "favorite_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
        
        let discountSymbol =
            data.discountType == "percentage" ? "%"
            : data.discountType == "price" ? "€"
            : data.discountType == "buyOneGetOne" ? "1+1"
            : data.discountType == "free" ? "Δωρεάν"
            : ""
        
//        discountLabel.text = "\(data.discount)\(discountSymbol)"
        discountLabel.text = data.discount
        discountLabel.font = UIFont(name: "PingLCG-Bold", size: 25)
        discountLabel.textColor = UIColor(rgb: 0xF2F2F2)
        
        discountView.backgroundColor = UIColor(rgb: data.color)
        
        titleLabel.text = data.title
        titleLabel.font = UIFont(name: "PingLCG-Bold", size: 22)
        titleLabel.textColor = UIColor(rgb: 0x000F1E)
        
        subtitleLabel.text = data.description
        subtitleLabel.font = UIFont(name: "PingLCG-Regular", size: 16)
        subtitleLabel.textColor = UIColor(rgb: 0x00111B)
        
        expirationLabel.text = data.expirationDate
        expirationLabel.font = UIFont(name: "PingLCG-Regular", size: 13)
        expirationLabel.textColor = UIColor(rgb: 0x00111B)
        
        logoImage.image = UIImage(named: data.merchantLogo, in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
    }

    public override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}