//
//  YHCertificateInfoCell.swift
//  galaxy
//
//  Created by edy on 2024/3/12.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//

import UIKit

class YHCertificateNameCell: UITableViewCell {
    
    static let cellReuseIdentifier = "YHCertificateNameCell"
    
    var whiteView: UIView!
    var iconImgV: UIImageView!
    var nameLabel: UILabel!
    var timeLabel: UILabel!
    var editBtn: UIButton!
    

    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    func setupUI() {
        
        self.selectionStyle = .none
        contentView.backgroundColor = .white
        
        whiteView = UIView()
        contentView.addSubview(whiteView)
        
        iconImgV = UIImageView(image:UIImage(named:"my_cer_type_pdf"))
        whiteView.addSubview(iconImgV)
        
        nameLabel = UILabel()
        nameLabel.textColor = UIColor.mainTextColor
        nameLabel.textAlignment = .left
        nameLabel.font = UIFont.PFSC_M(ofSize:14)
        nameLabel.text = "文档名称.doc"
        whiteView.addSubview(nameLabel)
        
        timeLabel = UILabel()
        timeLabel.textColor = UIColor.labelTextColor2
        timeLabel.textAlignment = .left
        timeLabel.font = UIFont.PFSC_R(ofSize:11)
        timeLabel.text = "上传于2024.01.01"
        whiteView.addSubview(timeLabel)
        
        editBtn = UIButton()
        editBtn.setImage(UIImage(named:"my_cer_btn_edit"), for:.normal)
        whiteView.addSubview(editBtn)

        whiteView.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(20)
            make.right.equalToSuperview().offset(-20)
            make.height.equalTo(55)
            make.top.equalToSuperview().offset(15)
        }

        iconImgV.snp.makeConstraints { make in
            make.width.height.equalTo(31)
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(6)
        }
        
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(iconImgV.snp.right).offset(18)
            make.height.equalTo(20)
            make.bottom.equalTo(whiteView.snp.centerY).offset(-1)
            make.right.equalTo(editBtn.snp.left)
        }
        
        timeLabel.snp.makeConstraints { make in
            make.left.right.equalTo(nameLabel)
            make.top.equalTo(whiteView.snp.centerY).offset(1)
            make.height.equalTo(20)
        }
        
        editBtn.snp.makeConstraints { make in
            make.width.height.equalTo(16)
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-6)
        }
    }
}
