ProfileView.swift 2.67 KB
//
//  ProfileView.swift
//  InterQR-Internship
//
//  Created by Дмитрий Тимофеев on 08.06.2022.
//

import UIKit
import SnapKit

class ProfileView: UIView {
    
    var profileImage: UIImageView = {
        var obj = UIImageView()
        obj.image = UIImage(named: "Profile")
        return obj
    }()
    var titleLabel: UILabel = {
        var obj = UILabel()
        obj.text = "Your display name"
        obj.font = .skModernist(type: .bold, ofSize: 16)
        obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1)
        return obj
    }()
    var descriptionLabel: UILabel = {
        var obj = UILabel()
        obj.text = "This name will be displayed everywhere"
        obj.font = .skModernist(type: .regular, ofSize: 14)
        obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1)
        return obj
    }()
    var displayNameLabel: UILabel = {
        var obj = UILabel()
        obj.text = "John Doe"
        obj.backgroundColor = UIColor(red: 0.971, green: 0.967, blue: 0.967, alpha: 1)
        obj.clipsToBounds = true
        obj.layer.cornerRadius = 15
        return obj
    }()
    var dividingLineView: UIView = {
        var view = UIView()
        view.backgroundColor = UIColor(red: 246/255, green: 246/255, blue: 246/255, alpha: 1)
        return view
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        layout()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func layout() {
        addSubview(profileImage)
        addSubview(titleLabel)
        addSubview(descriptionLabel)
        addSubview(displayNameLabel)
        addSubview(dividingLineView)
        
        profileImage.snp.makeConstraints {
            $0.top.equalTo(snp.top)
            $0.leading.equalTo(snp.leading).offset(32)
        }
        titleLabel.snp.makeConstraints {
            $0.top.equalTo(profileImage.snp.top)
            $0.leading.equalTo(profileImage.snp.trailing).offset(18)
        }
        descriptionLabel.snp.makeConstraints {
            $0.top.equalTo(titleLabel.snp.bottom).offset(5)
            $0.leading.equalTo(titleLabel.snp.leading)
        }
        displayNameLabel.snp.makeConstraints {
            $0.top.equalTo(descriptionLabel.snp.bottom).offset(20)
            $0.leading.equalTo(snp.leading).offset(66)
            $0.trailing.equalTo(snp.trailing).offset(-28)
            $0.height.equalTo(47)
        }
        dividingLineView.snp.makeConstraints {
            $0.leading.trailing.equalToSuperview()
            $0.height.equalTo(1)
            $0.top.equalTo(displayNameLabel.snp.bottom).offset(30)
        }
    }
}