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

import UIKit
import AttributedString


class YHPayMemberItemsView: UIView {
    lazy var sectionItem: YHPayMemberSectionItem = {
        let view = YHPayMemberSectionItem()
        return view
    }()
    
    lazy var contentItems: YHPayMemberContentItems = {
        let view = YHPayMemberContentItems()
        return view
    }()
    
    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = .separatorColor
        return view
    }()
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

private extension YHPayMemberItemsView {
    func setupUI() {
        updateUI() //for test hjl
    }
}


extension YHPayMemberItemsView {
    func updateUI(type : Int = 1) {
        removeSubviews()
        
        addSubview(sectionItem)
        sectionItem.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(YHPayMemberSectionItem.viewH)
        }
        sectionItem.updateUI(type: type)
        
        
        addSubview(contentItems)
        contentItems.snp.makeConstraints { make in
            make.top.equalTo(sectionItem.snp.bottom).offset(kMargin)
            make.left.equalToSuperview()
            make.right.equalToSuperview()
        }
        contentItems.updateUI(type: type)
        
        addSubview(lineView)
        lineView.snp.makeConstraints { make in
            make.top.equalTo(contentItems.snp.bottom).offset(20)
            make.left.right.equalToSuperview()
            make.height.equalTo(1)
            make.bottom.equalToSuperview()
        }
        if type == 3 {
            lineView.isHidden = true
        } else {
            lineView.isHidden = false
        }
    }
}
