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

import UIKit

class HomeTableViewCell: UITableViewCell {
    
    static let id = "HomeTableViewCell-ID"
    
    var containerView: UIView = {
        var obj = UIView()
        obj.layer.cornerRadius = 15
        obj.layer.borderWidth = 1
        obj.layer.borderColor = UIColor(red: 0.89, green: 0.918, blue: 0.918, alpha: 1).cgColor
        return obj
    }()
    var leftStatusImage: UIImageView = {
        var obj = UIImageView()
        obj.image = UIImage(named: "LeftBlue")
        obj.contentMode = .scaleAspectFill
        return obj
    }()
    var doorNameLabel: UILabel = {
        var obj = UILabel()
        obj.font = .skModernist(type: .bold, ofSize: 16)
        obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1)
        obj.text = "Front Door"
        return obj
    }()
    var doorLocationLabel: UILabel = {
        var obj = UILabel()
        obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1)
        obj.font = .skModernist(type: .regular, ofSize: 14)
        obj.text = "Home"
        return obj
    }()
    var lockStatusLabel: UILabel = {
        var obj = UILabel()
        obj.textColor = UIColor(red: 0, green: 0.267, blue: 0.545, alpha: 1)
        obj.font = .skModernist(type: .bold, ofSize: 15)
        obj.text = "Locked"
        return obj
    }()
    var rightStatusImage: UIImageView = {
        var obj = UIImageView()
        obj.image = UIImage(named: "RightBlue")
        return obj
    }()
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        layout()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func layout() {
        selectionStyle = .none
        addSubview(containerView)
        containerView.addSubview(leftStatusImage)
        containerView.addSubview(doorNameLabel)
        containerView.addSubview(doorLocationLabel)
        containerView.addSubview(lockStatusLabel)
        containerView.addSubview(rightStatusImage)
        
        containerView.snp.makeConstraints {
            $0.leading.trailing.equalToSuperview()
            $0.bottom.equalToSuperview().offset(-8)
            $0.top.equalToSuperview().offset(8)
        }
        leftStatusImage.snp.makeConstraints {
            $0.top.equalTo(containerView.snp.top).offset(19)
            $0.leading.equalTo(containerView.snp.leading).offset(23)
            $0.height.width.equalTo(41)
        }
        doorNameLabel.snp.makeConstraints {
            $0.top.equalTo(snp.top).offset(22)
            $0.leading.equalTo(leftStatusImage.snp.trailing).offset(14)
        }
        doorLocationLabel.snp.makeConstraints {
            $0.top.equalTo(doorNameLabel.snp.bottom)
            $0.leading.equalTo(doorNameLabel.snp.leading)
        }
        lockStatusLabel.snp.makeConstraints {
            $0.bottom.equalTo(snp.bottom).offset(-15)
            $0.centerX.equalTo(snp.centerX)
        }
        rightStatusImage.snp.makeConstraints {
            $0.trailing.equalTo(snp.trailing).offset(-16)
            $0.top.equalTo(snp.top).offset(19)
        }
    }
//    func configureWithItem(_ item: DoorsModel) {
        
//        doorTypeLabel.text = item.purpose
//        doorLocationLabel.text = item.type
//        configureStatus(status: item.lockStatus)
//        rightStatusImageView.isHidden = false
//    }
}