diff options
| author | Andrew Bulhak <andrew.bulhak@mullvad.net> | 2025-09-05 12:02:10 +0200 |
|---|---|---|
| committer | Jon Petersson <jon.petersson@mullvad.net> | 2025-09-24 14:24:44 +0200 |
| commit | d342fc4aa3c8a9cbfce58bdaf7123ca9bd745ff3 (patch) | |
| tree | 04fd938f9509cfd15099fbc62caeb6b7adacd09f /ios/MullvadVPN | |
| parent | 19a1036d88636def3bd3f262effff27d2aa47d6f (diff) | |
| download | mullvadvpn-d342fc4aa3c8a9cbfce58bdaf7123ca9bd745ff3.tar.xz mullvadvpn-d342fc4aa3c8a9cbfce58bdaf7123ca9bd745ff3.zip | |
Fix margins in scrollable out-of-time and welcome views
Diffstat (limited to 'ios/MullvadVPN')
3 files changed, 94 insertions, 46 deletions
diff --git a/ios/MullvadVPN/View controllers/CreationAccount/Completed/SetupAccountCompletedContentView.swift b/ios/MullvadVPN/View controllers/CreationAccount/Completed/SetupAccountCompletedContentView.swift index a7bfb40d05..6db71b9b72 100644 --- a/ios/MullvadVPN/View controllers/CreationAccount/Completed/SetupAccountCompletedContentView.swift +++ b/ios/MullvadVPN/View controllers/CreationAccount/Completed/SetupAccountCompletedContentView.swift @@ -76,13 +76,14 @@ class SetupAccountCompletedContentView: UIView { return stackView }() + let scrollView = UIScrollView() + weak var delegate: SetupAccountCompletedContentViewDelegate? override init(frame: CGRect) { super.init(frame: frame) backgroundColor = .primaryColor - directionalLayoutMargins = UIMetrics.contentLayoutMargins backgroundColor = .secondaryColor configureUI() @@ -102,18 +103,35 @@ class SetupAccountCompletedContentView: UIView { buttonsStackView.addArrangedSubview(privacyButton) buttonsStackView.addArrangedSubview(startButton) - addSubview(textsStackView) - addSubview(buttonsStackView) - addConstraints() - } + scrollView.addConstrainedSubviews([textsStackView]) { + textsStackView.pinEdgesToSuperviewMargins(PinnableEdges([ + .leading(0), + .trailing(0), + ])) + + textsStackView.pinEdgesToSuperview(PinnableEdges([ + .top(0), + .bottom(0), + ])) + } + + addConstrainedSubviews([scrollView, buttonsStackView]) { + scrollView.pinEdgesToSuperviewMargins(PinnableEdges([ + .top(UIMetrics.contentLayoutMargins.top), + .leading(0), + .trailing(0), + ])) - private func addConstraints() { - addConstrainedSubviews([textsStackView, buttonsStackView]) { - textsStackView - .pinEdgesToSuperviewMargins(.all().excluding(.bottom)) + buttonsStackView.pinEdgesToSuperviewMargins(PinnableEdges([ + .leading(UIMetrics.padding8), + .trailing(UIMetrics.padding8), + .bottom(UIMetrics.contentLayoutMargins.bottom), + ])) - buttonsStackView - .pinEdgesToSuperviewMargins(.all().excluding(.top)) + buttonsStackView.topAnchor.constraint( + equalTo: scrollView.bottomAnchor, + constant: UIMetrics.contentLayoutMargins.top + ) } } diff --git a/ios/MullvadVPN/View controllers/CreationAccount/Welcome/WelcomeContentView.swift b/ios/MullvadVPN/View controllers/CreationAccount/Welcome/WelcomeContentView.swift index 9054febbc9..35f352cf54 100644 --- a/ios/MullvadVPN/View controllers/CreationAccount/Welcome/WelcomeContentView.swift +++ b/ios/MullvadVPN/View controllers/CreationAccount/Welcome/WelcomeContentView.swift @@ -61,6 +61,7 @@ final class WelcomeContentView: UIView, Sendable { button.adjustsImageSizeForAccessibilityContentSizeCategory = true button.tintColor = .white button.setContentHuggingPriority(.defaultHigh, for: .horizontal) + button.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) return button }() @@ -148,6 +149,8 @@ final class WelcomeContentView: UIView, Sendable { return stackView }() + private let scrollView = UIScrollView() + weak var delegate: WelcomeContentViewDelegate? var viewModel: WelcomeViewModel? { didSet { @@ -164,7 +167,6 @@ final class WelcomeContentView: UIView, Sendable { setAccessibilityIdentifier(.welcomeView) backgroundColor = .primaryColor - directionalLayoutMargins = UIMetrics.contentLayoutMargins backgroundColor = .secondaryColor configureUI() @@ -198,20 +200,41 @@ final class WelcomeContentView: UIView, Sendable { buttonsStackView.addArrangedSubview(purchaseButton) - addSubview(textsStackView) - addSubview(buttonsStackView) addConstraints() showCheckmark(false) } private func addConstraints() { - addConstrainedSubviews([textsStackView, buttonsStackView]) { - textsStackView - .pinEdgesToSuperviewMargins(.all().excluding(.bottom)) + scrollView.addConstrainedSubviews([textsStackView]) { + textsStackView.pinEdgesToSuperviewMargins(PinnableEdges([ + .leading(0), + .trailing(0), + ])) + + textsStackView.pinEdgesToSuperview(PinnableEdges([ + .top(0), + .bottom(0), + ])) + } - buttonsStackView - .pinEdgesToSuperviewMargins(.all().excluding(.top)) + addConstrainedSubviews([scrollView, buttonsStackView]) { + scrollView.pinEdgesToSuperviewMargins(PinnableEdges([ + .top(UIMetrics.contentLayoutMargins.top), + .leading(0), + .trailing(0), + ])) + + buttonsStackView.pinEdgesToSuperviewMargins(PinnableEdges([ + .leading(UIMetrics.padding8), + .trailing(UIMetrics.padding8), + .bottom(UIMetrics.contentLayoutMargins.bottom), + ])) + + buttonsStackView.topAnchor.constraint( + equalTo: scrollView.bottomAnchor, + constant: UIMetrics.contentLayoutMargins.top + ) } } diff --git a/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeContentView.swift b/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeContentView.swift index d169c65c08..b23784d4f6 100644 --- a/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeContentView.swift +++ b/ios/MullvadVPN/View controllers/OutOfTime/OutOfTimeContentView.swift @@ -22,6 +22,7 @@ class OutOfTimeContentView: UIView { label.font = .mullvadLarge label.adjustsFontForContentSizeCategory = true label.textColor = .white + label.numberOfLines = 0 return label }() @@ -36,7 +37,7 @@ class OutOfTimeContentView: UIView { lazy var disconnectButton: AppButton = { let button = AppButton(style: .danger) button.translatesAutoresizingMaskIntoConstraints = false - button.alpha = 0 + button.isHidden = true let localizedString = NSLocalizedString("Disconnect", comment: "") button.setTitle(localizedString, for: .normal) return button @@ -57,6 +58,8 @@ class OutOfTimeContentView: UIView { return button }() + private let scrollView = UIScrollView() + private lazy var topStackView: UIStackView = { let stackView = UIStackView(arrangedSubviews: [statusActivityView, titleLabel, bodyLabel]) stackView.translatesAutoresizingMaskIntoConstraints = false @@ -71,7 +74,8 @@ class OutOfTimeContentView: UIView { ) stackView.translatesAutoresizingMaskIntoConstraints = false stackView.axis = .vertical - stackView.spacing = UIMetrics.TableView.sectionSpacing + stackView.spacing = UIMetrics.interButtonSpacing + stackView.backgroundColor = .secondaryColor return stackView }() @@ -80,7 +84,6 @@ class OutOfTimeContentView: UIView { setAccessibilityIdentifier(.outOfTimeView) translatesAutoresizingMaskIntoConstraints = false backgroundColor = .secondaryColor - directionalLayoutMargins = UIMetrics.contentLayoutMargins setUpSubviews() } @@ -91,7 +94,7 @@ class OutOfTimeContentView: UIView { func enableDisconnectButton(_ enabled: Bool, animated: Bool) { disconnectButton.isEnabled = enabled UIView.animate(withDuration: animated ? 0.25 : 0) { - self.disconnectButton.alpha = enabled ? 1 : 0 + self.disconnectButton.isHidden = !enabled } } @@ -102,32 +105,36 @@ class OutOfTimeContentView: UIView { // MARK: - Private Functions func setUpSubviews() { - addSubview(topStackView) - addSubview(bottomStackView) - configureConstraints() - } + scrollView.addConstrainedSubviews([topStackView]) { + topStackView.pinEdgesToSuperviewMargins(PinnableEdges([ + .leading(0), + .trailing(0), + ])) - func configureConstraints() { - NSLayoutConstraint.activate([ - topStackView.centerYAnchor.constraint(equalTo: centerYAnchor, constant: -20), + topStackView.pinEdgesToSuperview(PinnableEdges([ + .top(0), + .bottom(0), + ])) + } + + addConstrainedSubviews([scrollView, bottomStackView]) { + scrollView.pinEdgesToSuperviewMargins(PinnableEdges([ + .top(UIMetrics.contentLayoutMargins.top), + .leading(0), + .trailing(0), + ])) - topStackView.leadingAnchor.constraint( - equalTo: layoutMarginsGuide.leadingAnchor - ), - topStackView.trailingAnchor.constraint( - equalTo: layoutMarginsGuide.trailingAnchor - ), + bottomStackView.pinEdgesToSuperviewMargins(PinnableEdges([ + .leading(UIMetrics.padding8), + .trailing(UIMetrics.padding8), + .bottom(UIMetrics.contentLayoutMargins.bottom), + ])) - bottomStackView.leadingAnchor.constraint( - equalTo: layoutMarginsGuide.leadingAnchor - ), - bottomStackView.trailingAnchor.constraint( - equalTo: layoutMarginsGuide.trailingAnchor - ), - bottomStackView.bottomAnchor.constraint( - equalTo: layoutMarginsGuide.bottomAnchor - ), - ]) + bottomStackView.topAnchor.constraint( + equalTo: scrollView.bottomAnchor, + constant: UIMetrics.contentLayoutMargins.top + ) + } } func setBodyLabelText(_ text: String) { |
