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

import UIKit

class YHScoreTitleView: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    //固定高度
    static let viewH : CGFloat = 52.0
    
    private lazy var nameLable : UILabel = {
        let lable0 = UILabel(text: "年龄得分")
        lable0.textColor = UIColor(hex: 0x222222)
        lable0.font = UIFont.PingFangScM(ofSize: 17)
        return lable0
    }()
    
    
    private lazy var desLable : UILabel = {
        let lable0 = UILabel(text: "（最高30分）")
        lable0.textColor = UIColor(hex: 0x888F98)
        lable0.font = UIFont.PingFangScR(ofSize: 14)
        return lable0
    }()
    
    
    private lazy var bottomLine : UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(hex:0xF0F0F0)
        return view
    }()
}

private extension YHScoreTitleView {
    func setupUI() {
        addSubview(bottomLine)
        bottomLine.snp.makeConstraints { make in
            make.bottom.left.right.equalToSuperview()
            make.height.equalTo(0.5)
        }
        
        
        addSubview(nameLable)
        nameLable.snp.makeConstraints { make in
            make.top.left.equalToSuperview()
            make.bottom.equalTo(bottomLine.snp.top)
        }
        
        
        addSubview(desLable)
        desLable.snp.makeConstraints { make in
            make.centerY.equalTo(nameLable.snp.centerY)
            make.left.equalTo(nameLable.snp.right).offset(6)
        }
    }
}

extension YHScoreTitleView {
    func updateWith(_ name: String?,_ text : String?) {
        nameLable.text = name ?? "-"
        desLable.text = text ?? "-"
    }
}
