PickerViewCell.swift 2.01 KB
//
//  PickerView.swift
//  InterQR-Internship
//
//  Created by Дмитрий Тимофеев on 01.06.2022.
//

import UIKit

final class PickerView: UIView {
    
    private let iconView: UIImageView = {
        var obj = UIImageView()
        obj.contentMode = .scaleAspectFill
        obj.layer.cornerRadius = 10
        return obj
    }()
    private let label: UILabel = {
        var obj = UILabel()
        obj.textColor = UIColor(red: 50/255, green: 55/255, blue: 85/255, alpha: 1)
        obj.font = UIFont(name: SkModernistFontType.bold.rawValue, size: 15)
        return obj
    }()
    private let countryCode: UILabel = {
        var obj = UILabel()
        obj.textColor = UIColor(red: 50/255, green: 55/255, blue: 85/255, alpha: 1)
        obj.font = UIFont(name: SkModernistFontType.bold.rawValue, size: 15)
        return obj
    }()
    override init(frame: CGRect) {
        super.init(frame: frame)
        layout()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        layout()
    }
    
    private func layout() {
        addSubview(iconView)
        addSubview(label)
        addSubview(countryCode)
        
        iconView.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(25)
            make.centerY.equalTo(snp.centerY)
//            make.top.bottom.equalToSuperview()
            make.height.width.equalTo(20)
        }
        
        label.snp.makeConstraints { make in
            make.leading.equalTo(iconView.snp.trailing).offset(20)
            make.top.bottom.equalToSuperview()
        }
        
        countryCode.snp.makeConstraints { make in
            make.trailing.equalToSuperview().offset(-25)
            make.top.bottom.equalToSuperview()
        }
    }
    
    static func create(icon: UIImage, title: String, code: String) -> PickerView {
        let numberView = PickerView()
        numberView.iconView.image = icon
        numberView.label.text = title
        numberView.countryCode.text = code
        return numberView
    }
}