//
//  MPPositive_MoreListContentCollectionViewCell.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/4/28.
//

import UIKit
///更多页面 展示列表/专辑的cell
class MPPositive_MoreListContentCollectionViewCell: 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)
    //副标题
    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.left.top.right.equalToSuperview()
            make.height.equalTo(164*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.top.equalTo(coverImageView.snp.bottom).offset(9*width)
            make.left.right.equalToSuperview()
        }
        addSubview(subtitleLabel)
        subtitleLabel.snp.makeConstraints { make in
            make.left.bottom.right.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
    }
}
