Skip to content

Commit

Permalink
Fix voucher dialog margins
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Petersson committed Sep 13, 2023
1 parent c0ee7f5 commit 738e9bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ios/MullvadVPN/UI appearance/UIMetrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ final class RedeemVoucherContentView: UIView {
comment: ""
)
label.textColor = .white
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
return label
}()
Expand All @@ -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)
Expand Down Expand Up @@ -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
}()
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)]))
Expand All @@ -276,6 +271,7 @@ final class RedeemVoucherContentView: UIView {
constant: -UIMetrics.padding16
)
}

bottomsOfButtonsConstraint = buttonsStackView.pinEdgesToSuperview(PinnableEdges([.bottom(.zero)])).first
bottomsOfButtonsConstraint?.isActive = true
}
Expand Down

0 comments on commit 738e9bb

Please sign in to comment.