//
//  TSRecollectionSectionHeader.swift
//  KittensTravelNotes
//
//  Created by 100Years on 2025/7/7.
//

class TSRecollectionSectionHeader: UICollectionReusableView {
    var clickBlock:(()->Void)?
    
    lazy var dateformat: DateFormatter = {
        let format = DateFormatter()
        format.locale = .current
        format.dateStyle = .medium
//        format.dateFormat = "yyyy-MM-dd"
        return format
    }()
    
    var date:Date = Date(){
        didSet{
            titleLab.text =  dateformat.string(from: date)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        creatUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var titleLab: UILabel = {
        let titleLab = UILabel.createLabel(font: .font(name: .PoppinsBoldItalic,size: 16,weight: .medium),textColor: .mainText)
        return titleLab
    }()
    
    
    lazy var deleteBtn:TSUIExpandedTouchButton = {
        let deleteBtn = TSUIExpandedTouchButton()
        deleteBtn.setUpButton(image: .delete) { [weak self]  in
            guard let self = self else { return }
            clickBlock?()
        }
        return deleteBtn
    }()
    

    func creatUI() {
        addSubview(titleLab)
        titleLab.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.top.equalTo(23)
        }
    
        addSubview(deleteBtn)
        deleteBtn.snp.makeConstraints { make in
            make.trailing.equalTo(-16)
            make.centerY.equalTo(titleLab)
        }
    }

}
