-
Notifications
You must be signed in to change notification settings - Fork 389
/
Copy pathIPOverrideStatusView.swift
58 lines (48 loc) · 1.57 KB
/
IPOverrideStatusView.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
//
// IPOverrideStatusView.swift
// MullvadVPN
//
// Created by Jon Petersson on 2024-01-17.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//
import UIKit
class IPOverrideStatusView: UIView {
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 15, weight: .bold)
label.textColor = .white
return label
}()
private lazy var statusIcon: UIImageView = {
return UIImageView()
}()
private lazy var descriptionLabel: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 12, weight: .semibold)
label.textColor = .white.withAlphaComponent(0.6)
label.numberOfLines = 0
return label
}()
init() {
super.init(frame: .zero)
let titleContainerView = UIStackView(arrangedSubviews: [titleLabel, statusIcon, UIView()])
titleContainerView.spacing = 6
let contentContainterView = UIStackView(arrangedSubviews: [
titleContainerView,
descriptionLabel,
])
contentContainterView.axis = .vertical
contentContainterView.spacing = 4
addConstrainedSubviews([contentContainterView]) {
contentContainterView.pinEdgesToSuperview()
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setStatus(_ status: IPOverrideStatus) {
titleLabel.text = status.title.uppercased()
statusIcon.image = status.icon
descriptionLabel.text = status.description
}
}