diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-07-27 14:34:43 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-07-27 14:34:43 +0200 |
| commit | 5397cebfef71e3bb133e2cb1d84d61dce8db49fd (patch) | |
| tree | 7a1f518765dc3846c37197640050a1f1f6e535a7 /ios/MullvadVPN | |
| parent | c568d2a89c2ecbfd11843ed500ff1e283dd1eb7e (diff) | |
| parent | 2857f74cd082d5748115c2f1ee31ee7c52545ca1 (diff) | |
| download | mullvadvpn-5397cebfef71e3bb133e2cb1d84d61dce8db49fd.tar.xz mullvadvpn-5397cebfef71e3bb133e2cb1d84d61dce8db49fd.zip | |
Merge branch 'add-constraint-priority-helper'
Diffstat (limited to 'ios/MullvadVPN')
| -rw-r--r-- | ios/MullvadVPN/ConnectContentView.swift | 7 | ||||
| -rw-r--r-- | ios/MullvadVPN/NSLayoutConstraint+Helpers.swift | 16 | ||||
| -rw-r--r-- | ios/MullvadVPN/SettingsStaticTextFooterView.swift | 6 |
3 files changed, 21 insertions, 8 deletions
diff --git a/ios/MullvadVPN/ConnectContentView.swift b/ios/MullvadVPN/ConnectContentView.swift index 426f499c75..01b22f18d9 100644 --- a/ios/MullvadVPN/ConnectContentView.swift +++ b/ios/MullvadVPN/ConnectContentView.swift @@ -198,12 +198,11 @@ class ConnectContentView: UIView { case .pad: // Max container width is 70% width of iPad in portrait mode let maxWidth = min(UIScreen.main.nativeBounds.width * 0.7, UIMetrics.maximumSplitViewContentContainerWidth) - let containerWidthConstraint = containerView.widthAnchor.constraint(equalToConstant: maxWidth) - containerWidthConstraint.priority = .defaultHigh - layoutConstraints.append(contentsOf:[ + layoutConstraints.append(contentsOf: [ containerView.trailingAnchor.constraint(lessThanOrEqualTo: layoutMarginsGuide.trailingAnchor), - containerWidthConstraint + containerView.widthAnchor.constraint(equalToConstant: maxWidth) + .withPriority(.defaultHigh) ]) case .phone: diff --git a/ios/MullvadVPN/NSLayoutConstraint+Helpers.swift b/ios/MullvadVPN/NSLayoutConstraint+Helpers.swift new file mode 100644 index 0000000000..3a41101a96 --- /dev/null +++ b/ios/MullvadVPN/NSLayoutConstraint+Helpers.swift @@ -0,0 +1,16 @@ +// +// NSLayoutConstraint+Helpers.swift +// MullvadVPN +// +// Created by pronebird on 21/07/2022. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. +// + +import UIKit + +extension NSLayoutConstraint { + func withPriority(_ priority: UILayoutPriority) -> Self { + self.priority = priority + return self + } +} diff --git a/ios/MullvadVPN/SettingsStaticTextFooterView.swift b/ios/MullvadVPN/SettingsStaticTextFooterView.swift index 95fd211602..7e5619fb4d 100644 --- a/ios/MullvadVPN/SettingsStaticTextFooterView.swift +++ b/ios/MullvadVPN/SettingsStaticTextFooterView.swift @@ -24,14 +24,12 @@ class SettingsStaticTextFooterView: UITableViewHeaderFooterView { contentView.layoutMargins = UIMetrics.settingsCellLayoutMargins contentView.addSubview(titleLabel) - let bottomConstraint = titleLabel.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor) - bottomConstraint.priority = .defaultLow - contentView.addConstraints([ titleLabel.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor), titleLabel.leadingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.leadingAnchor), titleLabel.trailingAnchor.constraint(equalTo: contentView.layoutMarginsGuide.trailingAnchor), - bottomConstraint + titleLabel.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor) + .withPriority(.defaultLow) ]) } |
