//
//  KeyboardGuideView.swift
//  AiKeyboard
//
//  Created by Destiny on 2025/5/13.
//

import UIKit

class KeyboardGuideView: UIView {
    
    lazy var bgView: UIView = {
       
        let view = UIView()
        view.backgroundColor = .hexStringColor(hexString: "#000000").withAlphaComponent(0.8)
        return view
    }()
    
    lazy var buttonImageView: UIImageView = {
       
        let imageView = UIImageView()
        imageView.image = UIImage(named: "keyboard_guide_button")
        
        imageView.isUserInteractionEnabled = true
        let tap = UITapGestureRecognizer(target: self, action: #selector(removeViewAction))
        imageView.addGestureRecognizer(tap)
        
        return imageView
    }()
    
    lazy var guideImageView: UIImageView = {
       
        let imageView = UIImageView()
        imageView.image = UIImage(named: "keyboard_guide_image")
        return imageView
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func removeViewAction() {
        
        self.removeFromSuperview()
    }
}

extension KeyboardGuideView {
    
    func initUI() {
        
        self.addSubview(bgView)
        bgView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        self.bgView.addSubview(guideImageView)
        guideImageView.snp.makeConstraints { make in
            make.size.equalTo(CGSize(width: 180, height: 150))
            make.right.equalTo(-12)
            make.top.equalTo(12)
        }
        
        let left = KeyboardHelpView.UX.cellWidth + 24
        self.bgView.addSubview(buttonImageView)
        buttonImageView.snp.makeConstraints { make in
            make.size.equalTo(CGSize(width: 88, height: 46))
            make.top.equalTo(110)
            make.left.equalTo(left)
        }
    }
}
