//
//  TSRandomWallpaperBrowseView.swift
//  TSLiveWallpaper
//
//  Created by 100Years on 2024/12/24.
//


class TSRandomWallpaperSelecAllView : TSBaseView {
    
    var clickCallBack:(()->Void)?
    
    var isSelected: Bool = true {
        didSet {
            selectImageView.image = UIImage(named: isSelected ? "radiobox_selected" : "radiobox_unSelect")
        }
    }
    
    lazy var selectImageView: UIImageView = {
        return UIImageView.createImageView(imageName: "radiobox_selected")
    }()
    
    lazy var selectTextLabel: UILabel = {
        return UILabel.createLabel(text: "Select All".localized,font: UIFont.font(size: 14),textColor: UIColor.fromHex("FFFFFF"))
    }()
    
    lazy var selectNumLabel: UILabel = {
        return UILabel.createLabel(font: UIFont.font(size: 14),textColor: UIColor.fromHex("FFFFFF", alpha: 0.4))
    }()
    
    lazy var clearButton: UIButton = {
        let clearButton = UIButton()
        clearButton.isSelected = true
        clearButton.addTarget(self,action:#selector(clickClearButton(_:)), for: .touchUpInside)
        return clearButton
    }()
    
    override func creatUI() {
        contentView.addSubview(selectImageView)
        contentView.addSubview(selectTextLabel)
        contentView.addSubview(selectNumLabel)
        contentView.addSubview(clearButton)
        
        selectImageView.snp.makeConstraints { make in
            make.width.height.equalTo(20)
            make.centerY.equalToSuperview()
            make.leading.equalTo(0)
        }
        
        selectTextLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.leading.equalTo(selectImageView.snp.trailing).offset(6)
        }
        
        selectNumLabel.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.leading.equalTo(selectTextLabel.snp.trailing).offset(0)
            make.trailing.equalTo(0)
        }
        
        clearButton.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
    }
    
    @objc func clickClearButton(_ btn:UIButton){
        clickCallBack?()
    }
}
