summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/SelectLocationHeaderView.swift
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-03-16 16:49:21 +0100
committerAndrej Mihajlov <and@mullvad.net>2021-03-22 16:33:31 +0100
commit666bee40dbdd786de267e40a647085176b267bdf (patch)
tree41dfe77a47c97aadb03b80dd932771d0ce6f06f2 /ios/MullvadVPN/SelectLocationHeaderView.swift
parent3f841a3245e91455769ea540dc0bfad11221452d (diff)
downloadmullvadvpn-666bee40dbdd786de267e40a647085176b267bdf.tar.xz
mullvadvpn-666bee40dbdd786de267e40a647085176b267bdf.zip
Add LocationDataSource
Diffstat (limited to 'ios/MullvadVPN/SelectLocationHeaderView.swift')
-rw-r--r--ios/MullvadVPN/SelectLocationHeaderView.swift45
1 files changed, 31 insertions, 14 deletions
diff --git a/ios/MullvadVPN/SelectLocationHeaderView.swift b/ios/MullvadVPN/SelectLocationHeaderView.swift
index d5b0268008..f6a977ab2d 100644
--- a/ios/MullvadVPN/SelectLocationHeaderView.swift
+++ b/ios/MullvadVPN/SelectLocationHeaderView.swift
@@ -8,29 +8,46 @@
import UIKit
-class SelectLocationHeaderView: UIView {
-
- let textLabel = UILabel()
-
- override init(frame: CGRect) {
- super.init(frame: frame)
-
- layoutMargins = UIEdgeInsets(top: 24, left: 24, bottom: 24, right: 24)
+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)
- addSubview(textLabel)
+ let bottomConstraint = textContentLabel.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor)
+ bottomConstraint.priority = UILayoutPriority(800)
NSLayoutConstraint.activate([
- textLabel.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
- textLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
- textLabel.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
- textLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor),
- textLabel.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
+ textContentLabel.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
+ textContentLabel.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor),
+ trailingConstraint,
+ bottomConstraint
])
}