// // MPPositive_AddSongTableViewCell.swift // relax.offline.mp3.music // // Created by Mr.Zhou on 2024/9/24. // import UIKit import Kingfisher class MPPositive_AddSongTableViewCell: UITableViewCell { //特殊图片(展示预览图片) private lazy var iconImageView:UIImageView = { let imageView:UIImageView = .init() imageView.contentMode = .scaleAspectFill imageView.layer.masksToBounds = true imageView.layer.cornerRadius = 8*width return imageView }() private lazy var titleLabel:UILabel = createLabel(font: .systemFont(ofSize: 16*width, weight: .regular), textColor: .white, textAlignment: .left) private lazy var subtitleLabel:UILabel = createLabel(font: .systemFont(ofSize: 12*width, weight: .regular), textColor: .init(hex: "#999999"), textAlignment: .left) //是否添加按钮 lazy var statuImageView:UIImageView = { let imageView:UIImageView = .init() imageView.contentMode = .scaleAspectFill return imageView }() var list:MPPositive_CustomPlayListModel? var love:MPPositive_CollectionSongViewModel!{ didSet{ love.setImage(iconImageView) titleLabel.text = love.title subtitleLabel.text = love.subtitle //检索list中是否存在 if let array = list?.videosArray.filter({$0.videoId == love.collectionSong.videoId}), array.isEmpty == true { statuImageView.image = UIImage(named: "UnAdd_PlayLists'logo") }else { statuImageView.image = UIImage(named: "Added_PlayList'logo") } } } var offline:MPPositive_DownloadViewModel!{ didSet{ offline.setImage(iconImageView) titleLabel.text = offline.title subtitleLabel.text = offline.subtitle //检索list中是否存在 if let array = list?.videosArray.filter({$0.videoId == offline.loadItem.videoId}), array.isEmpty == true { statuImageView.image = UIImage(named: "UnAdd_PlayLists'logo") }else { statuImageView.image = UIImage(named: "Added_PlayList'logo") } } } override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) selectionStyle = .none backgroundColor = .clear configure() } required init?(coder: NSCoder) { super.init(coder: coder) } override func awakeFromNib() { super.awakeFromNib() // Initialization code } override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state } private func configure() { contentView.addSubview(iconImageView) iconImageView.snp.makeConstraints { make in make.width.height.equalTo(60*width) make.top.equalToSuperview().offset(12*width).priority(999) make.bottom.equalToSuperview().offset(-12*width) make.left.equalToSuperview().offset(16*width) } contentView.addSubview(titleLabel) titleLabel.snp.makeConstraints { make in make.top.equalTo(iconImageView.snp.top).offset(8*width) make.left.equalTo(iconImageView.snp.right).offset(14*width) make.right.equalToSuperview().offset(-40*width) } contentView.addSubview(subtitleLabel) subtitleLabel.snp.makeConstraints { make in make.bottom.equalTo(iconImageView.snp.bottom).offset(-8*width) make.left.equalTo(titleLabel.snp.left) make.right.equalTo(titleLabel.snp.right) } contentView.addSubview(statuImageView) statuImageView.snp.makeConstraints { make in make.size.equalTo(CGSize(width: 24*width, height: 24*width)) make.centerY.equalToSuperview() make.right.equalTo(-18*width) } } }