//
//  FS_DetailsCollectionViewCell.swift
//  Funny_sounds
//
//  Created by 忆海16 on 2024/8/16.
//

import UIKit

class FS_DetailsCollectionViewCell: UICollectionViewCell {
    
    lazy var bgImageV:UIImageView = {
        let bgImageV = UIImageView()
        bgImageV.image = UIImage(named: "contentBg")
        bgImageV.contentMode = .scaleToFill
        
        return bgImageV
    }()
    
    lazy var conentImageV:UIImageView = {
        let conentImageV = UIImageView()
        conentImageV.image = UIImage(named: "collectionImageV")
        conentImageV.contentMode = .scaleAspectFit
        conentImageV.layer.cornerRadius = 30
        conentImageV.clipsToBounds = true
        conentImageV.contentMode = .scaleToFill
        return conentImageV
    }()
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
        
        contentView.backgroundColor = .clear
        
    }
    //    MARK: -设置布局
    func setUI(){
        self.addSubview(bgImageV)
        self.addSubview(conentImageV)
      
        
        bgImageV.snp.makeConstraints { make in
            make.width.height.equalTo(92)
            make.top.equalToSuperview().offset(5)
            make.centerX.equalToSuperview()
        }
        
        conentImageV.snp.makeConstraints { make in
            make.centerX.centerY.equalTo(bgImageV)
            make.height.width.equalTo(60)
        }
        

        
    }
    
    var model:AudioFile?{
        didSet{
            if let imageURL = URL(string: model?.preUrl ?? "") {
                conentImageV.sd_setImage(with: imageURL, placeholderImage: UIImage(named: "collectionImageV"))
                }
        
        }
    }
}
