Untitled

mail@pastecode.io avatar
unknown
swift
a year ago
3.0 kB
2
Indexable
Never
import UIKit
import SnapKit

class QuoteBriefPriceView: UIView {
    // MARK: - Properties
    private lazy var headerContainer: UIView = {
        let view = UIView()
        view.backgroundColor = .clear
        return view
    }()
    
    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 14, weight: .medium)
        label.text = "Дневной диапазон"
        return label
    }()
    
    private lazy var changePriceView: UIView = {
        let view = UIView()
        return view
    }()
    
    private lazy var changePriceChart: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor(white: 0.66666666669999997, alpha: 1)
        return view
    }()
    
    private lazy var bottomBorderView: UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    
    private lazy var middleBorderView: UIView = {
        let view = UIView()
        view.backgroundColor = .white
        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(headerContainer)
        addSubview(changePriceView)
        addSubview(bottomBorderView)
        changePriceView.addSubview(middleBorderView)
        changePriceView.addSubview(changePriceChart)
        headerContainer.addSubview(titleLabel)
        
        // Set up constraints using SnapKit
        headerContainer.snp.makeConstraints { make in
            make.leading.trailing.equalToSuperview()
            make.top.equalTo(safeAreaLayoutGuide.snp.top)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(12)
            make.top.equalToSuperview().offset(13)
            make.trailing.lessThanOrEqualToSuperview().offset(-12)
            make.height.equalTo(17)
        }
        
        changePriceView.snp.makeConstraints { make in
            make.leading.trailing.equalToSuperview()
            make.top.equalTo(headerContainer.snp.bottom)
            make.bottom.equalTo(bottomBorderView.snp.top)
        }
        
        middleBorderView.snp.makeConstraints { make in
            make.leading.trailing.equalToSuperview()
            make.top.equalToSuperview()
            make.height.equalTo(1)
        }
        
        changePriceChart.snp.makeConstraints { make in
            make.leading.trailing.equalToSuperview()
            make.top.equalTo(middleBorderView.snp.bottom)
            make.bottom.equalToSuperview()
        }
        
        bottomBorderView.snp.makeConstraints { make in
            make.leading.trailing.equalToSuperview()
            make.bottom.equalTo(safeAreaLayoutGuide.snp.bottom)
            make.height.equalTo(1)
        }
    }
}