summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2022-07-26 13:44:16 +0200
committerAndrej Mihajlov <and@mullvad.net>2022-07-27 14:34:25 +0200
commit2857f74cd082d5748115c2f1ee31ee7c52545ca1 (patch)
tree7a1f518765dc3846c37197640050a1f1f6e535a7
parentc568d2a89c2ecbfd11843ed500ff1e283dd1eb7e (diff)
downloadmullvadvpn-2857f74cd082d5748115c2f1ee31ee7c52545ca1.tar.xz
mullvadvpn-2857f74cd082d5748115c2f1ee31ee7c52545ca1.zip
Add NSLayoutConstraint priority helper
-rw-r--r--ios/MullvadVPN.xcodeproj/project.pbxproj4
-rw-r--r--ios/MullvadVPN/ConnectContentView.swift7
-rw-r--r--ios/MullvadVPN/NSLayoutConstraint+Helpers.swift16
-rw-r--r--ios/MullvadVPN/SettingsStaticTextFooterView.swift6
4 files changed, 25 insertions, 8 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj
index 00ece54d46..fb9f67f90b 100644
--- a/ios/MullvadVPN.xcodeproj/project.pbxproj
+++ b/ios/MullvadVPN.xcodeproj/project.pbxproj
@@ -184,6 +184,7 @@
587C575326D2615F005EF767 /* PacketTunnelOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587C575226D2615F005EF767 /* PacketTunnelOptions.swift */; };
587C575426D2615F005EF767 /* PacketTunnelOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587C575226D2615F005EF767 /* PacketTunnelOptions.swift */; };
587CBFE322807F530028DED3 /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587CBFE222807F530028DED3 /* UIColor+Helpers.swift */; };
+ 587D9676288989DB00CD8F1C /* NSLayoutConstraint+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587D9675288989DB00CD8F1C /* NSLayoutConstraint+Helpers.swift */; };
587DCCEF287D84A500CE821E /* countries.geo.json in Resources */ = {isa = PBXBuildFile; fileRef = 587DCCEE287D84A500CE821E /* countries.geo.json */; };
587EB66A270EFACB00123C75 /* CharacterSet+IPAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587EB669270EFACB00123C75 /* CharacterSet+IPAddress.swift */; };
587EB67027143B6500123C75 /* DataSourceSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587EB66F27143B6500123C75 /* DataSourceSnapshot.swift */; };
@@ -479,6 +480,7 @@
587B7544266922BF00DEF7E9 /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
587C575226D2615F005EF767 /* PacketTunnelOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PacketTunnelOptions.swift; sourceTree = "<group>"; };
587CBFE222807F530028DED3 /* UIColor+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Helpers.swift"; sourceTree = "<group>"; };
+ 587D9675288989DB00CD8F1C /* NSLayoutConstraint+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSLayoutConstraint+Helpers.swift"; sourceTree = "<group>"; };
587DCCEE287D84A500CE821E /* countries.geo.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = countries.geo.json; sourceTree = "<group>"; };
587EB669270EFACB00123C75 /* CharacterSet+IPAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CharacterSet+IPAddress.swift"; sourceTree = "<group>"; };
587EB66F27143B6500123C75 /* DataSourceSnapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataSourceSnapshot.swift; sourceTree = "<group>"; };
@@ -919,6 +921,7 @@
587B7535266528A200DEF7E9 /* NotificationManager.swift */,
587B75422669034500DEF7E9 /* Notifications */,
584EBDBC2747C98F00A0C9FD /* NSAttributedString+Markdown.swift */,
+ 587D9675288989DB00CD8F1C /* NSLayoutConstraint+Helpers.swift */,
5871FB9F254C26BF0051A0A4 /* NSRegularExpression+IPAddress.swift */,
58CC40EE24A601900019D96E /* ObserverList.swift */,
580EE1FF24B3218800F9D8A1 /* Operations */,
@@ -1446,6 +1449,7 @@
580F8B8628197958002E0998 /* DNSSettings.swift in Sources */,
58FB865526E8BF3100F188BC /* AppStorePaymentManagerError.swift in Sources */,
58FD5BF42428C67600112C88 /* InAppPurchaseButton.swift in Sources */,
+ 587D9676288989DB00CD8F1C /* NSLayoutConstraint+Helpers.swift in Sources */,
580EE22424B3243100F9D8A1 /* AsyncBlockOperation.swift in Sources */,
58293FAE2510CA58005D0BB5 /* ProblemReportViewController.swift in Sources */,
58B9EB152489139B00095626 /* DisplayChainedError.swift in Sources */,
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)
])
}