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

class TSLightGradientToolView: TSBaseView {
    
    var changedColorComplete:((TSLightItemModel)->Void)?
    
    lazy var colorPickerView: TSColorPickerView = {
        let colorPickerView = TSColorPickerView()
        colorPickerView.dataArray = kLightShared.gradientColors
        colorPickerView.layout.minimumLineSpacing = 20.0
        colorPickerView.layout.minimumInteritemSpacing = 20.0
        colorPickerView.selectedColorComplete = { [weak self] colorModel in
            guard let self = self else { return }
            changedColorComplete?(colorModel)
        }
        return colorPickerView
    }()
    
    override func creatUI() {
        addSubview(colorPickerView)
        colorPickerView.snp.makeConstraints { make in
            make.leading.equalTo(18)
            make.trailing.equalTo(-17)
            make.top.equalTo(18)
            make.height.equalTo(101)
        }
        
        colorPickerView.collectionView.reloadData()
        
        kDelayMainShort {
            self.colorPickerView.collectionView.selectItem(at: IndexPath(item: 0, section: 0), animated: true, scrollPosition: .left)
        }
    }
}

