diff options
| author | mojganii <mojgan.jelodar@mullvad.net> | 2025-08-25 16:37:58 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-08-26 08:36:44 +0200 |
| commit | 9c54c09a18d5aeb80feb92b30a99dfb559fa89dc (patch) | |
| tree | e941433e413e5a4cb233bfdca3645a31163637ac /ios | |
| parent | 555b67f38df0010c69f25d99967b1b3783aefccc (diff) | |
| download | mullvadvpn-9c54c09a18d5aeb80feb92b30a99dfb559fa89dc.tar.xz mullvadvpn-9c54c09a18d5aeb80feb92b30a99dfb559fa89dc.zip | |
Fix dynamic size issues
Diffstat (limited to 'ios')
7 files changed, 39 insertions, 32 deletions
diff --git a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Cells/ListCellContentView.swift b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Cells/ListCellContentView.swift index d47c9c2221..4880286ef3 100644 --- a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Cells/ListCellContentView.swift +++ b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Cells/ListCellContentView.swift @@ -38,7 +38,7 @@ class ListCellContentView: UIView, UIContentView, UITextFieldDelegate { init(configuration: ListCellContentConfiguration) { actualConfiguration = configuration - super.init(frame: CGRect(x: 0, y: 0, width: 100, height: 0)) + super.init(frame: .zero) configureSubviews() addSubviews() @@ -75,8 +75,6 @@ class ListCellContentView: UIView, UIContentView, UITextFieldDelegate { secondaryTextLabel.textColor = textProperties.color secondaryTextLabel.numberOfLines = 0 secondaryTextLabel.text = actualConfiguration.secondaryText - secondaryTextLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) - secondaryTextLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) } private func configureTertiaryTextLabel() { @@ -98,9 +96,14 @@ class ListCellContentView: UIView, UIContentView, UITextFieldDelegate { let leadingTextContainer = UIStackView(arrangedSubviews: [textLabel, tertiaryTextLabel]) leadingTextContainer.axis = .vertical + leadingTextContainer.setContentHuggingPriority(.defaultLow, for: .horizontal) + leadingTextContainer.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal) + + secondaryTextLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) + secondaryTextLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) + addConstrainedSubviews([leadingTextContainer, secondaryTextLabel]) { leadingTextContainer.pinEdgesToSuperviewMargins(.all().excluding(.trailing)) - leadingTextContainer.centerYAnchor.constraint(equalTo: centerYAnchor) secondaryTextLabel.pinEdgesToSuperviewMargins(.all().excluding(.leading)) secondaryTextLabel.leadingAnchor.constraint( greaterThanOrEqualToSystemSpacingAfter: leadingTextContainer.trailingAnchor, diff --git a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Cells/SwitchCellContentView.swift b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Cells/SwitchCellContentView.swift index ea4e9df8b9..10c82b6910 100644 --- a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Cells/SwitchCellContentView.swift +++ b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Cells/SwitchCellContentView.swift @@ -70,6 +70,7 @@ class SwitchCellContentView: UIView, UIContentView, UITextFieldDelegate { textLabel.font = textProperties.font textLabel.adjustsFontForContentSizeCategory = true textLabel.textColor = textProperties.color + textLabel.numberOfLines = 0 textLabel.text = actualConfiguration.text } diff --git a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift index 88dc942e8b..cc15a2cadc 100644 --- a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift +++ b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/EditAccessMethodViewController.swift @@ -50,14 +50,22 @@ class EditAccessMethodViewController: UIViewController { tableView.setAccessibilityIdentifier(.editAccessMethodView) tableView.backgroundColor = .secondaryColor tableView.delegate = self - + tableView.sectionFooterHeight = UITableView.automaticDimension + tableView.estimatedSectionFooterHeight = 44 isModalInPresentation = true let title = createTitle() view.addConstrainedSubviews([title, tableView]) { - title.pinEdgesToSuperviewMargins(PinnableEdges([.leading(16), .trailing(16), .top(8)])) + title.pinEdgesToSuperviewMargins(PinnableEdges([.top(0)])) + title.pinEdgesToSuperview(PinnableEdges([ + .leading(UIMetrics.SettingsCell.defaultLayoutMargins.leading), + .trailing(UIMetrics.SettingsCell.defaultLayoutMargins.trailing), + ])) tableView.pinEdgesToSuperview(.all().excluding(.top)) - tableView.topAnchor.constraint(equalTo: title.bottomAnchor, constant: 16) + tableView.topAnchor.constraint( + equalTo: title.bottomAnchor, + constant: 0 + ) } configureDataSource() @@ -99,10 +107,6 @@ extension EditAccessMethodViewController: UITableViewDelegate { } } - func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - UITableView.automaticDimension - } - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { guard let sectionIdentifier = dataSource?.snapshot().sectionIdentifiers[section] else { return nil } switch sectionIdentifier { @@ -134,11 +138,13 @@ extension EditAccessMethodViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { guard let sectionIdentifier = dataSource?.snapshot().sectionIdentifiers[section] else { return 0 } - switch sectionIdentifier { + return switch sectionIdentifier { case .testingStatus: - return subject.value.testingStatus == .initial ? 0 : UITableView.automaticDimension + subject.value.testingStatus == .initial ? 0 : UITableView.automaticDimension + case .enableMethod: + UITableView.automaticDimension default: - return 0 + 0 } } @@ -170,20 +176,18 @@ extension EditAccessMethodViewController: UITableViewDelegate { guard let sectionIdentifier = dataSource?.snapshot().sectionIdentifiers[section] else { return 0 } let defaultMargin: CGFloat = 24 - switch sectionIdentifier { - case .enableMethod, .methodSettings: - return defaultMargin + return switch sectionIdentifier { case .testingStatus: switch subject.value.testingStatus { case .initial, .inProgress: - return 0 + 0 case .succeeded, .failed: - return defaultMargin + defaultMargin } case .cancelTest: - return subject.value.testingStatus == .inProgress ? defaultMargin : 0 - case .testMethod, .deleteMethod: - return UITableView.automaticDimension + subject.value.testingStatus == .inProgress ? defaultMargin : 0 + default: + (sectionIdentifier.sectionFooter != nil) ? UITableView.automaticDimension : defaultMargin } } diff --git a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/MethodSettings/MethodSettingsViewController.swift b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/MethodSettings/MethodSettingsViewController.swift index d6c3cedfd8..b66580800c 100644 --- a/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/MethodSettings/MethodSettingsViewController.swift +++ b/ios/MullvadVPN/Coordinators/Settings/APIAccess/Edit/MethodSettings/MethodSettingsViewController.swift @@ -138,11 +138,10 @@ class MethodSettingsViewController: UITableViewController { override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { guard let sectionIdentifier = dataSource?.snapshot().sectionIdentifiers[section] else { return 0 } - switch sectionIdentifier { - case .name, .protocol, .cancelTest, .testingStatus, .validationError: + case .protocol, .cancelTest, .testingStatus, .validationError: return 0 - case .proxyConfiguration: + case .proxyConfiguration, .name: return UITableView.automaticDimension } } diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift index ae058de96a..51775153c5 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift @@ -206,7 +206,6 @@ final class LocationViewControllerWrapper: UIViewController { segmentedControl.pinEdgesToSuperviewMargins(PinnableEdges([.top(0), .leading(8), .trailing(8)])) locationViewContainer.pinEdgesToSuperview(.all().excluding(.top)) - locationViewContainer.topAnchor.constraint(equalTo: segmentedControl.bottomAnchor, constant: 8) if settings.tunnelMultihopState.isEnabled { locationViewContainer.topAnchor.constraint(equalTo: segmentedControl.bottomAnchor, constant: 4) diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift b/ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift index 8aa6b0bccf..69878e50e0 100644 --- a/ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift +++ b/ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift @@ -18,7 +18,7 @@ class SettingsHeaderView: UITableViewHeaderFooterView { titleLabel.font = .mullvadSmallSemiBold titleLabel.adjustsFontForContentSizeCategory = true titleLabel.textColor = UIColor.Cell.titleTextColor - titleLabel.numberOfLines = 1 + titleLabel.numberOfLines = 0 return titleLabel }() diff --git a/ios/MullvadVPN/Views/SplitMainButton.swift b/ios/MullvadVPN/Views/SplitMainButton.swift index 45cb8928a6..a5364ffa74 100644 --- a/ios/MullvadVPN/Views/SplitMainButton.swift +++ b/ios/MullvadVPN/Views/SplitMainButton.swift @@ -14,7 +14,8 @@ struct SplitMainButton: View { var style: MainButtonStyle.Style var accessibilityId: AccessibilityIdentifier? - @State private var secondaryButtonWidth: CGFloat = 0 + @State private var secondaryButtonSize: CGSize = .zero + @State private var primaryButtonSize: CGSize = .zero var primaryAction: () -> Void var secondaryAction: () -> Void @@ -27,7 +28,8 @@ struct SplitMainButton: View { Text(text) Spacer() } - .padding(.trailing, -secondaryButtonWidth) + .padding(.leading, secondaryButtonSize.width) + .sizeOfView { primaryButtonSize = $0 } }) .ifLet(accessibilityId) { view, value in view.accessibilityIdentifier(value.asString) @@ -37,11 +39,10 @@ struct SplitMainButton: View { Image(image) .resizable() .scaledToFit() - .frame(width: 24, height: 24) .padding(10) + .frame(width: min(max(primaryButtonSize.height, 44), 60), height: max(primaryButtonSize.height, 44)) + .sizeOfView { secondaryButtonSize = $0 } }) - .aspectRatio(1, contentMode: .fit) - .sizeOfView { secondaryButtonWidth = $0.width } } .buttonStyle(MainButtonStyle(style)) .cornerRadius(UIMetrics.MainButton.cornerRadius) |
