//
//  TSRandomWallpaperBannerCell.swift
//  TSLiveWallpaper
//
//  Created by 100Years on 2024/12/22.
//

//MARK: TSRandomWallpaperBannerCell
class TSRandomWallpaperBannerCell: TSBaseCollectionCell , ComponentView {
    
    var component:CollectionViewComponent?
    lazy var bannerImageBgView: UIImageView = {
        return UIImageView.createImageView(imageName: "random_guided_top_bg",corner: 16)
    }()
    
    lazy var bannerImageTextView: UIImageView = {
        return UIImageView.createImageView(imageName: "random_guided_top_text")
    }()
    
    
    lazy var closeBtn: UIExpandedTouchButton = {
        let btn = UIExpandedTouchButton()
        btn.setUpButton(image: UIImage(named:"close_gary")) { [weak self]  in
            guard let self = self else { return }
        
            if let component = self.component {
                if let itemActionHandler = component.itemActionHandler {
                    itemActionHandler(self, IndexPath(row: 0, section: 0))
                }
            }
        }
        return btn
    }()
    
    static let reuseIdentifier = "TSHomeCyclePagerViewCell"
    override func creatUI() {
        bgContentView.addSubview(bannerImageBgView)
        bannerImageBgView.snp.makeConstraints { make in
            make.leading.equalTo(0)
            make.top.equalTo(0)
            make.trailing.equalTo(0)
            make.bottom.equalTo(0)
        }
        
        bgContentView.addSubview(bannerImageTextView)
        bannerImageTextView.snp.makeConstraints { make in
            make.leading.equalTo(14)
            make.centerY.equalToSuperview()
            make.width.equalTo(200)
            make.height.equalTo(68)
        }
        
        bgContentView.addSubview(closeBtn)
        closeBtn.snp.makeConstraints { make in
            make.top.equalTo(8)
            make.trailing.equalTo(-8)
            make.width.equalTo(16)
            make.height.equalTo(16)
        }
    }
    
    func renderView(with object: Any?, component: CollectionViewComponent, attributes: [String : Any]?) {
        self.component = component
    }
}


class TSRandomWallpaperHeaderView: UICollectionReusableView , ComponentView{
    func renderView(with object: Any?, component: CollectionViewComponent, attributes: [String : Any]?) {
      
    }
}
