//
//  YHPayMemberSectionItem.swift
//  galaxy
//
//  Created by davidhuangA on 2024/8/19.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//

import UIKit

class YHPayMemberSectionItem: UIView {
    static let viewH : CGFloat = 22.0
    
    lazy var tagView: UIView = {
        let view = UIView()
        view.backgroundColor = .brandMainColor
        return view
    }()
    
    lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.PFSC_M(ofSize: 16)
        label.text = "张全蛋"
        return label
    }()
    
    lazy var detailLabel: UILabel = {
        let label = UILabel()
        label.numberOfLines = 0
        label.font = UIFont.PFSC_M(ofSize: 13)
        label.text = "已缴费"
        label.textColor = UIColor.mainTextColor50
        label.textAlignment = .right
        return label
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

private extension YHPayMemberSectionItem {
    func setupUI() {
        addSubview(tagView)
        addSubview(titleLabel)
        addSubview(detailLabel)
        
        tagView.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.centerY.equalToSuperview()
            make.height.equalTo(14)
            make.width.equalTo(3)
        }
        
        
        detailLabel.snp.makeConstraints { make in
            make.right.equalToSuperview()
            make.centerY.equalToSuperview()
            make.height.equalTo(20)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(tagView.snp.right).offset(6)
            make.centerY.equalToSuperview()
            make.right.equalTo(detailLabel.snp.left).offset(-kMargin)
            make.height.equalTo(20)
        }
    }
}


extension YHPayMemberSectionItem {
    func updateUI(type : Int) {
        var txt = "待缴费"
        var color : UIColor = UIColor.failColor
        if type == 1 {
            txt = "待缴费"
            color = .brandMainColor
        } else if type == 2 {
            txt = "已过期"
            color = .failColor
            
        } else if type == 3 {
            txt = "已缴费"
            color = .mainTextColor50
        }
        detailLabel.text = txt
        detailLabel.textColor = color
        
    }
}
