diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2021-10-12 14:28:30 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2021-11-03 13:30:51 +0100 |
| commit | 6dff71ddfdce0427246b8a527739f594a5369b14 (patch) | |
| tree | 9a940f3b813d04fd314609c7227481fdf53928f1 | |
| parent | 55e7ac2525d86a0e708046d9eed9a6d29a322dc0 (diff) | |
| download | mullvadvpn-6dff71ddfdce0427246b8a527739f594a5369b14.tar.xz mullvadvpn-6dff71ddfdce0427246b8a527739f594a5369b14.zip | |
SelectLocationCell: indent cells using layout margins
| -rw-r--r-- | ios/MullvadVPN/SelectLocationCell.swift | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/ios/MullvadVPN/SelectLocationCell.swift b/ios/MullvadVPN/SelectLocationCell.swift index d297b719dd..1cfb71f45b 100644 --- a/ios/MullvadVPN/SelectLocationCell.swift +++ b/ios/MullvadVPN/SelectLocationCell.swift @@ -53,11 +53,10 @@ class SelectLocationCell: BasicTableViewCell { var didCollapseHandler: CollapseHandler? - private let preferredMargins = UIEdgeInsets(top: 16, left: 28, bottom: 16, right: 12) - override var indentationLevel: Int { didSet { updateBackgroundColor() + setLayoutMargins() } } @@ -71,17 +70,13 @@ class SelectLocationCell: BasicTableViewCell { fatalError("init(coder:) has not been implemented") } - override func layoutSubviews() { - super.layoutSubviews() + private func setLayoutMargins() { + let indentation = CGFloat(indentationLevel) * indentationWidth - let indentPoints = CGFloat(indentationLevel) * indentationWidth + var contentMargins = UIMetrics.selectLocationCellLayoutMargins + contentMargins.left += indentation - contentView.frame = CGRect( - x: indentPoints, - y: contentView.frame.origin.y, - width: contentView.frame.size.width - indentPoints, - height: contentView.frame.size.height - ) + contentView.layoutMargins = contentMargins } override func setHighlighted(_ highlighted: Bool, animated: Bool) { @@ -98,10 +93,9 @@ class SelectLocationCell: BasicTableViewCell { } private func setupCell() { - indentationWidth = 16 + indentationWidth = UIMetrics.cellIndentationWidth backgroundColor = .clear - contentView.layoutMargins = preferredMargins locationLabel.font = UIFont.systemFont(ofSize: 17) locationLabel.textColor = .white @@ -122,6 +116,7 @@ class SelectLocationCell: BasicTableViewCell { updateAccessibilityCustomActions() updateDisabled() updateBackgroundColor() + setLayoutMargins() NSLayoutConstraint.activate([ tickImageView.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor), |
