diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-12-20 12:53:24 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-12-20 16:56:17 +0100 |
| commit | 788858287f68d4b1b78b2d5c2136ca515dce4a4f (patch) | |
| tree | ce26aa6a2fa2ef1f3f0ddbb4f1a5ede3a5c8a328 | |
| parent | 765bab7bc3678965e8faf35869fa8344f509268a (diff) | |
| download | mullvadvpn-788858287f68d4b1b78b2d5c2136ca515dce4a4f.tar.xz mullvadvpn-788858287f68d4b1b78b2d5c2136ca515dce4a4f.zip | |
Add accessibility identifiers for preferences
| -rw-r--r-- | ios/MullvadVPN/PreferencesDataSource.swift | 37 | ||||
| -rw-r--r-- | ios/MullvadVPN/SettingsDataSource.swift | 10 |
2 files changed, 34 insertions, 13 deletions
diff --git a/ios/MullvadVPN/PreferencesDataSource.swift b/ios/MullvadVPN/PreferencesDataSource.swift index 4f39ad1403..80200a88de 100644 --- a/ios/MullvadVPN/PreferencesDataSource.swift +++ b/ios/MullvadVPN/PreferencesDataSource.swift @@ -40,7 +40,7 @@ class PreferencesDataSource: NSObject, UITableViewDataSource, UITableViewDelegat } } - private enum Section: Hashable { + private enum Section: String, Hashable { case mullvadDNS case customDNS } @@ -55,6 +55,27 @@ class PreferencesDataSource: NSObject, UITableViewDataSource, UITableViewDelegat case addDNSServer case dnsServer(_ uniqueID: UUID) + var accessibilityIdentifier: String { + switch self { + case .blockAdvertising: + return "blockAdvertising" + case .blockTracking: + return "blockTracking" + case .blockMalware: + return "blockMalware" + case .blockGambling: + return "blockGambling" + case .blockAdultContent: + return "blockAdultContent" + case .useCustomDNS: + return "useCustomDNS" + case .addDNSServer: + return "addDNSServer" + case let .dnsServer(uuid): + return "dnsServer(\(uuid.uuidString))" + } + } + static func isDNSServerItem(_ item: Item) -> Bool { if case .dnsServer = item { return true @@ -156,8 +177,12 @@ class PreferencesDataSource: NSObject, UITableViewDataSource, UITableViewDelegat func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let item = snapshot.itemForIndexPath(indexPath)! + let cell = dequeueCellForItem(item, in: tableView, at: indexPath) + + let section = snapshot.section(at: indexPath.section)! + cell.accessibilityIdentifier = "\(section.rawValue).\(item.accessibilityIdentifier)" - return dequeueCellForItem(item, in: tableView, at: indexPath) + return cell } func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { @@ -228,11 +253,9 @@ class PreferencesDataSource: NSObject, UITableViewDataSource, UITableViewDelegat } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - return tableView - .dequeueReusableHeaderFooterView( - withIdentifier: HeaderFooterReuseIdentifiers.spacer - .rawValue - ) + return tableView.dequeueReusableHeaderFooterView( + withIdentifier: HeaderFooterReuseIdentifiers.spacer.rawValue + ) } func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { diff --git a/ios/MullvadVPN/SettingsDataSource.swift b/ios/MullvadVPN/SettingsDataSource.swift index e2510baf20..15027f8ae4 100644 --- a/ios/MullvadVPN/SettingsDataSource.swift +++ b/ios/MullvadVPN/SettingsDataSource.swift @@ -152,7 +152,7 @@ final class SettingsDataSource: NSObject, UITableViewDataSource, UITableViewDele comment: "" ) cell.detailTitleLabel.text = nil - cell.accessibilityIdentifier = nil + cell.accessibilityIdentifier = "PreferencesCell" cell.disclosureType = .chevron return cell @@ -227,11 +227,9 @@ final class SettingsDataSource: NSObject, UITableViewDataSource, UITableViewDele } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - return tableView - .dequeueReusableHeaderFooterView( - withIdentifier: HeaderFooterReuseIdentifier.spacer - .rawValue - ) + return tableView.dequeueReusableHeaderFooterView( + withIdentifier: HeaderFooterReuseIdentifier.spacer.rawValue + ) } func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { |
