summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-10-05 15:04:28 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-11-03 13:30:51 +0100
commitfbd72c1c064047d8d1f988c79890c49f926aab95 (patch)
tree6e9d44b3aa86744ea9dcc45d883e65df0cbb1187
parent8e24d1b1c03f1b6e8ffef80771b7d9f7da95fda1 (diff)
downloadmullvadvpn-fbd72c1c064047d8d1f988c79890c49f926aab95.tar.xz
mullvadvpn-fbd72c1c064047d8d1f988c79890c49f926aab95.zip
SettingsCell: set layout margins
-rw-r--r--ios/MullvadVPN/SettingsCell.swift21
-rw-r--r--ios/MullvadVPN/UIMetrics.swift3
2 files changed, 19 insertions, 5 deletions
diff --git a/ios/MullvadVPN/SettingsCell.swift b/ios/MullvadVPN/SettingsCell.swift
index b8d46fe148..1d147242bf 100644
--- a/ios/MullvadVPN/SettingsCell.swift
+++ b/ios/MullvadVPN/SettingsCell.swift
@@ -13,17 +13,12 @@ class SettingsCell: BasicTableViewCell {
let titleLabel = UILabel()
let detailTitleLabel = UILabel()
- private let preferredMargins = UIEdgeInsets(top: 16, left: 24, bottom: 16, right: 12)
- private var appDidBecomeActiveObserver: NSObjectProtocol?
-
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
tintColor = .white
backgroundView?.backgroundColor = UIColor.Cell.backgroundColor
selectedBackgroundView?.backgroundColor = UIColor.Cell.selectedAltBackgroundColor
-
- contentView.layoutMargins = preferredMargins
separatorInset = .zero
titleLabel.translatesAutoresizingMaskIntoConstraints = false
@@ -43,6 +38,8 @@ class SettingsCell: BasicTableViewCell {
contentView.addSubview(titleLabel)
contentView.addSubview(detailTitleLabel)
+ setLayoutMargins()
+
NSLayoutConstraint.activate([
titleLabel.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor),
titleLabel.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
@@ -62,6 +59,12 @@ class SettingsCell: BasicTableViewCell {
fatalError("init(coder:) has not been implemented")
}
+ override func prepareForReuse() {
+ super.prepareForReuse()
+
+ setLayoutMargins()
+ }
+
override func didAddSubview(_ subview: UIView) {
super.didAddSubview(subview)
@@ -83,6 +86,14 @@ class SettingsCell: BasicTableViewCell {
updateDisclosureViewTintColor()
}
+ private func setLayoutMargins() {
+ // Set layout margins for standard acceessories added into the cell (reorder control, etc..)
+ layoutMargins = UIMetrics.settingsCellLayoutMargins
+
+ // Set layout margins for cell content
+ contentView.layoutMargins = UIMetrics.settingsCellLayoutMargins
+ }
+
/// For some reason the `tintColor` is not applied to standard accessory views.
/// Fix this by looking for the accessory button and changing the image rendering mode
private func updateDisclosureViewTintColor() {
diff --git a/ios/MullvadVPN/UIMetrics.swift b/ios/MullvadVPN/UIMetrics.swift
index 51d9a36369..1ecfb8c4c1 100644
--- a/ios/MullvadVPN/UIMetrics.swift
+++ b/ios/MullvadVPN/UIMetrics.swift
@@ -15,6 +15,9 @@ extension UIMetrics {
/// Common layout margins for content presentation
static var contentLayoutMargins = UIEdgeInsets(top: 24, left: 24, bottom: 24, right: 24)
+ /// Common layout margins for settings cell presentation
+ static var settingsCellLayoutMargins = UIEdgeInsets(top: 16, left: 24, bottom: 16, right: 12)
+
/// Common layout margins for location cell presentation
static var selectLocationCellLayoutMargins = UIEdgeInsets(top: 16, left: 28, bottom: 16, right: 12)