117 lines
3.3 KiB
Swift
117 lines
3.3 KiB
Swift
//
|
|
// SPHomePlayHistoryCell.swift
|
|
// MoviaBox
|
|
//
|
|
// Created by Overseas on 2025/4/22.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SPHomePlayHistoryCell: SPCollectionViewCell {
|
|
|
|
var model: SPShortModel? {
|
|
didSet {
|
|
coverImageView.sp_setImage(url: model?.image_url)
|
|
|
|
titleLabel.text = model?.name
|
|
|
|
// model?.episode_total
|
|
|
|
let episode_total = "\(model?.episode_total ?? 0)"
|
|
let episode = String(format: "movia_text_episcode_ios".localized, "\(model?.current_episode ?? "0")") + "/\(episode_total)"
|
|
|
|
let episodeString = NSMutableAttributedString(string: episode)
|
|
episodeString.color = .colorFF5100()
|
|
|
|
let range = NSRange(location: episode.length() - episode_total.length() - 1, length: episode_total.length() + 1)
|
|
episodeString.setColor(.colorAFAFAF(), range: range)
|
|
episodeLabel.attributedText = episodeString
|
|
|
|
}
|
|
}
|
|
|
|
private lazy var coverImageView: SPImageView = {
|
|
let imageView = SPImageView()
|
|
imageView.layer.cornerRadius = 44
|
|
imageView.layer.masksToBounds = true
|
|
return imageView
|
|
}()
|
|
|
|
///蒙层
|
|
private lazy var maskLayerView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = .color000000(alpha: 0.3)
|
|
return view
|
|
}()
|
|
|
|
private lazy var playImageView: UIImageView = {
|
|
let imageView = UIImageView(image: UIImage(named: "play_icon_04"))
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontWeight(ofSize: 12, weight: 200)
|
|
label.textColor = .colorFFFFFF()
|
|
label.numberOfLines = 2
|
|
return label
|
|
}()
|
|
|
|
private lazy var episodeLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontRegular(ofSize: 10)
|
|
return label
|
|
}()
|
|
|
|
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension SPHomePlayHistoryCell {
|
|
|
|
private func _setupUI() {
|
|
contentView.addSubview(coverImageView)
|
|
coverImageView.addSubview(maskLayerView)
|
|
coverImageView.addSubview(playImageView)
|
|
contentView.addSubview(titleLabel)
|
|
contentView.addSubview(episodeLabel)
|
|
|
|
coverImageView.snp.makeConstraints { make in
|
|
make.top.equalToSuperview()
|
|
make.centerX.equalToSuperview()
|
|
make.width.height.equalTo(88)
|
|
}
|
|
|
|
maskLayerView.snp.makeConstraints { make in
|
|
make.edges.equalToSuperview()
|
|
}
|
|
|
|
playImageView.snp.makeConstraints { make in
|
|
make.center.equalToSuperview()
|
|
}
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview()
|
|
make.top.equalTo(coverImageView.snp.bottom).offset(6)
|
|
make.right.lessThanOrEqualToSuperview()
|
|
}
|
|
|
|
episodeLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview()
|
|
make.bottom.equalToSuperview()
|
|
}
|
|
}
|
|
|
|
}
|