//
//  YHScorePersonInfoCell.swift
//  galaxy
//
//  Created by davidhuangA on 2024/1/27.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//

import UIKit
import AttributedString

class YHScorePersonInfoCell: UITableViewCell {
    static let cellReuseIdentifier = "YHScorePersonInfoCell"
    
    //头像
    private lazy var headImagV : UIImageView = {
        let imageV = UIImageView(image: UIImage(named: "score_header_default"))
        imageV.contentMode = .scaleAspectFit
        return imageV
    }()
    
    //姓名
    private lazy var nameLable : UILabel = {
        let lable0 = UILabel(text: "DavidHuang")
        lable0.textColor = UIColor(hex: 0x222222)
        lable0.font = UIFont.PFSC_M(ofSize: 16)
        return lable0
    }()
    
    //电话号码
    private lazy var phoneLable : UILabel = {
        let lable0 = UILabel(text: "15818743775")
        lable0.textColor = UIColor(hex: 0x888F98)
        lable0.font = UIFont.PFSC_R(ofSize: 12)
        return lable0
    }()
    
    
    //综合得分
    private lazy var scoreLable : UILabel = {
        let lable0 = UILabel(text: "92 分")
        lable0.textColor = UIColor(hex: 0x3C86F8)
        lable0.font = UIFont.PFSC_B(ofSize: 43)
        lable0.textAlignment = .right
        return lable0
    }()
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

extension YHScorePersonInfoCell {
    func setupUI() {
        backgroundColor = .clear
        contentView.backgroundColor = .clear
        
        let lable0 = UILabel(text: "香港优才评分报告")
        lable0.textColor = .white
        lable0.font = UIFont.PFSC_B(ofSize: 24)
        contentView.addSubview(lable0)
        lable0.snp.makeConstraints { make in
            make.top.equalTo(32)
            make.left.equalTo(8)
            make.right.equalTo(-8)
            make.height.equalTo(34)
        }
        
        
        let lable1 = UILabel(text: "根据您填写的资料情况生成")
        lable1.textColor = UIColor(hex: 0xffffff,alpha: 0.8)
        lable1.font = UIFont.PFSC_R(ofSize: 12)
        contentView.addSubview(lable1)
        lable1.snp.makeConstraints { make in
            make.top.equalTo(lable0.snp.bottom).offset(6)
            make.left.equalTo(lable0.snp.left)
            make.right.equalTo(lable0.snp.right)
            make.height.equalTo(17)
        }
        
        
        let holdView = UIView()
        holdView.backgroundColor = .white
        holdView.layer.cornerRadius = 12
        holdView.clipsToBounds = true
        contentView.addSubview(holdView)
        holdView.snp.makeConstraints { make in
            make.top.equalTo(lable1.snp.bottom).offset(30)
            make.left.right.equalToSuperview()
            make.height.equalTo(89)
            make.bottom.equalToSuperview().offset(-14)
        }
        
        
        let bkgImageV = UIImageView(image: UIImage(named: "score_icon_bkg"))
        bkgImageV.contentMode = .scaleAspectFill
        holdView.addSubview(bkgImageV)
        bkgImageV.snp.makeConstraints { make in
            make.top.right.bottom.equalToSuperview()
            make.width.equalTo(178)
        }
        
        
        let interHoldView = UIView()
        interHoldView.layer.borderWidth = 1
        interHoldView.layer.borderColor = UIColor(red: 0.235, green: 0.525, blue: 0.973, alpha: 0.2).cgColor
        interHoldView.layer.cornerRadius = 10
        interHoldView.clipsToBounds = true
        holdView.addSubview(interHoldView)
        interHoldView.snp.makeConstraints { make in
            make.top.left.equalTo(4)
            make.right.bottom.equalTo(-4)
        }
        
        
        // 头像 名称  电话号码  得分
        holdView.addSubview(headImagV)
        headImagV.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(21)
            make.width.height.equalTo(42)
        }
        
        
        holdView.addSubview(nameLable)
        nameLable.snp.makeConstraints { make in
            make.top.equalTo(headImagV.snp.top)
            make.left.equalTo(headImagV.snp.right).offset(12)
            make.height.equalTo(24)
            make.width.equalTo(200)
        }
        
        
        holdView.addSubview(phoneLable)
        phoneLable.snp.makeConstraints { make in
            make.top.equalTo(nameLable.snp.bottom)
            make.left.equalTo(headImagV.snp.right).offset(12)
            make.height.equalTo(20)
            make.width.equalTo(200)
        }
        
        
        holdView.addSubview(scoreLable)
        scoreLable.snp.makeConstraints { make in
            make.top.equalTo(10)
            make.right.equalToSuperview().offset(-21)
            make.height.equalTo(50)
        }
        
        let a: ASAttributedString = .init("95", .font(UIFont.PFSC_R(ofSize: 43)),.foreground(UIColor(hex:0x3C86F8)))
        let b: ASAttributedString = .init("分", .font(UIFont.PFSC_R(ofSize: 12)),.foreground(UIColor(hex:0x3C86F8)))
        scoreLable.attributed.text = a + b
        
        
        
        
        let lable3 = UILabel(text: "综合得分")
        lable3.textColor = UIColor(hex: 0x888F98)
        lable3.font = UIFont.PFSC_R(ofSize: 12)
        lable3.textAlignment = .right
        contentView.addSubview(lable3)
        lable3.snp.makeConstraints { make in
            make.top.equalTo(scoreLable.snp.bottom).offset(-4)
            make.right.equalTo(scoreLable.snp.right)
            make.height.equalTo(20)
        }
        
    }
    
}
