From 738e9bb5a8d1947ee54f51f3688a18c062bece93 Mon Sep 17 00:00:00 2001 From: Jon Petersson Date: Wed, 13 Sep 2023 14:20:50 +0200 Subject: [PATCH] Fix voucher dialog margins --- ios/MullvadVPN/UI appearance/UIMetrics.swift | 2 +- .../RedeemVoucher/RedeemVoucherContentView.swift | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ios/MullvadVPN/UI appearance/UIMetrics.swift b/ios/MullvadVPN/UI appearance/UIMetrics.swift index b257d5d46a8d..41b380336796 100644 --- a/ios/MullvadVPN/UI appearance/UIMetrics.swift +++ b/ios/MullvadVPN/UI appearance/UIMetrics.swift @@ -38,7 +38,7 @@ enum UIMetrics { enum SettingsRedeemVoucher { static let cornerRadius = 8.0 static let preferredContentSize = CGSize(width: 280, height: 260) - static let contentLayoutMargins = NSDirectionalEdgeInsets(top: 16, leading: 0, bottom: 16, trailing: 0) + static let contentLayoutMargins = NSDirectionalEdgeInsets(top: 16, leading: 16, bottom: 16, trailing: 16) } enum AccountDeletion { diff --git a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift index f5061d570d26..8e66ff446186 100644 --- a/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift +++ b/ios/MullvadVPN/View controllers/RedeemVoucher/RedeemVoucherContentView.swift @@ -40,7 +40,6 @@ final class RedeemVoucherContentView: UIView { comment: "" ) label.textColor = .white - label.translatesAutoresizingMaskIntoConstraints = false label.numberOfLines = 0 return label }() @@ -61,7 +60,6 @@ final class RedeemVoucherContentView: UIView { private let activityIndicator: SpinnerActivityIndicatorView = { let activityIndicator = SpinnerActivityIndicatorView(style: .medium) - activityIndicator.translatesAutoresizingMaskIntoConstraints = false activityIndicator.tintColor = .white activityIndicator.setContentHuggingPriority(.defaultHigh, for: .horizontal) activityIndicator.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) @@ -111,8 +109,6 @@ final class RedeemVoucherContentView: UIView { private lazy var statusStack: UIStackView = { let stackView = UIStackView(arrangedSubviews: [activityIndicator, statusLabel]) - stackView.translatesAutoresizingMaskIntoConstraints = false - stackView.axis = .horizontal stackView.spacing = UIMetrics.padding8 return stackView }() @@ -124,7 +120,6 @@ final class RedeemVoucherContentView: UIView { statusStack, logoutViewForAccountNumberIsEntered, ]) - stackView.translatesAutoresizingMaskIntoConstraints = false stackView.axis = .vertical stackView.setCustomSpacing(UIMetrics.padding16, after: titleLabel) stackView.setCustomSpacing(UIMetrics.padding8, after: textField) @@ -136,7 +131,6 @@ final class RedeemVoucherContentView: UIView { private lazy var buttonsStackView: UIStackView = { let stackView = UIStackView(arrangedSubviews: [redeemButton, cancelButton]) - stackView.translatesAutoresizingMaskIntoConstraints = false stackView.axis = .vertical stackView.spacing = UIMetrics.padding16 stackView.setContentCompressionResistancePriority(.required, for: .vertical) @@ -260,14 +254,15 @@ final class RedeemVoucherContentView: UIView { private func configureUI() { addConstrainedSubviews([scrollView]) { - scrollView.pinEdgesToSuperviewMargins() + scrollView.pinEdgesToSuperview(.all(UIMetrics.SettingsRedeemVoucher.contentLayoutMargins)) } scrollView.addConstrainedSubviews([contentHolderView]) { contentHolderView.pinEdgesToSuperview() - contentHolderView.widthAnchor.constraint(equalTo: scrollView.widthAnchor, multiplier: 1.0) - contentHolderView.heightAnchor.constraint(greaterThanOrEqualTo: scrollView.heightAnchor, multiplier: 1.0) + contentHolderView.widthAnchor.constraint(equalTo: scrollView.widthAnchor) + contentHolderView.heightAnchor.constraint(greaterThanOrEqualTo: scrollView.heightAnchor) } + contentHolderView.addConstrainedSubviews([voucherCodeStackView, buttonsStackView]) { voucherCodeStackView.pinEdgesToSuperview(.all().excluding(.bottom)) buttonsStackView.pinEdgesToSuperview(PinnableEdges([.leading(.zero), .trailing(.zero)])) @@ -276,6 +271,7 @@ final class RedeemVoucherContentView: UIView { constant: -UIMetrics.padding16 ) } + bottomsOfButtonsConstraint = buttonsStackView.pinEdgesToSuperview(PinnableEdges([.bottom(.zero)])).first bottomsOfButtonsConstraint?.isActive = true }