//
//  YHBasicInfoFillCell.swift
//  galaxy
//
//  Created by davidhuangA on 2024/2/3.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//

import UIKit

class YHBasicInfoFillCell: UITableViewCell {
    static let cellReuseIdentifier = "YHBasicInfoFillCell"
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        
        selectionStyle = .none
        
        updateUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    let view0 = YHBasicInfoFillView()
    let view1 = YHBasicInfoFillView()
    
    
    typealias Block = () -> ()
    var block: Block?
}

extension YHBasicInfoFillCell {
    func updateUI() {
        //主申请人
        let holdView1 = UIView()
        holdView1.backgroundColor = .white
        holdView1.layer.cornerRadius = kCornerRadius6
        holdView1.clipsToBounds = true
        contentView.addSubview(holdView1)
        holdView1.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.left.right.equalToSuperview()
            make.bottom.equalToSuperview()
        }
        do {
            let sessionView = YHPersonInfoSessionView()
            sessionView.updateTitle(title: "主申请人")
            holdView1.addSubview(sessionView)
            sessionView.snp.makeConstraints { make in
                make.top.equalToSuperview()
                make.right.equalToSuperview().offset(-18)
                make.left.equalToSuperview().offset(18)
                make.height.equalTo(YHPersonInfoSessionView.viewH)
            }
            
            holdView1.addSubview(view0)
            view0.snp.makeConstraints { make in
                make.top.equalTo(sessionView.snp.bottom)
                make.right.equalToSuperview().offset(-18)
                make.left.equalToSuperview().offset(18)
                
            }
            view0.block = {
                self.block?()
            }
            
            
            holdView1.addSubview(view1)
            view1.snp.makeConstraints { make in
                make.top.equalTo(view0.snp.bottom)
                make.right.equalToSuperview().offset(-18)
                make.left.equalToSuperview().offset(18)
                make.bottom.equalToSuperview()
            }
            view1.block = {
                self.block?()
            }
        }
        
    }
}
