-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathDescriptionLabel.swift
87 lines (72 loc) · 2.39 KB
/
DescriptionLabel.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// FirewallDescriptionLabel.swift
// Lockdown
//
// Created by Aliaksandr Dvoineu on 18.04.23.
// Copyright © 2023 Confirmed Inc. All rights reserved.
//
import UIKit
struct DescriptionLabelViewModel {
let text: String
}
final class DescriptionLabel: UIView {
// MARK: - Properties
lazy var lockImage: UIImageView = {
let image = UIImageView()
image.image = UIImage(named: "icn_lock")
image.setContentHuggingPriority(.required, for: .horizontal)
image.setContentCompressionResistancePriority(.required, for: .horizontal)
image.contentMode = .left
image.layer.masksToBounds = true
return image
}()
lazy var checkmarkImage: UIImageView = {
let image = UIImageView()
image.image = UIImage(named: "icn_checkmark")
image.setContentHuggingPriority(.required, for: .horizontal)
image.setContentCompressionResistancePriority(.required, for: .horizontal)
image.contentMode = .left
image.layer.masksToBounds = true
image.isHidden = true
return image
}()
private lazy var descriptionLabel: UILabel = {
let label = UILabel()
label.textColor = .label
label.font = fontMedium15
label.textAlignment = .left
label.numberOfLines = 0
return label
}()
private lazy var stackView: UIStackView = {
let stackView = UIStackView()
stackView.addArrangedSubview(lockImage)
stackView.addArrangedSubview(checkmarkImage)
stackView.addArrangedSubview(descriptionLabel)
stackView.axis = .horizontal
stackView.distribution = .fill
stackView.alignment = .center
stackView.spacing = 12
return stackView
}()
// MARK: - Initializer
override init(frame: CGRect) {
super.init(frame: frame)
configureUI()
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Functions
private func configureUI() {
addSubview(stackView)
stackView.anchors.top.pin()
stackView.anchors.bottom.pin()
stackView.anchors.leading.pin()
stackView.anchors.trailing.pin()
}
func configure(with model: DescriptionLabelViewModel) {
descriptionLabel.text = model.text
}
}