176 lines
5.4 KiB
Swift
176 lines
5.4 KiB
Swift
//
|
|
// XSStoreCoinsBigCell.swift
|
|
// XSeri
|
|
//
|
|
// Created by 长沙鸿瑶 on 2026/3/18.
|
|
//
|
|
|
|
import UIKit
|
|
import SnapKit
|
|
|
|
class XSStoreCoinsBigCell: XSStoreCell {
|
|
|
|
override var item: XSPayItem? {
|
|
didSet {
|
|
let coins = item?.coins ?? 0
|
|
let sendCoins = item?.send_coins ?? 0
|
|
|
|
coinsLabel.text = "\(coins)"
|
|
|
|
if sendCoins > 0 {
|
|
sendCoinsLabel.isHidden = false
|
|
sendCoinsRatioView.isHidden = false
|
|
|
|
sendCoinsLabel.text = "+ \(sendCoins) " + "Bonus".localized
|
|
|
|
let ratio = String(format: "%.0f", CGFloat(sendCoins) / CGFloat(coins) * 100)
|
|
sendCoinsRatioLabel.text = "+\(ratio)%"
|
|
} else {
|
|
sendCoinsLabel.isHidden = true
|
|
sendCoinsRatioView.isHidden = true
|
|
}
|
|
|
|
priceLabel.text = "\(item?.currency ?? "")\(item?.price ?? "")"
|
|
if let make = item?.corner_marker, !make.isEmpty {
|
|
hotView.isHidden = false
|
|
} else {
|
|
hotView.isHidden = true
|
|
}
|
|
}
|
|
}
|
|
|
|
private lazy var bgView: XSView = {
|
|
let view = XSView()
|
|
view.xs_colors = [UIColor._703_BDE.cgColor, UIColor.D_567_F_1.cgColor]
|
|
view.xs_startPoint = .init(x: 0.5, y: 0)
|
|
view.xs_endPoint = .init(x: 0.5, y: 1)
|
|
view.layer.cornerRadius = 12
|
|
view.layer.masksToBounds = true
|
|
view.layer.borderWidth = 1
|
|
view.layer.borderColor = UIColor.white.withAlphaComponent(0.25).cgColor
|
|
return view
|
|
}()
|
|
|
|
private lazy var coinsContainerView: UIView = {
|
|
let view = UIView()
|
|
return view
|
|
}()
|
|
|
|
private lazy var coinsIconImageView = UIImageView(image: UIImage(named: "coins_icon_04"))
|
|
|
|
private lazy var coinsLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .font(ofSize: 18, weight: .bold)
|
|
return label
|
|
}()
|
|
|
|
private lazy var sendCoinsLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .font(ofSize: 12, weight: .regular)
|
|
label.textColor = .white.withAlphaComponent(0.5)
|
|
return label
|
|
}()
|
|
|
|
private lazy var priceLabel: UILabel = {
|
|
let label = UILabel()
|
|
label.backgroundColor = .white
|
|
label.layer.cornerRadius = 12
|
|
label.layer.masksToBounds = true
|
|
label.font = .font(ofSize: 14, weight: .bold)
|
|
label.textColor = ._2_A_2_A_2_A
|
|
label.textAlignment = .center
|
|
return label
|
|
}()
|
|
|
|
private lazy var hotView = UIImageView(image: UIImage(named: "hot_icon_05"))
|
|
|
|
private lazy var sendCoinsRatioView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = .white
|
|
view.layer.cornerRadius = 8
|
|
view.layer.masksToBounds = true
|
|
view.layer.maskedCorners = .layerMinXMaxYCorner
|
|
return view
|
|
}()
|
|
|
|
private lazy var sendCoinsRatioLabel: UILabel = {
|
|
let label = XSLabel()
|
|
label.font = .font(ofSize: 14, weight: .bold)
|
|
label.textColors = [UIColor._6900_CB.cgColor, UIColor.F_75_FFF.cgColor]
|
|
label.textStartPoint = .init(x: 0.5, y: 0)
|
|
label.textEndPoint = .init(x: 0.5, y: 1)
|
|
return label
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
xs_setupUI()
|
|
}
|
|
|
|
@MainActor required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|
|
|
|
extension XSStoreCoinsBigCell {
|
|
|
|
private func xs_setupUI() {
|
|
contentView.addSubview(bgView)
|
|
contentView.addSubview(coinsContainerView)
|
|
coinsContainerView.addSubview(coinsIconImageView)
|
|
coinsContainerView.addSubview(coinsLabel)
|
|
contentView.addSubview(sendCoinsLabel)
|
|
contentView.addSubview(priceLabel)
|
|
contentView.addSubview(hotView)
|
|
bgView.addSubview(sendCoinsRatioView)
|
|
sendCoinsRatioView.addSubview(sendCoinsRatioLabel)
|
|
|
|
bgView.snp.makeConstraints { make in
|
|
make.edges.equalToSuperview()
|
|
}
|
|
|
|
coinsContainerView.snp.makeConstraints { make in
|
|
make.centerX.equalToSuperview()
|
|
make.top.equalToSuperview().offset(14)
|
|
}
|
|
|
|
coinsIconImageView.snp.makeConstraints { make in
|
|
make.left.top.bottom.equalToSuperview()
|
|
}
|
|
|
|
coinsLabel.snp.makeConstraints { make in
|
|
make.centerY.equalToSuperview()
|
|
make.left.equalTo(coinsIconImageView.snp.right).offset(5)
|
|
make.right.equalToSuperview()
|
|
}
|
|
|
|
sendCoinsLabel.snp.makeConstraints { make in
|
|
make.centerX.equalToSuperview()
|
|
make.top.equalTo(coinsContainerView.snp.bottom).offset(6)
|
|
}
|
|
|
|
priceLabel.snp.makeConstraints { make in
|
|
make.left.right.equalToSuperview().inset(6)
|
|
make.bottom.equalToSuperview().inset(6)
|
|
make.height.equalTo(24)
|
|
}
|
|
|
|
hotView.snp.makeConstraints { make in
|
|
make.left.equalToSuperview()
|
|
make.top.equalToSuperview()
|
|
}
|
|
|
|
sendCoinsRatioView.snp.makeConstraints { make in
|
|
make.top.right.equalToSuperview()
|
|
make.height.equalTo(18)
|
|
}
|
|
|
|
sendCoinsRatioLabel.snp.makeConstraints { make in
|
|
make.center.equalToSuperview()
|
|
make.left.equalToSuperview().offset(4)
|
|
}
|
|
}
|
|
|
|
}
|