//
//  RoleTagCollectionCell.swift
//  Visual_Novel_iOS
//
//  Created by mh on 2025/10/16.
//

import UIKit

class RoleTagCollectionCell: UICollectionViewCell {
    
    lazy var containerView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(hex: "#BAC5D2")
        view.cornerRadius = 11.5
        return view
    }()
    
    lazy var titleLab: UILabel = {
        let lab = UILabel()
        lab.font = UIFont.boldSystemFont(ofSize: 12)
        lab.textColor = UIColor(hex: "#E5F1FF")
        lab.textAlignment = .center
        return lab
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.contentView.clipsToBounds = true
        setupViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupViews() {
        
        contentView.addSubview(containerView)
        containerView.addSubview(titleLab)
        
        containerView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        titleLab.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.right.equalToSuperview().inset(7)
        }
    }
    
    func setupData(model: CLRoleTagsModel) {
        titleLab.text = model.name
        if model.isSelected {
            containerView.backgroundColor = UIColor(hex: "#0065FF")
            titleLab.textColor = .white
        } else {
            containerView.backgroundColor = UIColor(hex: "#BAC5D2")
            titleLab.textColor = UIColor(hex: "#E5F1FF")
        }
    }
    
}
