//
//  YHWorkFileItemView.swift
//  galaxy
//
//  Created by EDY on 2024/2/20.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//

import UIKit

class YHWorkFileItemView: UIView {
    typealias ItemBlock = (_ model: YHItemModel) -> ()
    var block: ItemBlock?
    var titleLabel: UILabel!
    var deleteButton: UIButton!
    
    var dataSource: YHWorkItemListModel? {
        didSet {
            updateAllViews()
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = .white
        setUpView()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUpView() {
        titleLabel = {
            let label = UILabel()
            label.font = kBoldFont(size: 14)
            label.textAlignment = .left
            label.textColor = UIColor(hex:0x222222)
            return label
        }()
        addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.top.equalTo(16)
            make.width.equalTo(200)
            make.height.equalTo(20)
        }
        
        deleteButton = {
            let button = UIButton(type: .custom)
            button.titleLabel?.font = kFont(size: 14)
            button.contentHorizontalAlignment = .center
            button.setTitle("删除", for: .normal)
            button.setTitleColor( UIColor(hex:0xf81d22), for: .normal)
            button.addTarget(self, action: #selector(deleteClick), for: .touchUpInside)
            button.isHidden = true
            return button
        }()
        addSubview(deleteButton)
        deleteButton.snp.makeConstraints { make in
            make.right.equalTo(-24)
            make.height.equalTo(20)
            make.width.equalTo(28)
            make.centerY.equalTo(titleLabel.snp.centerY)
        }
    }
    
    func updateAllViews() {
        guard let dataSource = dataSource else { return }
    }
    
    
    @objc func deleteClick() {
        
    }
}
