268 lines
9.2 KiB
Swift
268 lines
9.2 KiB
Swift
//
|
|
// SPMemberRechargeCell.swift
|
|
// MoviaBox
|
|
//
|
|
// Created by 佳尔 on 2025/4/28.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SPMemberRechargeCell: SPCollectionViewCell {
|
|
|
|
|
|
var model: SPPayTemplateItem? {
|
|
didSet {
|
|
desLabel.text = model?.sp_description
|
|
// typeLabel.text = model?.vip_type_key?.getText()
|
|
typeLabel.text = model?.brief
|
|
currencyLabel.text = model?.currency
|
|
moneyLabel.text = model?.price
|
|
if let sendCoins = model?.send_coins, sendCoins > 0 {
|
|
markBgView.isHidden = false
|
|
sendCoinLabel.text = String(format: "movia_extra_#".localized, "\(sendCoins)")
|
|
} else {
|
|
markBgView.isHidden = true
|
|
}
|
|
|
|
switch model?.vip_type_key {
|
|
case .year:
|
|
vipImageView.image = UIImage(named: "vip_image_01")
|
|
downBgView.colors = [UIColor.colorFDE9A6().cgColor, UIColor.colorFFAC38().cgColor]
|
|
topBgView.colors = [UIColor.color2B2826().cgColor, UIColor.color100F0B().cgColor]
|
|
|
|
desLabel.textColor = .color6B3308()
|
|
iconImageView.image = UIImage(named: "vip_icon_03")
|
|
typeLabel.textColor = .colorFFB559()
|
|
typeIconImageView.image = UIImage(named: "vip_icon_05")
|
|
|
|
case .quarter:
|
|
vipImageView.image = UIImage(named: "vip_image_02")
|
|
downBgView.colors = [UIColor.colorFDE9A6().cgColor, UIColor.colorFFAC38().cgColor]
|
|
topBgView.colors = [UIColor.colorFEE3B5().cgColor, UIColor.colorFCCE7D().cgColor]
|
|
|
|
desLabel.textColor = .color6B3308()
|
|
iconImageView.image = UIImage(named: "vip_icon_03")
|
|
typeLabel.textColor = .color9F5300()
|
|
typeIconImageView.image = UIImage(named: "vip_icon_06")
|
|
|
|
case .month:
|
|
vipImageView.image = UIImage(named: "vip_image_03")
|
|
downBgView.colors = [UIColor.color2AAED3().cgColor, UIColor.color9CD5E5().cgColor]
|
|
topBgView.colors = [UIColor.colorF2F4F4().cgColor, UIColor.colorC8E1E8().cgColor]
|
|
|
|
desLabel.textColor = .colorFFFFFF()
|
|
iconImageView.image = UIImage(named: "vip_icon_04")
|
|
typeLabel.textColor = .color0D4E64()
|
|
typeIconImageView.image = UIImage(named: "vip_icon_07")
|
|
|
|
case .week:
|
|
vipImageView.image = UIImage(named: "vip_image_04")
|
|
downBgView.colors = [UIColor.color0588DB().cgColor, UIColor.colorA9E1F2().cgColor]
|
|
topBgView.colors = [UIColor.colorFAFCFE().cgColor, UIColor.colorCED6FA().cgColor]
|
|
|
|
desLabel.textColor = .colorFFFFFF()
|
|
iconImageView.image = UIImage(named: "vip_icon_04")
|
|
typeLabel.textColor = .color020926()
|
|
typeIconImageView.image = UIImage(named: "vip_icon_08")
|
|
|
|
default:
|
|
break
|
|
}
|
|
|
|
currencyLabel.textColor = typeLabel.textColor
|
|
moneyLabel.textColor = typeLabel.textColor
|
|
tipLabel.textColor = typeLabel.textColor
|
|
|
|
}
|
|
}
|
|
|
|
//MARK: UI属性
|
|
private lazy var downBgView: SPGradientView = {
|
|
let view = SPGradientView()
|
|
view.locations = [0, 1]
|
|
view.startPoint = .init(x: 0, y: 0.5)
|
|
view.endPoint = .init(x: 1, y: 0.5)
|
|
view.layer.cornerRadius = 12
|
|
view.layer.masksToBounds = true
|
|
return view
|
|
}()
|
|
|
|
private lazy var topBgView: SPGradientView = {
|
|
let view = SPGradientView()
|
|
view.locations = [0, 1]
|
|
view.startPoint = .init(x: 0, y: 0.5)
|
|
view.endPoint = .init(x: 1, y: 0.5)
|
|
view.layer.cornerRadius = 11
|
|
view.layer.masksToBounds = true
|
|
return view
|
|
}()
|
|
|
|
private lazy var vipImageView: UIImageView = {
|
|
let imageView = UIImageView()
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var iconImageView: UIImageView = {
|
|
let imageView = UIImageView()
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var desLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontRegular(ofSize: 12)
|
|
return label
|
|
}()
|
|
|
|
private lazy var typeLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontMedium(ofSize: 16)
|
|
return label
|
|
}()
|
|
|
|
private lazy var typeIconImageView: UIImageView = {
|
|
let imageView = UIImageView()
|
|
imageView.isHidden = true
|
|
return imageView
|
|
}()
|
|
|
|
private lazy var currencyLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontBold(ofSize: 32)
|
|
return label
|
|
}()
|
|
|
|
private lazy var moneyLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontBold(ofSize: 32)
|
|
return label
|
|
}()
|
|
|
|
private lazy var tipLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontRegular(ofSize: 11)
|
|
label.text = "movia_buy_menber_tip".localized
|
|
return label
|
|
}()
|
|
|
|
private lazy var markBgView: SPGradientView = {
|
|
let view = SPGradientView()
|
|
view.colors = [UIColor.colorFF1A35().cgColor, UIColor.colorFF569C().cgColor, UIColor.colorFF8E33().cgColor]
|
|
view.locations = [0, 0.5, 1]
|
|
view.startPoint = .init(x: 0, y: 0.5)
|
|
view.endPoint = .init(x: 1, y: 0.5)
|
|
view.addRadius(topLeft: 0, topRight: 0, bottomLeft: 11, bottomRight: 0)
|
|
return view
|
|
}()
|
|
|
|
private lazy var sendCoinLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .fontBold(ofSize: 11)
|
|
label.textColor = .colorFFFFFF()
|
|
return label
|
|
}()
|
|
|
|
private lazy var coinImageView: UIImageView = {
|
|
let imageView = UIImageView(image: UIImage(named: "coin_icon_05"))
|
|
return imageView
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension SPMemberRechargeCell {
|
|
|
|
private func _setupUI() {
|
|
contentView.addSubview(downBgView)
|
|
downBgView.addSubview(iconImageView)
|
|
downBgView.addSubview(desLabel)
|
|
contentView.addSubview(topBgView)
|
|
topBgView.addSubview(vipImageView)
|
|
topBgView.addSubview(typeLabel)
|
|
topBgView.addSubview(typeIconImageView)
|
|
topBgView.addSubview(currencyLabel)
|
|
topBgView.addSubview(moneyLabel)
|
|
topBgView.addSubview(tipLabel)
|
|
topBgView.addSubview(markBgView)
|
|
markBgView.addSubview(sendCoinLabel)
|
|
markBgView.addSubview(coinImageView)
|
|
|
|
|
|
downBgView.snp.makeConstraints { make in
|
|
make.edges.equalToSuperview()
|
|
}
|
|
|
|
iconImageView.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(17)
|
|
make.bottom.equalToSuperview().offset(-7)
|
|
}
|
|
|
|
desLabel.snp.makeConstraints { make in
|
|
make.centerY.equalTo(iconImageView)
|
|
make.left.equalTo(iconImageView.snp.right).offset(4)
|
|
}
|
|
|
|
topBgView.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(1)
|
|
make.right.equalToSuperview().offset(-1)
|
|
make.top.equalToSuperview().offset(1)
|
|
make.bottom.equalToSuperview().offset(-25)
|
|
}
|
|
|
|
vipImageView.snp.makeConstraints { make in
|
|
make.centerY.equalToSuperview()
|
|
make.right.equalToSuperview().offset(-7)
|
|
}
|
|
|
|
typeLabel.snp.makeConstraints { make in
|
|
make.left.equalToSuperview().offset(kSPMainW(23))
|
|
make.top.equalToSuperview().offset(19)
|
|
}
|
|
|
|
typeIconImageView.snp.makeConstraints { make in
|
|
make.centerY.equalTo(typeLabel)
|
|
make.left.equalTo(typeLabel.snp.right).offset(3)
|
|
}
|
|
|
|
currencyLabel.snp.makeConstraints { make in
|
|
make.left.equalTo(typeLabel)
|
|
make.top.equalTo(typeLabel.snp.bottom).offset(8)
|
|
}
|
|
|
|
moneyLabel.snp.makeConstraints { make in
|
|
make.centerY.equalTo(currencyLabel)
|
|
make.left.equalTo(currencyLabel.snp.right).offset(5)
|
|
}
|
|
|
|
tipLabel.snp.makeConstraints { make in
|
|
make.left.equalTo(typeLabel)
|
|
make.top.equalTo(moneyLabel.snp.bottom).offset(8)
|
|
}
|
|
|
|
markBgView.snp.makeConstraints { make in
|
|
make.top.right.equalToSuperview()
|
|
make.height.equalTo(18)
|
|
}
|
|
|
|
sendCoinLabel.snp.makeConstraints { make in
|
|
make.centerY.equalToSuperview()
|
|
make.left.equalToSuperview().offset(5)
|
|
}
|
|
|
|
coinImageView.snp.makeConstraints { make in
|
|
make.centerY.equalToSuperview()
|
|
make.left.equalTo(sendCoinLabel.snp.right).offset(2)
|
|
make.right.equalToSuperview().offset(-5)
|
|
}
|
|
}
|
|
|
|
}
|