CNLiveHomeFollowCell.swift 3.49 KB
//
//  CNLiveHomeFollowCell.swift
//  metaCode
//
//  Created by zx on 2025/2/21.
//

import Foundation

class CNLiveHomeFollowCell:UITableViewCell{
    
    //CNLiveHomeFollowModel
    var _followModel : CNLiveHomeFollowModel?
    var followModel : CNLiveHomeFollowModel? {
        get{
            _followModel
        }
        set{
            _followModel = newValue!
            self.setupNewUI(model: followModel!)
        }
    }
    
    //MARK: - 懒加载
    lazy var followImgView :UIImageView = {
        let iconImgView = UIImageView(frame: CGRect(x: 15, y: 0, width: KSreenWidth-30, height: 50))
        iconImgView.backgroundColor = HexColor("#FAFAFA")
        iconImgView.layer.cornerRadius = 25
        iconImgView.clipsToBounds = true
        iconImgView.contentMode = .scaleAspectFill
        iconImgView.isUserInteractionEnabled = true
        iconImgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(followImgViewAction)))
        iconImgView.addSubview(followIconImgView)
        iconImgView.addSubview(titleLabel)
        iconImgView.addSubview(titleLabel1)
        iconImgView.addSubview(subTitleLabel1)
        return iconImgView
    }()
    lazy var followIconImgView :UIImageView = {
        let iconImgView = UIImageView(frame: CGRect(x: 20, y: (50-30.0)*0.5, width: 30, height: 30))
        iconImgView.image = UIImage(named: "home_followIcon")
        iconImgView.contentMode = .scaleAspectFill
        return iconImgView
    }()
    lazy var titleLabel: UILabel = {
        let titleLbl = UILabel(frame: CGRect(x: followIconImgView.right+3, y: 12.5, width: 44, height: 20))
        titleLbl.centerY = followIconImgView.centerY
        titleLbl.font = Font_14
        titleLbl.textColor = HexColor("#4A4A4A")
        titleLbl.text = "正在追"
        return titleLbl
    }()
    lazy var titleLabel1: UILabel = {
        let titleLbl = UILabel(frame: CGRect(x: titleLabel.right+20, y: 5, width: KSreenWidth-titleLabel.right-20-20, height: 20))
        titleLbl.font = BoldFont_14
        titleLbl.textColor = HexColor("#4A4A4A")
        return titleLbl
    }()
    lazy var subTitleLabel1: UILabel = {
        let titleLbl = UILabel(frame: CGRect(x: titleLabel1.left, y: titleLabel1.bottom+5, width: titleLabel1.width, height: 14))
        titleLbl.font = Font_10
        titleLbl.textColor = HexColor("#999999")
        return titleLbl
    }()

    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
        
    private func setupUI() {
        contentView.backgroundColor = .clear
        self.backgroundColor = .clear
        self.contentView.addSubview(self.followImgView)
        
        self.contentView.clipsToBounds = true
    }
    
    func setupNewUI(model:CNLiveHomeFollowModel){
        titleLabel1.text = model.title
        subTitleLabel1.text = model.description
    }
    
    @objc func followImgViewAction(){
        
        CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: self.followModel?.modelId ?? "", contentId: self.followModel?.contentId ?? "", pid: self.followModel?.activeId ?? "", shareUrl: self.followModel?.shareUrl ?? "", thirdUrl: "", title: self.followModel?.title ?? "", s_to: "", trailerId: "", controller: navigationViewController().visibleViewController, slideModel: nil)

    }
    
}