diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index b09c0452aa42..2aa72ee4fb53 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -2811,6 +2811,7 @@ 7A42DEC82A05164100B209BE /* SettingsInputCell.swift */, 58677711290976FB006F721F /* SettingsInteractor.swift */, 5867770F290975E8006F721F /* SettingsInteractorFactory.swift */, + F041BE4E2C983C2B0083EC28 /* SettingsPromptAlertItem.swift */, 58ACF64A26553C3F00ACE4B7 /* SettingsSwitchCell.swift */, 58CCA01122424D11004F3011 /* SettingsViewController.swift */, 7A27E3CA2CAE86170088BCFF /* SettingsViewModel.swift */, diff --git a/ios/MullvadVPN/Coordinators/LocationCoordinator.swift b/ios/MullvadVPN/Coordinators/LocationCoordinator.swift index de38e6c81112..76171ca47c4a 100644 --- a/ios/MullvadVPN/Coordinators/LocationCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/LocationCoordinator.swift @@ -64,7 +64,7 @@ class LocationCoordinator: Coordinator, Presentable, Presenting { customListRepository: customListRepository, constraints: tunnelManager.settings.relayConstraints, multihopEnabled: tunnelManager.settings.tunnelMultihopState.isEnabled, - daitaEnabled: tunnelManager.settings.daita.daitaState.isEnabled, + daitaSettings: tunnelManager.settings.daita, startContext: startContext ) locationViewControllerWrapper.delegate = self diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationViewController.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationViewController.swift index 587f5ab146f2..fb0ff50e5b04 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/LocationViewController.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationViewController.swift @@ -26,7 +26,7 @@ final class LocationViewController: UIViewController { private var relaysWithLocation: LocationRelays? private var filter = RelayFilter() private var selectedRelays: RelaySelection - private var daitaEnabled: Bool + private var shouldFilterDaita: Bool weak var delegate: LocationViewControllerDelegate? var customListRepository: CustomListRepositoryProtocol @@ -35,17 +35,17 @@ final class LocationViewController: UIViewController { } var filterViewShouldBeHidden: Bool { - !daitaEnabled && (filter.ownership == .any) && (filter.providers == .any) + !shouldFilterDaita && (filter.ownership == .any) && (filter.providers == .any) } init( customListRepository: CustomListRepositoryProtocol, selectedRelays: RelaySelection, - daitaEnabled: Bool = false + shouldFilterDaita: Bool ) { self.customListRepository = customListRepository self.selectedRelays = selectedRelays - self.daitaEnabled = daitaEnabled + self.shouldFilterDaita = shouldFilterDaita super.init(nibName: nil, bundle: nil) } @@ -154,7 +154,7 @@ final class LocationViewController: UIViewController { topContentView.addArrangedSubview(searchBar) filterView.isHidden = filterViewShouldBeHidden - filterView.setDaita(daitaEnabled) + filterView.setDaita(shouldFilterDaita) filterView.didUpdateFilter = { [weak self] in self?.delegate?.didUpdateFilter(filter: $0) diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift index 4f8147f74637..02f81942480c 100644 --- a/ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift +++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift @@ -52,7 +52,7 @@ final class LocationViewControllerWrapper: UIViewController { private var selectedExit: UserSelectedRelays? private let multihopEnabled: Bool private var multihopContext: MultihopContext = .exit - private let daitaEnabled: Bool + private let daitaSettings: DAITASettings weak var delegate: LocationViewControllerWrapperDelegate? @@ -60,11 +60,11 @@ final class LocationViewControllerWrapper: UIViewController { customListRepository: CustomListRepositoryProtocol, constraints: RelayConstraints, multihopEnabled: Bool, - daitaEnabled: Bool, + daitaSettings: DAITASettings, startContext: MultihopContext ) { self.multihopEnabled = multihopEnabled - self.daitaEnabled = daitaEnabled + self.daitaSettings = daitaSettings multihopContext = startContext selectedEntry = constraints.entryLocations.value @@ -73,13 +73,16 @@ final class LocationViewControllerWrapper: UIViewController { entryLocationViewController = LocationViewController( customListRepository: customListRepository, selectedRelays: RelaySelection(), - daitaEnabled: multihopEnabled && daitaEnabled + shouldFilterDaita: daitaSettings.daitaState.isEnabled + && daitaSettings.directOnlyState.isEnabled ) exitLocationViewController = LocationViewController( customListRepository: customListRepository, selectedRelays: RelaySelection(), - daitaEnabled: !multihopEnabled && daitaEnabled + shouldFilterDaita: !multihopEnabled + && daitaSettings.daitaState.isEnabled + && daitaSettings.directOnlyState.isEnabled ) super.init(nibName: nil, bundle: nil) @@ -109,7 +112,7 @@ final class LocationViewControllerWrapper: UIViewController { func setRelaysWithLocation(_ relaysWithLocation: LocationRelays, filter: RelayFilter) { var daitaFilteredRelays = relaysWithLocation - if daitaEnabled { + if daitaSettings.daitaState.isEnabled && daitaSettings.directOnlyState.isEnabled { daitaFilteredRelays.relays = relaysWithLocation.relays.filter { relay in relay.daita == true } diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift b/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift index eb9236bc5826..59219e620568 100644 --- a/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift +++ b/ios/MullvadVPN/View controllers/Settings/SettingsDataSource.swift @@ -25,11 +25,17 @@ final class SettingsDataSource: UITableViewDiffableDataSource UIView? { - nil + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + let sectionIdentifier = snapshot().sectionIdentifiers[section] + + return switch sectionIdentifier { + case .main: + 0 + case .daita, .version, .problemReport: + UITableView.automaticDimension + } } - func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - return UIMetrics.TableView.sectionSpacing + func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { + let sectionIdentifier = snapshot().sectionIdentifiers[section] + guard let sectionFooterText = sectionIdentifier.sectionFooter else { return nil } + + guard let headerView = tableView + .dequeueReusableView(withIdentifier: HeaderFooterReuseIdentifier.primary) + else { return nil } + + var contentConfiguration = UIListContentConfiguration.mullvadGroupedFooter(tableStyle: .plain) + contentConfiguration.text = sectionFooterText + + headerView.contentConfiguration = contentConfiguration +// headerView.directionalLayoutMargins = UIMetrics.SettingsCell.apiAccessInsetLayoutMargins + + return headerView } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { - 0 + let sectionIdentifier = snapshot().sectionIdentifiers[section] + + return switch sectionIdentifier { + case .daita: + UITableView.automaticDimension + case .main, .version, .problemReport: + 0 + } } // MARK: - Private @@ -154,7 +201,7 @@ final class SettingsDataSource: UITableViewDiffableDataSource