//
//  KeyboardLoginTipView.swift
//  AiKeyboard
//
//  Created by Destiny on 2025/4/25.
//

import UIKit

class KeyboardLoginTipView: UIView {
    
    lazy var bgImageView: UIImageView = {
       
        let imageView = UIImageView()
        imageView.image = UIImage(named: "keyboard_bg")
        return imageView
    }()
    
    lazy var backBtn: UIButton = {
        
        let btn = UIButton()
        btn.setImage(UIImage(named: "keyboard_back_btn"), for: .normal)
        btn.layer.shadowOffset = CGSize(width: 0, height: 0)
        btn.layer.shadowColor = UIColor.hexStringColor(hexString: "#000000", alpha: 0.12).cgColor
        btn.layer.shadowRadius = 6.1
        return btn
    }()
    
    lazy var logoIcon: UIImageView = {
       
        let icon = UIImageView()
        icon.image = UIImage(named: "keyboard_logo")
        return icon
    }()
    
    lazy var loginLabel: UILabel = {
       
        let label = UILabel()
        label.text = "请登录后使用"
        label.font = .systemFont(ofSize: 20, weight: .medium)
        label.textColor = .hexStringColor(hexString: "#000000", alpha: 0.8)
        return label
    }()
    
    lazy var loginBtn: UIButton = {
       
        let btn = UIButton()
        btn.setTitle("去登录", for: .normal)
        btn.setTitleColor(.white, for: .normal)
        
        if let image = UIImage.gradient([UIColor.hexStringColor(hexString: "#7D46FC"), UIColor.hexStringColor(hexString: "#F5FAFF")], size: CGSize(width: 300, height: 48), locations: [0, 1], direction: .horizontal) {
            
            btn.backgroundColor = UIColor(patternImage: image)
        }
        
        return btn
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

extension KeyboardLoginTipView {
    
    func initUI() {
        
        self.addSubview(bgImageView)
        bgImageView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        self.addSubview(backBtn)
        backBtn.snp.makeConstraints { make in
            make.size.equalTo(CGSize(width: 32, height: 32))
            make.left.equalTo(12)
            make.top.equalTo(14)
        }
        
        self.addSubview(logoIcon)
        logoIcon.snp.makeConstraints { make in
            make.size.equalTo(CGSize(width: 83, height: 83))
            make.centerX.equalToSuperview()
            make.top.equalTo(70)
        }
        
        self.addSubview(loginLabel)
        loginLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(logoIcon.snp.bottom).offset(14)
        }
        
        self.addSubview(loginBtn)
        loginBtn.snp.makeConstraints { make in
            make.size.equalTo(CGSize(width: 300, height: 48))
            make.top.equalTo(loginLabel.snp.bottom).offset(29)
            make.centerX.equalToSuperview()
        }
    }
}
