//
//  TSLightSolidColorToolView.swift
//  Girly
//
//  Created by 100Years on 2025/1/7.
//


class TSLightSolidColorToolView: TSBaseView {
    
    lazy var colorSlider: ColorSlider = {
        let colorSlider = kCommonColorSlider()
        colorSlider.color = TSConfig.ligntSolidDefaultColor
        colorSlider.addTarget(self, action: #selector(changedColor(slider:)), for: .valueChanged)
        return colorSlider
    }()
    
    var changedColorComplete:((UIColor)->Void)?
   
    lazy var colorPickerView: TSColorPickerView = {
        let colorPickerView = TSColorPickerView()
        colorPickerView.dataArray = kLightShared.solidColors
        colorPickerView.selectedColorComplete = { [weak self] colorModel in
            guard let self = self else { return }
            changedColorComplete?(colorModel.color.color)
        }
        return colorPickerView
    }()

    override func creatUI() {

        addSubview(colorSlider)
        colorSlider.snp.makeConstraints { make in
            make.leading.equalTo(18)
            make.trailing.equalTo(-18)
            make.top.equalTo(27)
            make.height.equalTo(6)
        }
        
        addSubview(colorPickerView)
        colorPickerView.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.trailing.equalTo(-16)
            make.top.equalTo(70)
            make.height.equalTo(40)
        }
    }
    
    @objc func changedColor(slider: ColorSlider) {
        changedColorComplete?(slider.color)
        colorPickerView.unCheck()
    }
}
