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

import UIKit

class NotificationsView: UIView {
    
    var notificationImage: UIImageView = {
        var obj = UIImageView()
        obj.image = UIImage(named: "Notification")
        return obj
    }()
    var titleLabel: UILabel = {
        var obj = UILabel()
        obj.text = "Do not disturb"
        obj.textColor = UIColor(red: 0.196, green: 0.216, blue: 0.333, alpha: 1)
        obj.font = .skModernist(type: .bold, ofSize: 16)
        return obj
    }()
    var descriptionLabel: UILabel = {
        var obj = UILabel()
        obj.text = "You will not be notified of any\ncalls for one day. Auto reset at\nmidnight"
        obj.textColor = UIColor(red: 0.725, green: 0.725, blue: 0.725, alpha: 1)
        obj.font = .skModernist(type: .regular, ofSize: 14)
        obj.numberOfLines = 3
        return obj
    }()
    var notificationSwitch: UISwitch = {
        var obj = UISwitch()
        obj.isOn = true
        obj.clipsToBounds = true
        return obj
    }()
    var volumeImage: UIImageView = {
        var obj = UIImageView()
        obj.image = UIImage(named: "Volume")
        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(notificationImage)
        addSubview(titleLabel)
        addSubview(descriptionLabel)
        addSubview(notificationSwitch)
        addSubview(volumeImage)
        addSubview(dividingLineView)
        
        notificationImage.snp.makeConstraints {
            $0.leading.equalTo(snp.leading).offset(31)
            $0.top.equalTo(snp.top).offset(38)
        }
        titleLabel.snp.makeConstraints {
            $0.leading.equalTo(notificationImage.snp.trailing).offset(17.5)
            $0.top.equalTo(snp.top).offset(38)
        }
        descriptionLabel.snp.makeConstraints {
            $0.top.equalTo(titleLabel.snp.bottom).offset(5)
            $0.leading.equalTo(titleLabel.snp.leading)
        }
        notificationSwitch.snp.makeConstraints {
            $0.top.equalTo(snp.top).offset(36)
            $0.trailing.equalTo(snp.trailing).offset(-28)
        }
        volumeImage.snp.makeConstraints {
            $0.leading.equalTo(snp.leading).offset(29.5)
            $0.top.equalTo(titleLabel.snp.bottom).offset(53)
        }
        dividingLineView.snp.makeConstraints {
            $0.height.equalTo(1)
            $0.top.equalTo(volumeImage.snp.bottom).offset(17)
            $0.leading.equalTo(snp.leading).offset(32)
            $0.trailing.equalTo(snp.trailing).offset(-32)
        }
    }
}