//
//  TSFlashSetToolView.swift
//  Girly
//
//  Created by 100Years on 2025/1/9.
//

class TSFlashSetToolView: TSBaseView {
    
    var clickDoneComplete:(()->Void)?
    var changedValueComplete:((CGFloat,Bool)->Void)?{
        didSet{
            flashSliderView.changedValueComplete = changedValueComplete
        }
    }

    lazy var bottomView: UIView = {
        let bottomView = UIView()
        bottomView.backgroundColor = .cardBgColor
        return bottomView
    }()
    
    var isShow = true
    
    lazy var titleLabel1: UILabel = {
        let titleLabel1 = UILabel.createLabel(text: "Volume".localized,font: .font(size: 14,weight: .medium),textColor: .white)
        return titleLabel1
    }()
    
    lazy var submitBtn: UIButton = {
        let submitBtn = createNormalSubmitBtn(title: "Open".localized) { [weak self]  in
            guard let self = self else { return }
            isShow = !isShow
            clickDoneComplete?()
        }
        submitBtn.cornerRadius = 22.0;
        return submitBtn
    }()
    
    lazy var flashSliderView: TSFlashSliderView = {
        let flashSliderView = TSFlashSliderView()
        
        return flashSliderView
    }()
    
    override func creatUI() {
        
        contentView.addSubview(bottomView)
        bottomView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        
        let cell1 = creatCell1()
        bottomView.addSubview(cell1)
        cell1.snp.makeConstraints { make in
            make.leading.equalTo(0)
            make.trailing.equalTo(0)
            make.top.equalTo(20)
            make.height.equalTo(44)
        }
        
        bottomView.addSubview(flashSliderView)
        flashSliderView.snp.makeConstraints { make in
            make.top.equalTo(cell1.snp.bottom)
            make.leading.equalTo(16)
            make.trailing.equalTo(-16)
            make.height.equalTo(48)
        }

        bottomView.addSubview(submitBtn)
        submitBtn.snp.makeConstraints { make in
            make.leading.equalTo(50)
            make.trailing.equalTo(-51)
            make.bottom.equalTo(-34)
            make.height.equalTo(44)
        }

        kDelayMainShort {
            self.bottomView.cornersRound(radius: 20, corner: [.topLeft,.topRight])
        }
        
    }
    
    
    func creatCell1() -> UIView{
        let view = UIView()
        view.addSubview(titleLabel1)
        titleLabel1.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.trailing.equalTo(0)
            make.centerY.equalToSuperview()
        }
        return view
        
    }
}
