//
//  TSSettingCell.swift
//  Girly
//
//  Created by 100Years on 2025/1/10.
//

class TSSettingCell: TSSimpleTableViewCell {
    
    lazy var leftLab: UILabel = {
        return UILabel.createLabel(font: .font(size: 16,weight: .bold),textColor: .white)
    }()
    
    lazy var rightLab: UILabel = {
        return UILabel.createLabel(font: .font(size: 16,weight: .bold),textColor: .fromHex("FFFFFF", alpha: 0.4))
    }()
    
    lazy var rightImageView: UIImageView = {
        return UIImageView.createRightArrow()
    }()
    
    lazy var lineView: UIView = {
        let lineView = UIView()
        lineView.backgroundColor = UIColor.fromHex("#FFFFFF", alpha: 0.1)
        return lineView
    }()
    override var itemModel:TSBasicItemModel{
        didSet{
            leftLab.text = itemModel.leftTitle
            rightLab.text = itemModel.rightString
            
            if itemModel.rightIsHave {
                rightImageView.isHidden = false
                rightLab.isHidden = true
            }else{
                rightImageView.isHidden = true
                rightLab.isHidden = false
            }
            
            lineView.isHidden = !itemModel.bottomIsHave
            self.bgContentView.frame = CGRect(x: 0, y: 0, width: k_ScreenWidth - 32, height: itemModel.height)
            self.itemModel.setCornerView(self.bgContentView, corner: 20)
        }
    }
    
    override func creatUI() {
        bgContentView.backgroundColor = UIColor.fromHex("FFFFFF", alpha: 0.1)
        bgContentView.addSubview(leftLab)
        bgContentView.addSubview(rightLab)
        bgContentView.addSubview(rightImageView)
        bgContentView.addSubview(lineView)
        
        leftLab.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.centerY.equalToSuperview()
        }
        
        rightLab.snp.makeConstraints { make in
            make.trailing.equalTo(-16)
            make.centerY.equalToSuperview()
        }
        
        rightImageView.snp.makeConstraints { make in
            make.trailing.equalTo(-16)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(24)
        }
        
        lineView.snp.makeConstraints { make in
            make.leading.trailing.bottom.equalTo(0)
            make.height.equalTo(1)
        }
    }
    
    override func didEndDisplaying(indexPath: IndexPath) {
        self.itemModel.setCornerView(self.bgContentView, corner: 20)
    }
}
