//
//  DiscoverBanner.swift

//
//  Created by Leon on 2025/9/9.
//

class DiscoverBanner:UIView{
    
    var adBlock:UIView!
    var imageView: UIImageView!
    var titleLabel: UILabel!
    var topButton: UIButton!
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupViews() {
        adBlock = {
            let v = UIView()
            v.cornerRadius = 16
            addSubview(v)
            v.snp.makeConstraints { make in
                make.leading.equalToSuperview().offset(CGFloat.lrs)
                make.trailing.equalToSuperview().offset(-CGFloat.lrs)
                make.top.bottom.equalToSuperview()
                make.height.equalTo(v.snp.width).multipliedBy(147.0/345.0)
            }
            return v
        }()
        
        imageView = {
            let v = UIImageView()
            v.contentMode = .scaleAspectFill
            v.clipsToBounds = true
            v.image = UIImage(named: "discover_banner_ad")
            adBlock.addSubview(v)
            v.snp.makeConstraints { make in
                make.edges.equalToSuperview()
            }
            return v
        }()
        
        titleLabel = {
            let v = UILabel()
            v.font = .t.ttm
            v.textColor = .text
            v.numberOfLines = 0
            adBlock.addSubview(v)
            v.snp.makeConstraints { make in
                make.leading.equalToSuperview().offset(16)
                make.trailing.equalToSuperview().offset(-16)
                make.bottom.equalToSuperview().offset(-16)
            }
            return v
        }()

        topButton = {
            let v = UIButton()
            adBlock.addSubview(v)
            v.snp.makeConstraints { make in
                make.edges.equalToSuperview()
            }
            return v
        }()

        //titleLabel.text = "Dialy Free Crush Coin"
    }
}
