diff options
| author | Jon Petersson <jon.petersson@mullvad.net> | 2026-01-08 16:02:36 +0100 |
|---|---|---|
| committer | Jon Petersson <jon.petersson@mullvad.net> | 2026-01-08 16:02:36 +0100 |
| commit | 7ba44e990e2c06e50f91a55ea4a326398b0b9e82 (patch) | |
| tree | ade1d51be7ce6241ed74e239fe02222bcda78cdd | |
| parent | 390dad5aeeb21be8771bf1666a6c65284bb782d6 (diff) | |
| parent | 2bea18a097ceca6e3768fd0ba0441b03a1c6239b (diff) | |
| download | mullvadvpn-7ba44e990e2c06e50f91a55ea4a326398b0b9e82.tar.xz mullvadvpn-7ba44e990e2c06e50f91a55ea4a326398b0b9e82.zip | |
Merge branch 'change-the-edit-button-in-dns-settings-to-be-a-button-ios-1431'
| -rw-r--r-- | ios/MullvadVPN/View controllers/VPNSettings/CustomDNSDataSource.swift | 6 | ||||
| -rw-r--r-- | ios/MullvadVPN/View controllers/VPNSettings/CustomDNSViewController.swift | 43 |
2 files changed, 41 insertions, 8 deletions
diff --git a/ios/MullvadVPN/View controllers/VPNSettings/CustomDNSDataSource.swift b/ios/MullvadVPN/View controllers/VPNSettings/CustomDNSDataSource.swift index 886f6016e5..80a2e3e5bd 100644 --- a/ios/MullvadVPN/View controllers/VPNSettings/CustomDNSDataSource.swift +++ b/ios/MullvadVPN/View controllers/VPNSettings/CustomDNSDataSource.swift @@ -301,7 +301,11 @@ final class CustomDNSDataSource: UITableViewDiffableDataSource< } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { - 0 + if snapshot().itemIdentifiers.contains(.dnsServerInfo) { + 0 + } else { + 16 + } } func tableView( diff --git a/ios/MullvadVPN/View controllers/VPNSettings/CustomDNSViewController.swift b/ios/MullvadVPN/View controllers/VPNSettings/CustomDNSViewController.swift index e651ee53c5..d9a4893325 100644 --- a/ios/MullvadVPN/View controllers/VPNSettings/CustomDNSViewController.swift +++ b/ios/MullvadVPN/View controllers/VPNSettings/CustomDNSViewController.swift @@ -13,6 +13,7 @@ class CustomDNSViewController: UITableViewController { private let interactor: VPNSettingsInteractor private var dataSource: CustomDNSDataSource? private let alertPresenter: AlertPresenter + private let editButton = AppButton(style: .default) override var preferredStatusBarStyle: UIStatusBarStyle { .lightContent @@ -39,17 +40,28 @@ class CustomDNSViewController: UITableViewController { tableView.estimatedRowHeight = 60 tableView.estimatedSectionHeaderHeight = tableView.estimatedRowHeight + let footerView = UIView( + frame: .init( + x: 0, + y: 0, + width: tableView.frame.width, + height: UIMetrics.Button.minimumTappableAreaSize.height + )) + footerView.addConstrainedSubviews([editButton]) { + editButton.pinEdgesToSuperview( + .init([ + .top(0), + .leading(UIMetrics.contentInsets.left), + .bottom(0), + .trailing(UIMetrics.contentInsets.right), + ])) + } + tableView.tableFooterView = footerView + dataSource = CustomDNSDataSource(tableView: tableView) dataSource?.delegate = self navigationItem.title = NSLocalizedString("DNS settings", comment: "") - if navigationItem.rightBarButtonItem != nil { - navigationItem.leftBarButtonItem = editButtonItem - navigationItem.leftBarButtonItem?.setAccessibilityIdentifier(.dnsSettingsEditButton) - } else { - navigationItem.rightBarButtonItem = editButtonItem - navigationItem.rightBarButtonItem?.setAccessibilityIdentifier(.dnsSettingsEditButton) - } interactor.tunnelSettingsDidChange = { [weak self] newSettings in self?.dataSource?.update(from: newSettings) @@ -61,6 +73,10 @@ class CustomDNSViewController: UITableViewController { origin: .zero, size: CGSize(width: 0, height: UIMetrics.TableView.emptyHeaderHeight) )) + + editButton.setAccessibilityIdentifier(.dnsSettingsEditButton) + editButton.addTarget(self, action: #selector(didPressEditButton), for: .touchUpInside) + setEditButtonTitle() } override func setEditing(_ editing: Bool, animated: Bool) { @@ -77,6 +93,19 @@ class CustomDNSViewController: UITableViewController { isModalInPresentation = editing } + @objc private func didPressEditButton() { + setEditing(!isEditing, animated: true) + setEditButtonTitle() + } + + private func setEditButtonTitle() { + if isEditing { + editButton.setTitle(NSLocalizedString("Done", comment: ""), for: .normal) + } else { + editButton.setTitle(NSLocalizedString("Edit", comment: ""), for: .normal) + } + } + private func showInfo(with message: NSAttributedString) { let presentation = AlertPresentation( id: "vpn-settings-content-blockers-alert", |
