//
//  Home_FourthListCollectionViewCell.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/3/27.
//

import UIKit
///首页音乐第四行展示列表Cell
class MPSideA_Home_FourthListCollectionViewCell: UICollectionViewCell {
    @IBOutlet weak var coverImageView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var subtitleLabel: UILabel!
    @IBOutlet weak var shieldView: UIView!
    @IBOutlet weak var stateBtn: UIButton!
    var musicView:MPSideA_MusicViewModel!{
        didSet{
            coverImageView.image = musicView.cover
            titleLabel.text = musicView.title
            subtitleLabel.text = musicView.duration
            //判断当前音乐是否播放中,是不是这首音乐
            guard MPSideA_MediaCenterManager.shared.getPlayerState() == .Playing, MPSideA_MediaCenterManager.shared.getMusic()?.identifier == musicView.music.identifier else {
                //展示未播放状态
                titleLabel.textColor = .init(hex: "#FFFFFF")
                subtitleLabel.textColor = .init(hex: "#FFFFFF")
                stateBtn.isSelected = false
                shieldView.isHidden = true
                return
            }
            //展示播放状态
            titleLabel.textColor = .init(hex: "#80F988")
            subtitleLabel.textColor = .init(hex: "#80F988")
            stateBtn.isSelected = true
            shieldView.isHidden = false
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
}
