//
//  CustomSheetCell.swift
//  SwiftProject
//
//  Created by aaa on 2024/4/3.
//

import Foundation
import UIKit
class CustomSheetCell: UITableViewCell {
    
    lazy var rightImgView:UIImageView? = {
       let imgView = UIImageView()
        return imgView
    }()
    
    lazy var leftLabel:UILabel? = {
       let label = UILabel()
        label.textColor = .white
        label.font = UIFont.systemFont(ofSize: 16)
        label.textAlignment = .center
        return label
    }()
    
    let wh:CGFloat = 25
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.backgroundColor = .clear
        self.contentView.addSubview(rightImgView!)
        self.contentView.addSubview(leftLabel!)
        
        
        rightImgView?.snp.makeConstraints({ make in
            make.width.equalTo(wh)
            make.height.equalTo(wh)
            make.centerY.equalToSuperview()
        })
        
        leftLabel?.snp.makeConstraints({ make in
            make.top.bottom.equalTo(0)
            make.left.equalTo(rightImgView!.snp.right).offset(8)
            make.centerX.equalToSuperview()
            make.width.equalTo(60)
        })
        
        self.contentView.backgroundColor = UIColor(r: 20, g: 20, b: 20, a: 1)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setCData(_ data:[String:String]) {
        rightImgView?.image = nil
        leftLabel?.text = nil
        if !UserInfo.sharedInstance.isMemberShip {
            let imgName = data["imgName"]
            if let im = imgName {
                rightImgView?.image = UIImage(named: im)

                rightImgView?.isHidden = false
            }
            else {

                rightImgView?.isHidden = true
            }
        }
        
        
        let text = data["text"]
        leftLabel?.text = text
    }
}
