111 lines
3.5 KiB
Swift
111 lines
3.5 KiB
Swift
//
|
|
// BRConsumptionRecordCell.swift
|
|
// BeeReel
|
|
//
|
|
// Created by 长沙鸿瑶 on 2025/7/28.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class BRConsumptionRecordCell: BRCollectionViewCell {
|
|
|
|
var model: BRConsumptionRecordsModel? {
|
|
didSet {
|
|
timeLabel.text = model?.created_at
|
|
let episode = "EP.##".localizedReplace(text: "\(model?.episode ?? "0")") + " \(model?.name ?? "")"
|
|
contentLabel.text = episode
|
|
|
|
coinView.setNeedsUpdateConfiguration()
|
|
}
|
|
}
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontRegular(ofSize: 14)
|
|
label.textColor = .color1C1C1C()
|
|
label.text = "Purchase Single Episode".localized
|
|
return label
|
|
}()
|
|
|
|
private lazy var contentLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontRegular(ofSize: 12)
|
|
label.textColor = .colorC2C2C2()
|
|
label.text = "Ep.8 Romantic Flash Marriage In Progress"
|
|
return label
|
|
}()
|
|
|
|
private lazy var timeLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontRegular(ofSize: 11)
|
|
label.textColor = .colorC2C2C2()
|
|
label.text = "2025-04-17 06:19:13"
|
|
label.setContentHuggingPriority(.required, for: .horizontal)
|
|
label.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
return label
|
|
}()
|
|
|
|
private lazy var coinView: UIButton = {
|
|
var config = UIButton.Configuration.plain()
|
|
config.imagePadding = 2
|
|
config.image = UIImage(named: "Frame 6")
|
|
config.imagePlacement = .trailing
|
|
config.contentInsets = .zero
|
|
|
|
let button = UIButton(configuration: config)
|
|
button.isUserInteractionEnabled = false
|
|
button.configurationUpdateHandler = { [weak self] button in
|
|
guard let self = self else { return }
|
|
|
|
button.configuration?.attributedTitle = AttributedString.br_createAttributedString(string: "-\(model?.coins ?? 0)", color: .color7ECD5E(), font: .fontMedium(ofSize: 15))
|
|
}
|
|
return button
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
self.contentView.backgroundColor = .colorFAFAFA()
|
|
self.contentView.layer.cornerRadius = 10
|
|
self.contentView.layer.masksToBounds = true
|
|
|
|
br_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|
|
|
|
extension BRConsumptionRecordCell {
|
|
|
|
private func br_setupUI() {
|
|
contentView.addSubview(titleLabel)
|
|
contentView.addSubview(contentLabel)
|
|
contentView.addSubview(timeLabel)
|
|
contentView.addSubview(coinView)
|
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(12)
|
|
make.top.equalToSuperview().offset(11)
|
|
}
|
|
|
|
contentLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(12)
|
|
make.bottom.equalToSuperview().offset(-15)
|
|
make.right.equalTo(timeLabel.snp.left).offset(-25)
|
|
}
|
|
|
|
timeLabel.snp.makeConstraints { make in
|
|
make.centerY.equalTo(contentLabel)
|
|
make.right.equalToSuperview().offset(-10)
|
|
}
|
|
|
|
coinView.snp.makeConstraints { make in
|
|
make.centerY.equalTo(titleLabel)
|
|
make.right.equalToSuperview().offset(-11)
|
|
}
|
|
|
|
}
|
|
|
|
}
|