117 lines
3.3 KiB
Swift
117 lines
3.3 KiB
Swift
//
|
|
// VPVipBuyCell.swift
|
|
// Veloria
|
|
//
|
|
// Created by 湖南秦九 on 2025/5/29.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class VPVipBuyCell: VPCollectionViewCell {
|
|
|
|
|
|
var item: VPPayTemplateItem? {
|
|
didSet {
|
|
if let key = item?.vip_type_key?.rawValue {
|
|
bgImageView.image = UIImage(named: "vip_buy_bg_\(key)")
|
|
}
|
|
vipNameLabel.text = item?.vip_type_key?.getText()
|
|
unitLabel.text = item?.currency
|
|
moneyLabel.text = item?.price
|
|
|
|
var colors: [CGColor] = []
|
|
|
|
switch item?.vip_type_key {
|
|
case .week:
|
|
colors = [UIColor.color64A3A7().cgColor, UIColor.color416767().cgColor]
|
|
case .month:
|
|
colors = [UIColor.color9C7565().cgColor, UIColor.color573D31().cgColor]
|
|
case .quarter:
|
|
colors = [UIColor.color647DA7().cgColor, UIColor.color414867().cgColor]
|
|
case .year:
|
|
colors = [UIColor.color9C6586().cgColor, UIColor.color57314F().cgColor]
|
|
default:
|
|
break
|
|
}
|
|
|
|
|
|
vipNameLabel.gradientLayer.colors = colors
|
|
unitLabel.gradientLayer.colors = colors
|
|
moneyLabel.gradientLayer.colors = colors
|
|
durationLabel.gradientLayer.colors = colors
|
|
}
|
|
}
|
|
|
|
private lazy var bgImageView: UIImageView = {
|
|
let imageView = UIImageView()
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var vipNameLabel: VPGradientLabel = {
|
|
let label = VPGradientLabel()
|
|
label.font = .fontBold(ofSize: 16)
|
|
return label
|
|
}()
|
|
|
|
private lazy var unitLabel: VPGradientLabel = {
|
|
let label = VPGradientLabel()
|
|
label.font = .fontRegular(ofSize: 14)
|
|
return label
|
|
}()
|
|
|
|
private lazy var moneyLabel: VPGradientLabel = {
|
|
let label = VPGradientLabel()
|
|
label.font = .fontAaHouDiHei(ofSize: 22)
|
|
return label
|
|
}()
|
|
|
|
private lazy var durationLabel: VPGradientLabel = {
|
|
let label = VPGradientLabel()
|
|
label.font = .fontRegular(ofSize: 14)
|
|
return label
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
vp_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|
|
|
|
extension VPVipBuyCell {
|
|
|
|
private func vp_setupUI() {
|
|
contentView.addSubview(bgImageView)
|
|
contentView.addSubview(vipNameLabel)
|
|
contentView.addSubview(unitLabel)
|
|
contentView.addSubview(moneyLabel)
|
|
|
|
bgImageView.snp.makeConstraints { make in
|
|
make.edges.equalToSuperview()
|
|
}
|
|
|
|
vipNameLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(14)
|
|
make.top.equalToSuperview().offset(31)
|
|
make.height.equalTo(22)
|
|
}
|
|
|
|
unitLabel.snp.makeConstraints { make in
|
|
make.left.equalTo(vipNameLabel)
|
|
make.top.equalTo(vipNameLabel.snp.bottom).offset(20)
|
|
make.height.equalTo(20)
|
|
}
|
|
|
|
moneyLabel.snp.makeConstraints { make in
|
|
make.left.equalTo(unitLabel.snp.right)
|
|
make.bottom.equalTo(unitLabel).offset(-1)
|
|
}
|
|
|
|
}
|
|
|
|
}
|