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

import UIKit
///b面首页展示列表二
class MPPositive_HomeListSecondCollectionViewCell: UICollectionViewCell {
    //封面
    private lazy var coverImageView:UIImageView = {
        let imageView:UIImageView = .init()
        imageView.contentMode = .scaleAspectFill
        imageView.layer.masksToBounds = true
        imageView.layer.cornerRadius = 16*width
        return imageView
    }()
    //播放状态View
    private lazy var statuView:UIView = setStatuView()
    //标题Label
    private lazy var titleLabel:UILabel = createLabel("Title", font: .systemFont(ofSize: 14*width, weight: .regular), textColor: .white, textAlignment: .left)
    var itemViewModel:MPPositive_BrowseItemViewModel!{
        didSet{
            itemViewModel.setUrltoImage(coverImageView)
            titleLabel.text = itemViewModel.title
        }
    }
    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.left.top.right.equalToSuperview()
            make.height.equalTo(96*width)
        }
        addSubview(statuView)
        statuView.snp.makeConstraints { make in
            make.left.right.bottom.top.equalTo(coverImageView)
        }
        statuView.isHidden = true
        addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
        }
        
    }
    //生成的覆盖黑色半透明View
    private func setStatuView() -> UIView {
        let bgView:UIView = .init()
        bgView.backgroundColor = .init(hex: "#000000", alpha: 0.7)
        bgView.layer.masksToBounds = true
        bgView.layer.cornerRadius = 16*width
        //播放状态图片
        let imageView:UIImageView = .init(image: .init(named: "Home Second'play"))
        bgView.addSubview(imageView)
        imageView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.equalTo(14*width)
            make.height.equalTo(17*width)
        }
        return bgView
    }
}
