//
//  TSFullScreenVC.swift
//  Girly
//
//  Created by 100Years on 2025/1/8.
//




class TSFullScreenVC: TSBaseVC {
    
    //0纯色,1 渐变色,3 图形
    var type = 0
    
    lazy var colorView: UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    lazy var shapeView: TSLightShapeView = {
        let shapeView = TSLightShapeView()
        return shapeView
    }()
    
    var color:UIColor = .white
    var cgcolors:[CGColor] = [UIColor.white.cgColor]
    var shapeNamed:String = ""
    
    override func createView() {

        setNavBarViewHidden(true)
        contentView.addSubview(colorView)
        colorView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        view.addSubview(shapeView)
        shapeView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        self.view.layoutIfNeeded()
        
        self.shapeView.addContent()
//        kDelayMainShort {
//            self.shapeView.addContent()
//        }
        
        self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(closePage)))
    }
    
    
    
    override func dealThings() {
        if type == 0 {
            colorView.isHidden = false
            shapeView.isHidden = true
            colorView.backgroundColor = color
        }else if type == 1 {
            colorView.isHidden = false
            shapeView.isHidden = true
            colorView.addGradientBg(colors: cgcolors)
        }else if type == 2 {
            colorView.isHidden = true
            shapeView.isHidden = false
            
            shapeView.color = color
            shapeView.imageNamed = shapeNamed
        }
        UIDevice.brightness(brightness: 1.0)
        UIDevice.keepScreenAwake()
    }
    
    
    @objc func closePage() {
        self.dismiss(animated: true)
    }
    
    deinit {
        UIDevice.allowScreenSleep()
    }

}

extension TSFullScreenVC {
    static func creatSolidColorVC(color:UIColor) -> TSFullScreenVC{
        let vc = TSFullScreenVC()
        vc.type = 0
        vc.color = color
        return vc
    }
    
    static func creatGradientVC(cgcolors:[CGColor]) -> TSFullScreenVC{
        let vc = TSFullScreenVC()
        vc.type = 1
        vc.cgcolors = cgcolors
        return vc
    }
    
    static func creatShapeVC(color:UIColor,shapeNamed:String) -> TSFullScreenVC{
        let vc = TSFullScreenVC()
        vc.type = 2
        vc.color = color
        vc.shapeNamed = shapeNamed
        return vc
    }
}
