87 lines
2.5 KiB
Swift
87 lines
2.5 KiB
Swift
//
|
|
// SPMinePlayHistoryCell.swift
|
|
// Thimra
|
|
//
|
|
// Created by Overseas on 2025/4/23.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SPMinePlayHistoryCell: SPCollectionViewCell {
|
|
|
|
var model: SPShortModel? {
|
|
didSet {
|
|
coverImageView.sp_setImage(url: model?.image_url)
|
|
titleLabel.text = model?.name
|
|
|
|
let episode_total = "\(model?.episode_total ?? 0)"
|
|
let episode = String(format: "EP.%@/%@", "\(model?.current_episode ?? "0")", episode_total)
|
|
|
|
let episodeString = NSMutableAttributedString(string: episode)
|
|
episodeString.color = .colorE6334B()
|
|
|
|
let range = NSRange(location: episode.length() - episode_total.length(), length: episode_total.length())
|
|
episodeString.setColor(.colorAFAFAF(), range: range)
|
|
episodeLabel.attributedText = episodeString
|
|
}
|
|
}
|
|
|
|
//MARK: UI属性
|
|
private lazy var coverImageView: SPImageView = {
|
|
let imageView = SPImageView()
|
|
imageView.layer.cornerRadius = 4
|
|
imageView.layer.masksToBounds = true
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontMedium(ofSize: 12)
|
|
label.textColor = .colorAFAFAF()
|
|
label.numberOfLines = 2
|
|
return label
|
|
}()
|
|
|
|
private lazy var episodeLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontMedium(ofSize: 12)
|
|
return label
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|
|
|
|
extension SPMinePlayHistoryCell {
|
|
|
|
private func _setupUI() {
|
|
contentView.addSubview(coverImageView)
|
|
contentView.addSubview(titleLabel)
|
|
contentView.addSubview(episodeLabel)
|
|
|
|
coverImageView.snp.makeConstraints { make in
|
|
make.left.right.top.equalToSuperview()
|
|
make.bottom.equalToSuperview().offset(-58)
|
|
}
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview()
|
|
make.right.lessThanOrEqualToSuperview()
|
|
make.top.equalTo(coverImageView.snp.bottom).offset(12)
|
|
}
|
|
|
|
episodeLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview()
|
|
make.top.equalTo(titleLabel.snp.bottom).offset(4)
|
|
}
|
|
}
|
|
|
|
}
|