//
//  TSRingToneCellView.swift
//  AIRingtone
//
//  Created by 100Years on 2025/3/3.
//

class TSRingToneCellView: TSBaseView {
    
    
    let coverImageView:UIImageView = UIImageView()
    let playBtn = UIButton.createButton(image: UIImage(named: "ringtone_play"))
    let nameLab = UILabel.createLabel(font: .font(size: 14),textColor: .white)
    let timeLab = UILabel.createLabel(font: .font(size: 12),textColor: .white.withAlphaComponent(0.6))
    
    var isPlay:Bool = false {
        didSet{
            playBtn.setImage(UIImage(named: isPlay ? "ringtone_pause" : "ringtone_play"), for: .normal)
        }
    }
    
    override func creatUI() {
        contentView.backgroundColor = .popupColor
        contentView.cornerRadius = 16
        coverImageView.cornerRadius = 8
        coverImageView.backgroundColor = .black
        
        contentView.addSubview(coverImageView)
        contentView.addSubview(playBtn)
        contentView.addSubview(nameLab)
        contentView.addSubview(timeLab)
        
        
        playBtn.snp.makeConstraints { make in
            make.trailing.equalTo(-20)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(24)
        }
    
        coverImageView.snp.makeConstraints { make in
            make.leading.equalTo(12)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(48)
        }
        
        nameLab.snp.makeConstraints { make in
            make.leading.equalTo(76)
            make.trailing.equalTo(50)
            make.top.equalTo(17)
            make.height.equalTo(14)
        }
        
        timeLab.snp.makeConstraints { make in
            make.leading.equalTo(76)
            make.bottom.equalTo(-17)
            make.height.equalTo(12)
        }
    }

}
