//
//  SpeakEleLessionView.swift
//  SpeakEasyLearnEnglish
//
//  Created by mac on 2025/7/15.
//

import UIKit

enum buttonColorType : String {
    case red = "sp-home-red"
    case blue = "sp-home-blue"
    case yellow = "sp-home-xyellow"
    case green = "sp-home-green"
    case gray = "sp-home-gray"
    case orange = "sp-home-orange"
}

class SpeakEleLessionView: UIView {

    lazy var button: UIButton = {
       let button = UIButton.init(type: .custom)
      
       return button
   }()
    
    lazy var backView: UIView = {
       let bView = UIView()
        bView.backgroundColor = .white
       return bView
   }()
    
    lazy var nameLb: UILabel = {
       let nlb = UILabel()
        nlb.font =  UIFont.montserrat(.medium ,size: 14)
        nlb.textColor = .black
        nlb.text = "Music Prefences"
        nlb.numberOfLines = 0
        nlb.textAlignment = .center
       return nlb
   }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
   
        self.isUserInteractionEnabled = true
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setColor(type: Int) {
        let colorArr: [buttonColorType] = [.blue,.orange,.green,.yellow,.red,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray,.gray]
        button.setImage(UIImage(named: colorArr[type].rawValue), for: .normal)
    }
    
   private func setupUI() {
       
       self.addSubview(backView)
       backView.addSubview(button)
       self.addSubview(nameLb)
       
       backView.snp.makeConstraints { make in
           make.width.height.equalTo(96)
           make.top.left.right.equalTo(0)
       }
       
       nameLb.snp.makeConstraints { make in
           make.top.equalTo(backView.snp.bottom).offset(5)
           make.left.right.equalTo(0)
       }
       
        button.snp.makeConstraints { make in
            make.top.equalTo(5)
            make.left.equalTo(6)
            make.right.equalTo(-6)
            make.bottom.equalTo(-8)
        }
       
       backView.corners = 48
       backView.borderWidth = 4
       backView.borderColor = UIColor.init(with: "#000000", alpha: 0.18)
    }

}
