WalletQuestionnaireBannerTableViewCell.swift 4.6 KB
//
//  WalletQuestionnaireBannerTableViewCell.swift
//  SwiftWarplyFramework
//
//  Created by Manos Chorianopoulos on 27/2/24.
//

import UIKit

@objc public class WalletQuestionnaireBannerTableViewCell: UITableViewCell {
    @IBOutlet weak var bannerView: UIView!
    @IBOutlet weak var bannerIconImage: UIImageView!
    @IBOutlet weak var bannerIconImageWidth: NSLayoutConstraint!
    @IBOutlet weak var bannerLabel: UILabel!
    @IBOutlet weak var bannerLabelLeftSpace: NSLayoutConstraint!
//    @IBOutlet weak var bannerArrowImage: UIImageView!
    
    @IBOutlet weak var bannerCenteredView: UIView!
    @IBOutlet weak var bannerCenteredIconImage: UIImageView!
    @IBOutlet weak var bannerCenteredIconImageWidth: NSLayoutConstraint!
    @IBOutlet weak var bannerCenteredLabel: UILabel!
    @IBOutlet weak var bannerCenteredLabelLeftSpace: NSLayoutConstraint!
    
    public override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        bannerView.layer.cornerRadius = 12.0
        bannerView.layer.borderWidth = 1
        bannerView.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
//        bannerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
        
        bannerCenteredView.layer.cornerRadius = 12.0
        bannerCenteredView.layer.borderWidth = 1
        bannerCenteredView.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
        
        // Add shadow
//        bannerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
//        bannerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
//        bannerView.layer.shadowOpacity = 1.0
//        bannerView.layer.shadowRadius = 1.0
        
        bannerIconImage.image = UIImage(named: "wallet_plus", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
        bannerCenteredIconImage.image = UIImage(named: "wallet_plus", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
//        bannerArrowImage.image = UIImage(named: "arrow_right_black", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
        
        bannerLabel.font = UIFont(name: "PeridotPE-Bold", size: 12)
        bannerCenteredLabel.font = UIFont(name: "PeridotPE-Bold", size: 12)
    }

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

        // Configure the view for the selected state
    }
    
    func configureCell(isCentered: Bool) {
        let userTag = swiftApi().getUserTag()
//        print("User tag: " + userTag)
        if (userTag != "" && userTag != "undefined") {
            bannerLabel.text = userTag
            bannerLabel.frame.size.width = bannerLabel.intrinsicContentSize.width
            bannerIconImage.isHidden = true
            bannerIconImageWidth.constant = CGFloat(0.0)
            bannerLabelLeftSpace.constant = CGFloat(0.0)
            bannerView.frame.size.width = bannerView.intrinsicContentSize.width
            
            bannerCenteredLabel.text = userTag
            bannerCenteredLabel.frame.size.width = bannerCenteredLabel.intrinsicContentSize.width
            bannerCenteredIconImage.isHidden = true
            bannerCenteredIconImageWidth.constant = CGFloat(0.0)
            bannerCenteredLabelLeftSpace.constant = CGFloat(0.0)
            bannerCenteredView.frame.size.width = bannerLabel.intrinsicContentSize.width
            
            
        } else {
            bannerLabel.text = "Πρόσθεσε τις προτιμήσεις σου"
            bannerLabel.frame.size.width = bannerLabel.intrinsicContentSize.width
            bannerIconImage.isHidden = false
            bannerIconImageWidth.constant = CGFloat(16.0)
            bannerLabelLeftSpace.constant = CGFloat(5.0)
            bannerView.frame.size.width = bannerView.intrinsicContentSize.width
            
            bannerCenteredLabel.text = "Πρόσθεσε τις προτιμήσεις σου"
            bannerCenteredLabel.frame.size.width = bannerCenteredLabel.intrinsicContentSize.width
            bannerCenteredIconImage.isHidden = false
            bannerCenteredIconImageWidth.constant = CGFloat(16.0)
            bannerCenteredLabelLeftSpace.constant = CGFloat(5.0)
            bannerCenteredView.frame.size.width = bannerCenteredView.intrinsicContentSize.width
        }

        if (isCentered) {
            bannerView.isHidden = true
            bannerCenteredView.isHidden = false
            
        } else {
            bannerView.isHidden = false
            bannerCenteredView.isHidden = true
        }
    }
    
}