ThimraTV/MoviaBox/Class/Mine/View/SPLanguageCell.swift
2025-05-10 11:23:25 +08:00

92 lines
2.5 KiB
Swift

//
// SPLanguageCell.swift
// MoviaBox
//
// Created by on 2025/5/10.
//
import UIKit
class SPLanguageCell: SPTableViewCell {
var model: SPLanguageModel? {
didSet {
titleLabel.text = model?.show_name
if model?.is_default == 1 {
self.contentView.layer.borderColor = UIColor.colorFF3232().cgColor
self.selectedButton.isSelected = true
} else {
self.contentView.layer.borderColor = UIColor.clear.cgColor
self.selectedButton.isSelected = false
}
}
}
var sp_isSelected = false {
didSet {
if sp_isSelected {
self.contentView.layer.borderColor = UIColor.colorFF3232().cgColor
self.selectedButton.isSelected = true
} else {
self.contentView.layer.borderColor = UIColor.clear.cgColor
self.selectedButton.isSelected = false
}
}
}
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .fontMedium(ofSize: 14)
label.textColor = .colorFFFFFF()
return label
}()
private lazy var selectedButton: UIButton = {
let button = UIButton(type: .custom)
button.isUserInteractionEnabled = false
button.setImage(UIImage(named: "check_icon_01"), for: .normal)
button.setImage(UIImage(named: "check_icon_01_selected"), for: .selected)
return button
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.contentView.backgroundColor = .color321F1F()
self.contentView.layer.borderWidth = 1
self.contentView.layer.cornerRadius = 10
self.contentView.layer.masksToBounds = true
_setupUI()
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension SPLanguageCell {
private func _setupUI() {
contentView.addSubview(titleLabel)
contentView.addSubview(selectedButton)
titleLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalToSuperview().offset(16)
}
selectedButton.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.right.equalToSuperview().offset(-16)
}
}
}