106 lines
3.2 KiB
Swift
106 lines
3.2 KiB
Swift
//
|
|
// SPHomeShortCell.swift
|
|
// MoviaBox
|
|
//
|
|
// Created by Overseas on 2025/4/22.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SPHomeShortCell: SPCollectionViewCell {
|
|
|
|
var model: SPShortModel? {
|
|
didSet {
|
|
coverImageView.sp_setImage(url: model?.image_url)
|
|
titleLabel.text = model?.name
|
|
|
|
if model?.tag_type == .hot {
|
|
markView.isHidden = false
|
|
markView.colors = [UIColor.color3E23DE(alpha: 0.17).cgColor, UIColor.color4629F1(alpha: 0.74).cgColor, UIColor.color3D1DFF().cgColor]
|
|
markLabel.text = "HOT"
|
|
} else if model?.tag_type == .new {
|
|
markView.isHidden = false
|
|
markView.colors = [UIColor.colorDE2326(alpha: 0.17).cgColor, UIColor.colorF1298A(alpha: 0.74).cgColor, UIColor.colorFF1DE8().cgColor]
|
|
markLabel.text = "NEW"
|
|
} else {
|
|
markView.isHidden = true
|
|
}
|
|
}
|
|
}
|
|
|
|
private lazy var coverImageView: SPImageView = {
|
|
let imageView = SPImageView()
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var markView: SPGradientView = {
|
|
let view = SPGradientView()
|
|
view.locations = [0, 0.3, 1]
|
|
view.startPoint = .init(x: 0, y: 0.7)
|
|
view.endPoint = .init(x: 1, y: 0.5)
|
|
view.addRadius(topLeft: 0, topRight: 4, bottomLeft: 12, bottomRight: 0)
|
|
return view
|
|
}()
|
|
|
|
private lazy var markLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontBold(ofSize: 12)
|
|
label.textColor = .colorFFFFFF()
|
|
return label
|
|
}()
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontMedium(ofSize: 12)
|
|
label.textColor = .colorFFFFFF()
|
|
label.numberOfLines = 2
|
|
return label
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
contentView.layer.cornerRadius = 8
|
|
contentView.layer.masksToBounds = true
|
|
contentView.backgroundColor = .colorD9D9D9(alpha: 0.14)
|
|
|
|
_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension SPHomeShortCell {
|
|
private func _setupUI() {
|
|
contentView.addSubview(coverImageView)
|
|
coverImageView.addSubview(markView)
|
|
markView.addSubview(markLabel)
|
|
contentView.addSubview(titleLabel)
|
|
|
|
coverImageView.snp.makeConstraints { make in
|
|
make.left.right.top.equalToSuperview()
|
|
make.bottom.equalToSuperview().offset(-44)
|
|
}
|
|
|
|
markView.snp.makeConstraints { make in
|
|
make.top.equalToSuperview().offset(6)
|
|
make.right.equalToSuperview().offset(-6)
|
|
make.width.equalTo(46)
|
|
make.height.equalTo(18)
|
|
}
|
|
|
|
markLabel.snp.makeConstraints { make in
|
|
make.center.equalToSuperview()
|
|
}
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(8)
|
|
make.right.lessThanOrEqualToSuperview().offset(-8)
|
|
make.top.equalTo(coverImageView.snp.bottom).offset(5)
|
|
}
|
|
|
|
}
|
|
}
|