blob: f6a977ab2d88b3c32082872db2a1ca4d28578d31 (
plain)
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
|
//
// SelectLocationHeaderView.swift
// MullvadVPN
//
// Created by pronebird on 22/07/2020.
// Copyright © 2020 Mullvad VPN AB. All rights reserved.
//
import UIKit
class SelectLocationHeaderView: UITableViewHeaderFooterView {
lazy var textContentLabel: UILabel = {
let textLabel = UILabel()
textLabel.translatesAutoresizingMaskIntoConstraints = false
textLabel.font = UIFont.systemFont(ofSize: 17)
textLabel.textColor = UIColor(white: 1, alpha: 0.6)
textLabel.numberOfLines = 0
textLabel.text = NSLocalizedString("While connected, your real location is masked with a private and secure location in the selected region", comment: "")
return textLabel
}()
var topLayoutMarginAdjustmentForNavigationBarTitle: CGFloat = 0 {
didSet {
let value = UIMetrics.contentLayoutMargins.top - topLayoutMarginAdjustmentForNavigationBarTitle
contentView.layoutMargins.top = max(value, 0)
}
}
override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
layoutMargins = .zero
contentView.layoutMargins = UIMetrics.contentLayoutMargins
contentView.addSubview(textContentLabel)
backgroundView = UIView()
backgroundView?.backgroundColor = .secondaryColor
let trailingConstraint = textContentLabel.trailingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.trailingAnchor)
trailingConstraint.priority = UILayoutPriority(800)
let bottomConstraint = textContentLabel.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor)
bottomConstraint.priority = UILayoutPriority(800)
NSLayoutConstraint.activate([
textContentLabel.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
textContentLabel.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor),
trailingConstraint,
bottomConstraint
])
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
|