//
//  MPPositive_SearchGrideCollectionViewCell.swift
//  relax.offline.mp3.music
//
//  Created by Mr.Zhou on 2024/7/12.
//

import UIKit
import MarqueeLabel
class MPPositive_SearchGrideCollectionViewCell: UICollectionViewCell {
    //颜色块
    private lazy var colorView:UIView = .init()
    //标题Label
    private lazy var titleLabel:UILabel = createMarQueeLabel("Loading", font: .systemFont(ofSize: 16, weight: .bold), textColor: .white)
    var gride:MPPositive_GridViewModel!{
        didSet{
            colorView.backgroundColor = .randomColor
            titleLabel.text = gride.title
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = .init(hex: "#1F1F1F")
        layer.masksToBounds = true
        layer.cornerRadius = 10*width
        confirgue()
    }
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    //配置
    private func confirgue() {
        addSubview(colorView)
        colorView.snp.makeConstraints { make in
            make.top.left.bottom.equalToSuperview()
            make.width.equalToSuperview().multipliedBy(0.2)
        }
        addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(colorView.snp.right).offset(12*width)
            make.right.equalToSuperview().offset(-12*width)
        }
    }
}
