//
//  SpeakElePCCollectionViewCell.swift
//  SpeakEasyLearnEnglish
//
//  Created by mac on 2025/7/16.
//

import UIKit

class SpeakElePCCollectionViewCell: UICollectionViewCell {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    @available(*, unavailable)
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var backView: UIView = {
       let bView = UIView()
        bView.backgroundColor = UIColor.init(with: "#000000", alpha: 0.08)
        bView.isUserInteractionEnabled = true
        self.contentView.addSubview(bView)
       return bView
   }()
    
    private lazy var iconImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.translatesAutoresizingMaskIntoConstraints = false
        imageView.backgroundColor = UIColor.clear
        imageView.contentMode = .scaleAspectFit
     //   imageView.isUserInteractionEnabled = false
        self.contentView.addSubview(imageView)
        return imageView
    }()
    
    private lazy var titleLabel:UILabel = {
        let label = UILabel()
        label.textColor = .white
        label.font = UIFont(name: "Microsoft YaHei", size:10)
        self.contentView.addSubview(label)
        return label
    }()
}

extension SpeakElePCCollectionViewCell {
    func setupUI() {
        
        backView.snp.remakeConstraints { (make) in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.top.equalTo(0)
            make.bottom.equalTo(0)
        }
        backView.corners = 8
        
        iconImageView.snp.remakeConstraints { (make) in
            make.centerY.equalToSuperview().offset(-10)
            make.centerX.equalToSuperview()
            make.width.height.equalTo(18)
            //            make.height.equalTo(FITSCALE(num: 19))
        }
        
        titleLabel.snp.remakeConstraints { (make) in
            //            make.bottom.equalTo(-20)
            make.top.equalTo(iconImageView.snp.bottom).offset(5)
            make.centerX.equalToSuperview()
            //            make.height.equalTo(FITSCALE(num: 19))
        }
    }
    
     func setImage(_ imgName:String) {

            iconImageView.image = UIImage(named: imgName)
    }
    
    func setTitle(_ title:String) {
        titleLabel.text = title
        
    }
    
}
