Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.2 kB
0
Indexable
Never
import UIKit
import SnapKit

class HintBarHeaderView: UIView {
    // MARK: - Properties
    private lazy var backView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(red: 0.94901960784313721, green: 0.94901960784313721, blue: 0.96862745098039216, alpha: 1)
        return view
    }()
    
    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 17)
        label.text = "Bonds"
        return label
    }()
    
    private lazy var hintBar: HintBar = {
        let hintBar = HintBar()
        return hintBar
    }()
    
    private lazy var separatorView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(red: 0.94901960784313721, green: 0.94901960784313721, blue: 0.96862745098039216, alpha: 1)
        return view
    }()
    
    // MARK: - Initialization
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupUI()
    }
    
    // MARK: - UI Setup
    private func setupUI() {
        addSubview(backView)
        addSubview(titleLabel)
        addSubview(hintBar)
        addSubview(separatorView)
        
        // Set up constraints using SnapKit
        backView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(safeAreaLayoutGuide).offset(12.5)
            make.leading.equalTo(safeAreaLayoutGuide).offset(12)
            make.trailing.equalTo(safeAreaLayoutGuide).offset(-12)
            make.height.equalTo(20.5)
        }
        
        hintBar.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(6)
            make.leading.trailing.equalToSuperview()
            make.height.greaterThanOrEqualTo(32)
            make.height.equalTo(32).priority(.required)
        }
        
        separatorView.snp.makeConstraints { make in
            make.leading.trailing.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
    }
}