//
//  MPPositive_HomeListFifthCollectionViewCell.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/4/22.
//

import UIKit
///b面首页展示列表五（视频）
class MPPositive_HomeListFifthCollectionViewCell: UICollectionViewCell {
    //视频封面
    private lazy var coverImageView:UIImageView = {
        let imageView:UIImageView = .init()
        imageView.contentMode = .scaleAspectFill
        imageView.layer.masksToBounds = true
        imageView.layer.cornerRadius = 16*width
        return imageView
    }()
    //播放按钮
    private lazy var playBtn:UIButton = {
        let btn:UIButton = .init()
        btn.setBackgroundImage(UIImage(named: "B_Home_Video'logo"), for: .normal)
        btn.isUserInteractionEnabled = false
        return btn
    }()
    //标题Label
    private lazy var titleLabel:UILabel = createLabel("Title", font: .systemFont(ofSize: 14*width, weight: .regular), textColor: .white, textAlignment: .left)
    //副标题
    private lazy var subtitleLabel:UILabel = createLabel("Title", font: .systemFont(ofSize: 12*width, weight: .regular), textColor: .init(hex: "#666666"), textAlignment: .left)
    var itemViewModel:MPPositive_BrowseItemViewModel!{
        didSet{
            itemViewModel.setUrltoImage(coverImageView)
            titleLabel.text = itemViewModel.title
            subtitleLabel.text = itemViewModel.subtitle
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        confirgue()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    //配置
    private func confirgue() {
        backgroundColor = .clear
        layer.masksToBounds = true
        addSubview(coverImageView)
        coverImageView.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(187*width)
        }
        addSubview(playBtn)
        playBtn.snp.makeConstraints { make in
            make.width.height.equalTo(34*width)
            make.left.equalToSuperview().offset(8*width)
            make.bottom.equalToSuperview().offset(-58*width)
        }
        addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(-20*width)
        }
        addSubview(subtitleLabel)
        subtitleLabel.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
        }
    }
}
