//
//  TSViewTool.swift
//  TSLiveWallpaper
//
//  Created by 100Years on 2024/12/20.
//

class TSViewTool: UIView {
    
    static func createNormalSubmitBtn(title:String, imageNamed:String? = nil, action: (() -> Void)? = nil) -> UIButton {
        let image = UIImage(named:imageNamed ?? "")
        let btn = UIButton.createButton(title:title,image: image,font: UIFont.font(size: 18,weight: .medium),titleColor:"#111111".uiColor,action: action)
   
        var buttonBgImage = UIImage(named: "normal_submit_bg")!
//        if UIDevice.isPad {
//            buttonBgImage = buttonBgImage.resizableImage(withCapInsets: UIEdgeInsets(top:24, left: 24, bottom: 24, right: 24), resizingMode: .stretch)
//        }
          btn.setBackgroundImage(buttonBgImage, for: .normal)
        
//        kDelayMainShort {
//            btn.addGradientBg(colors: ["#B3FFAB".uiColor.cgColor,"12FFF7".uiColor.cgColor],startPoint: CGPoint(x: 0, y: 1),endPoint: CGPoint(x: 1, y: 0))
//        }

        
        if image != nil {
            btn.imageEdgeInsets = UIEdgeInsets(top: 0, left: -8, bottom: 0, right: 0)
            btn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 0)
        }
        return btn
    }
    
    
    static func setNormalSubmitBtn(btn:UIButton,showVip:Bool) {
        if showVip{
            btn.setImage(UIImage(named: "vip_icon"), for: .normal)
            btn.imageEdgeInsets = UIEdgeInsets(top: 0, left: -8, bottom: 0, right: 0)
            btn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 0)
        }else{
            btn.setImage(nil, for: .normal)
            btn.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
            btn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        }
    }
    
    static func createBlurEffectView(style:UIBlurEffect.Style,backgroundColor:UIColor? = nil) -> UIVisualEffectView {
        let blurEffect = UIBlurEffect(style: style)
        let blurEffectView = UIVisualEffectView(effect: blurEffect)
        blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        
        if backgroundColor != nil {
            blurEffectView.backgroundColor = backgroundColor
        }
        
        return blurEffectView
    }
}


let kWapppaperPlaceholderImage = UIImage(named: "wapppaper_placeholder")
let KIconLiveImage = UIImage(named: "icon_live")
