//
//  TSTBDesktopPreviewView.swift
//  AIRingtone
//
//  Created by 100Years on 2025/3/2.
//

class TSTBDesktopPreviewView: TSBaseView {
    
    var closePage:(()->Void)?
    var urlString:String?{
        didSet{
            islandView.showImageView.setAsyncImage(urlString: urlString,contentMode: .scaleAspectFill)
        }
    }
    lazy var bgImageView : UIImageView = {
        let bgImageView = UIImageView.createImageView(imageName: "desktop_bg")
        return bgImageView
    }()
    
    lazy var iconBgImageView : UIImageView = {
        let iconBgImageView = UIImageView.createImageView(imageName: "desktop_clear_bg")
        return iconBgImageView
    }()
    
    lazy var islandView : TSTSIslandView = {
        let islandView = TSTSIslandView()
        return islandView
    }()
    
    override func creatUI() {
        self.backgroundColor = .yellow.withAlphaComponent(0.1)
        addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickView)))
        
        contentView.addSubview(bgImageView)
        bgImageView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.equalTo(k_ScreenWidth)
            make.height.equalTo(kDesignScale*812)
        }
        
        contentView.addSubview(iconBgImageView)
        iconBgImageView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.equalTo(k_ScreenWidth)
            make.height.equalTo(kDesignScale*812)
        }
        
        contentView.addSubview(islandView)
        islandView.snp.makeConstraints { make in
            make.top.equalTo(10+k_Height_statusBar())
            make.centerX.equalToSuperview()
            make.width.equalTo(islandView.width)
            make.height.equalTo(islandView.height)
        }
    }
    
    
    @objc func clickView(){
        isHidden = true
        closePage?()
    }
}
