//
|
// WorldCupRankTCell.swift
|
// WanPai
|
//
|
// Created by 无故事王国 on 2024/2/28.
|
//
|
|
import UIKit
|
import JQTools
|
|
class WorldCupRankTCell: UITableViewCell {
|
|
private var rankImg:UIImageView!
|
private var rankLabel:UILabel!
|
private var userImg:UIImageView!
|
private var userNameLabel:UILabel!
|
private var numerLabel:UILabel!
|
private var radioLabel:UILabel!
|
private var integralLabel:UILabel!
|
var indexPath:IndexPath?
|
|
var model:WorldCupMatchRankModel?{
|
didSet{
|
if let m = model{
|
integralLabel.text = "\(m.integral)"
|
userNameLabel.text = m.name
|
userImg.sd_setImage(with: URL(string: m.avatar))
|
numerLabel.text = "\(m.totalSession)"
|
radioLabel.text = String(format: "%.2lf%%", m.winRate)
|
|
if let index = indexPath{
|
rankImg.image = UIImage(named: "rank_\(index.row + 1)")
|
switch index.row{
|
case 0...2:
|
rankImg.isHidden = false
|
rankLabel.text = ""
|
default:
|
rankImg.isHidden = true
|
rankLabel.text = "\(index.row + 1)"
|
}
|
}else{
|
rankImg.isHidden = true
|
rankLabel.text = "\(m.rank)"
|
}
|
|
self.jq_borderColor = UIColor(hexString: "#FC743A")
|
|
if m.oneself == 1{
|
self.jq_borderWidth = 1
|
}else{
|
self.jq_borderWidth = 0
|
}
|
}
|
}
|
}
|
|
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
super.init(style: .default, reuseIdentifier: reuseIdentifier)
|
setUI()
|
}
|
|
required init?(coder: NSCoder) {
|
fatalError("init(coder:) has not been implemented")
|
}
|
|
|
private func setUI(){
|
|
selectionStyle = .none
|
|
rankImg = UIImageView()
|
contentView.addSubview(rankImg)
|
rankImg.snp.makeConstraints { make in
|
make.left.equalTo(15)
|
make.top.equalTo(12)
|
make.width.equalTo(22)
|
make.height.equalTo(26)
|
}
|
|
rankLabel = UILabel()
|
rankLabel.text = "1"
|
rankLabel.font = UIFont.init(name: "Impact", size: 12)
|
rankLabel.textColor = UIColor(hexString: "#777777")
|
rankLabel.textAlignment = .center
|
contentView.addSubview(rankLabel)
|
rankLabel.snp.makeConstraints { make in
|
make.center.equalTo(rankImg)
|
}
|
|
userImg = UIImageView()
|
userImg.backgroundColor = .black.withAlphaComponent(0.4)
|
userImg.jq_cornerRadius = 17
|
contentView.addSubview(userImg)
|
userImg.snp.makeConstraints { make in
|
make.left.equalTo(rankImg.snp.right).offset(37)
|
make.centerY.equalToSuperview()
|
make.width.height.equalTo(34)
|
}
|
|
userNameLabel = UILabel()
|
userNameLabel.text = ""
|
userNameLabel.font = UIFont.systemFont(ofSize: 14, weight: .medium)
|
userNameLabel.textColor = .black
|
contentView.addSubview(userNameLabel)
|
userNameLabel.snp.makeConstraints { make in
|
make.left.equalTo(userImg.snp.right).offset(10)
|
make.centerY.equalToSuperview()
|
make.height.equalTo(20)
|
make.width.equalTo(70)
|
}
|
|
integralLabel = UILabel()
|
integralLabel.text = "10"
|
integralLabel.font = UIFont.systemFont(ofSize: 14, weight: .medium)
|
integralLabel.textColor = .black
|
contentView.addSubview(integralLabel)
|
integralLabel.snp.makeConstraints { make in
|
make.left.equalTo(userNameLabel.snp.right).offset(10)
|
make.centerY.equalToSuperview()
|
make.height.equalTo(20)
|
make.width.equalTo(60)
|
}
|
|
|
|
numerLabel = UILabel()
|
numerLabel.text = "0"
|
numerLabel.font = UIFont.systemFont(ofSize: 12)
|
numerLabel.textColor = .black.withAlphaComponent(0.6)
|
numerLabel.textAlignment = .center
|
contentView.addSubview(numerLabel)
|
numerLabel.snp.makeConstraints { make in
|
// make.left.equalToSuperview().offset((JQ_ScreenW - 28) * 0.469)
|
make.left.equalTo(integralLabel.snp.right).offset(7)
|
make.centerY.equalToSuperview()
|
make.height.equalTo(17)
|
// make.right.equalToSuperview().offset(-((JQ_ScreenW - 28) * 0.201))
|
}
|
|
|
radioLabel = UILabel()
|
radioLabel.text = "0%"
|
radioLabel.font = UIFont.systemFont(ofSize: 12)
|
radioLabel.textColor = .black.withAlphaComponent(0.6)
|
radioLabel.textAlignment = .center
|
contentView.addSubview(radioLabel)
|
radioLabel.snp.makeConstraints { make in
|
// make.left.equalTo(numerLabel.snp.right)
|
make.centerY.equalToSuperview()
|
make.height.equalTo(17)
|
make.right.equalToSuperview().offset(-5)
|
}
|
|
|
}
|
}
|