ThimraTV/MoviaBox/Class/Player/View/SPEpisodeCell.swift
2025-04-28 10:57:59 +08:00

84 lines
2.1 KiB
Swift

//
// SPEpisodeCell.swift
// MoviaBox
//
// Created by on 2025/4/16.
//
import UIKit
class SPEpisodeCell: SPCollectionViewCell {
var videoInfoModel: SPVideoInfoModel? {
didSet {
textLabel.text = "\(videoInfoModel?.episode ?? "0")"
lockImageView.isHidden = !(videoInfoModel?.is_lock ?? false)
}
}
var sp_isSelected: Bool = false {
didSet {
if sp_isSelected {
contentView.backgroundColor = .color621C14()
contentView.layer.borderColor = UIColor.colorFF0000().cgColor
} else {
contentView.backgroundColor = .color1C1A1C()
contentView.layer.borderColor = UIColor.color1C1A1C().cgColor
}
}
}
private lazy var textLabel: UILabel = {
let label = UILabel()
label.font = .fontMedium(ofSize: 16)
label.textColor = .colorFFFFFF()
return label
}()
private lazy var lockImageView: UIButton = {
let view = UIButton(type: .custom)
view.isUserInteractionEnabled = false
view.setImage(UIImage(named: "lock_icon_01"), for: .normal)
view.setBackgroundImage(UIImage(named: "lock_bg_01"), for: .normal)
return view
}()
override init(frame: CGRect) {
super.init(frame: frame)
contentView.layer.cornerRadius = 8
contentView.layer.masksToBounds = true
contentView.layer.borderWidth = 2
_setupUI()
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension SPEpisodeCell {
private func _setupUI() {
contentView.addSubview(textLabel)
contentView.addSubview(lockImageView)
textLabel.snp.makeConstraints { make in
make.center.equalToSuperview()
}
lockImageView.snp.makeConstraints { make in
make.right.top.equalToSuperview()
}
}
}