DisplayNameCell.swift 2.56 KB
//
//  DisplayNameCell.swift
//  InterQR-Internship
//
//  Created by Leyter on 09.06.2022.
//

import Foundation
import UIKit
class DisplayNameCell: UITableViewCell, Reusable {
    var settingsIcon: 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 displayNameTextField: UITextField = {
        var obj = UITextField()
        obj.text = "John Doe"
        obj.returnKeyType = .done
        obj.backgroundColor = UIColor(red: 0.971, green: 0.967, blue: 0.967, alpha: 1)
        obj.clipsToBounds = true
        obj.layer.cornerRadius = 15
        return obj
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setup()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setup()
    }
    
    private func setup() {
        selectionStyle = .none
        contentView.addSubview(settingsIcon)
        contentView.addSubview(titleLabel)
        contentView.addSubview(descriptionLabel)
        contentView.addSubview(displayNameTextField)
        
        settingsIcon.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.leading.equalTo(snp.leading).offset(32)
        }
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(settingsIcon.snp.top)
            make.leading.equalTo(settingsIcon.snp.trailing).offset(18)
        }
        descriptionLabel.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(5)
            make.leading.equalTo(titleLabel.snp.leading)
        }
        displayNameTextField.snp.makeConstraints { make in
            make.top.equalTo(descriptionLabel.snp.bottom).offset(20)
            make.leading.equalTo(snp.leading).offset(66)
            make.trailing.equalTo(snp.trailing).offset(-28)
            make.height.equalTo(47)
            make.bottom.equalToSuperview().offset(-30)
        }
        
    }
}