InboxTableViewCell.swift 2.08 KB
//
//  InboxTableViewCell.swift
//  SwiftWarplyFramework
//
//  Created by Manos Chorianopoulos on 24/6/22.
//

import UIKit

@objc public class InboxTableViewCell: UITableViewCell {
    @IBOutlet weak var inboxView: UIView!
    @IBOutlet weak var campaignImage: UIImageView!
    @IBOutlet weak var newBadgeImage: UIImageView!
    @IBOutlet weak var campaignTitleLabel: UILabel!
    
    public override func awakeFromNib() {
        super.awakeFromNib()
        
        inboxView.layer.cornerRadius = 5.0
        inboxView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
        inboxView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
        inboxView.layer.shadowOpacity = 1.0
        inboxView.layer.shadowRadius = 15.0
        inboxView.clipsToBounds = true
        
        newBadgeImage.image = UIImage(named: "new_icon", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
        
        newBadgeImage.isHidden = true
    }

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

        // Configure the view for the selected state
    }
    
    public override func layoutSubviews() {
        super.layoutSubviews()
        //set the values for top,left,bottom,right margins
        let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
        contentView.frame = contentView.frame.inset(by: margins)
    }
    
    
    func configureCell(campaign: swiftApi.CampaignItemModel) {
        campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
        
        campaignTitleLabel.text = campaign.title ?? ""
        
        if (campaign.is_new == true) {
            newBadgeImage.isHidden = false
        } else{
            newBadgeImage.isHidden = true
        }
    }

    func configureCell(ccms: swiftApi.LoyaltyContextualOfferModel) {
        campaignImage.load(link: ccms._imageUrl , placeholder: UIImage(), cache: URLCache())
        
        campaignTitleLabel.text = ccms._title
        
        newBadgeImage.isHidden = true
    }

}