Music_Player3/relax.offline.mp3.music/MP/MPPositive/Views/Home/MPPositive_MusicItemShowTableViewCell.swift
2024-06-03 09:48:39 +08:00

114 lines
4.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// MPPositive_MusicItemShowTableViewCell.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/4/29.
//
import UIKit
///bCell
class MPPositive_MusicItemShowTableViewCell: UITableViewCell {
///
private lazy var coverImageView:UIImageView = {
let imageView:UIImageView = .init()
imageView.contentMode = .scaleAspectFill
imageView.layer.masksToBounds = true
imageView.layer.cornerRadius = 10*width
return imageView
}()
///
private lazy var titleLabel:UILabel = createLabel(font: .systemFont(ofSize: 14*width, weight: .regular), textColor: .white, textAlignment: .left)
///
private lazy var subtitleLabel:UILabel = createLabel(font: .systemFont(ofSize: 12*width, weight: .regular), textColor: .init(hex: "#FFFFFF", alpha: 0.6), textAlignment: .left)
///
private lazy var moreBtn:UIButton = {
let btn:UIButton = .init()
btn.setBackgroundImage(UIImage(named: "Song_More'logo"), for: .normal)
btn.addTarget(self, action: #selector(moreActionClick(_ :)), for: .touchUpInside)
return btn
}()
///
// private lazy var loadBtn:UIButton = {
// let btn:UIButton = .init()
// btn.setBackgroundImage(UIImage(named: "Song_Unload'logo"), for: .normal)
// btn.setBackgroundImage(UIImage(named: "Song_Loaded'logo"), for: .selected)
// btn.addTarget(self, action: #selector(loadActionClick(_ :)), for: .touchUpInside)
// return btn
// }()
//
var itemView:MPPositive_BrowseItemViewModel!{
didSet{
itemView.setUrltoImage(coverImageView)
titleLabel.text = itemView.title
subtitleLabel.text = itemView.subtitle
}
}
var moreBlock:(() -> Void)?
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
selectionStyle = .none
backgroundColor = .clear
contentView.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(coverImageView)
//cell
coverImageView.snp.makeConstraints { make in
make.width.height.equalTo(60*width)
make.left.equalToSuperview().offset(18*width)
make.top.equalToSuperview().offset(8*width).priority(999)
make.bottom.equalToSuperview().offset(-8*width).priority(999)
}
contentView.addSubview(moreBtn)
moreBtn.snp.makeConstraints { make in
make.width.height.equalTo(24*width)
make.centerY.equalTo(coverImageView.snp.centerY)
make.right.equalToSuperview().offset(-18*width)
}
// contentView.addSubview(loadBtn)
// loadBtn.snp.makeConstraints { make in
// make.width.height.equalTo(24*width)
// make.centerY.equalTo(coverImageView.snp.centerY)
// make.right.equalToSuperview().offset(-54*width)
// }
contentView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalTo(coverImageView.snp.top).offset(10*width)
make.left.equalTo(coverImageView.snp.right).offset(12*width)
make.right.equalTo(moreBtn.snp.left).offset(-12*width)
}
contentView.addSubview(subtitleLabel)
subtitleLabel.snp.makeConstraints { make in
make.bottom.equalTo(coverImageView.snp.bottom).offset(-10*width)
make.left.right.equalTo(titleLabel)
}
}
//
@objc private func moreActionClick(_ sender:UIButton) {
guard moreBlock != nil else {
return
}
moreBlock!()
}
//
@objc private func loadActionClick(_ sender:UIButton) {
}
}