summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2023-08-04 09:51:53 +0200
committerBug Magnet <marco.nikic@mullvad.net>2023-08-09 09:26:39 +0200
commit62a11beb35df0741d7f0a444bde7dd02afa2b9f9 (patch)
tree903ef8832296469552cf38a695a65b562794a916
parent04239e4e260ecc625aa940ec742927a20baa9583 (diff)
downloadmullvadvpn-62a11beb35df0741d7f0a444bde7dd02afa2b9f9.tar.xz
mullvadvpn-62a11beb35df0741d7f0a444bde7dd02afa2b9f9.zip
Add an accessibilityCustomActionName to SettingsHeaderView
-rw-r--r--ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift29
-rw-r--r--ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift18
2 files changed, 29 insertions, 18 deletions
diff --git a/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift b/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift
index a6b565ada6..6e1a131d5f 100644
--- a/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift
+++ b/ios/MullvadVPN/View controllers/Preferences/PreferencesDataSource.swift
@@ -774,21 +774,24 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
apply(snapshot, animatingDifferences: true)
}
- private func configureContentBlockersHeader(_ reusableView: SettingsHeaderView) {
- reusableView.titleLabel.text = NSLocalizedString(
+ private func configureContentBlockersHeader(_ header: SettingsHeaderView) {
+ let title = NSLocalizedString(
"CONTENT_BLOCKERS_HEADER_LABEL",
tableName: "Preferences",
value: "DNS content blockers",
comment: ""
)
- reusableView.infoButtonHandler = { [weak self] in
+ header.titleLabel.text = title
+ header.accessibilityCustomActionName = title
+
+ header.infoButtonHandler = { [weak self] in
if let self {
self.delegate?.preferencesDataSource(self, showInfo: .contentBlockers)
}
}
- reusableView.didCollapseHandler = { [weak self] headerView in
+ header.didCollapseHandler = { [weak self] headerView in
guard let self else { return }
var snapshot = self.snapshot()
@@ -804,21 +807,23 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
}
}
- private func configureWireguardPortsHeader(_ reusableView: SettingsHeaderView) {
- reusableView.titleLabel.text = NSLocalizedString(
+ private func configureWireguardPortsHeader(_ header: SettingsHeaderView) {
+ let title = NSLocalizedString(
"WIRE_GUARD_PORTS_HEADER_LABEL",
tableName: "Preferences",
value: "WireGuard ports",
comment: ""
)
- reusableView.infoButtonHandler = { [weak self] in
+ header.titleLabel.text = title
+ header.accessibilityCustomActionName = title
+ header.infoButtonHandler = { [weak self] in
if let self {
self.delegate?.preferencesDataSource(self, showInfo: .wireGuardPorts)
}
}
- reusableView.didCollapseHandler = { [weak self] headerView in
+ header.didCollapseHandler = { [weak self] headerView in
guard let self else { return }
var snapshot = self.snapshot()
@@ -846,13 +851,15 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
}
private func configureObfuscationHeader(_ header: SettingsHeaderView) {
- header.titleLabel.text = NSLocalizedString(
+ let title = NSLocalizedString(
"OBFUSCATION_HEADER_LABEL",
tableName: "Preferences",
value: "WireGuard Obfuscation",
comment: ""
)
+ header.titleLabel.text = title
+ header.accessibilityCustomActionName = title
header.didCollapseHandler = { [weak self] header in
guard let self else { return }
@@ -872,13 +879,15 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
}
private func configureObfuscationPortHeader(_ header: SettingsHeaderView) {
- header.titleLabel.text = NSLocalizedString(
+ let title = NSLocalizedString(
"OBFUSCATION_PORT_HEADER_LABEL",
tableName: "Preferences",
value: "UDP-over-TCP Port",
comment: ""
)
+ header.titleLabel.text = title
+ header.accessibilityCustomActionName = title
header.didCollapseHandler = { [weak self] header in
guard let self else { return }
diff --git a/ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift b/ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift
index 4a536528a5..c934042d62 100644
--- a/ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift
+++ b/ios/MullvadVPN/View controllers/Settings/SettingsHeaderView.swift
@@ -44,6 +44,12 @@ class SettingsHeaderView: UITableViewHeaderFooterView {
}
}
+ var accessibilityCustomActionName = "" {
+ didSet {
+ updateAccessibilityCustomActions()
+ }
+ }
+
var didCollapseHandler: CollapseHandler?
var infoButtonHandler: InfoButtonHandler?
@@ -92,7 +98,6 @@ class SettingsHeaderView: UITableViewHeaderFooterView {
}
updateCollapseImage()
- updateAccessibilityCustomActions()
}
required init?(coder: NSCoder) {
@@ -119,20 +124,17 @@ class SettingsHeaderView: UITableViewHeaderFooterView {
}
private func updateAccessibilityCustomActions() {
- #warning(
- "SettingsHeaderView is reused for more than content blockers now, this code doesn't seem correct anymore."
- )
let actionName = isExpanded
? NSLocalizedString(
- "CONTENT_BLOCKERS_COLLAPSE_ACCESSIBILITY_ACTION",
+ "SETTINGS_HEADER_COLLAPSE_ACCESSIBILITY_ACTION",
tableName: "Settings",
- value: "Collapse content blockers",
+ value: "Collapse \(accessibilityCustomActionName)",
comment: ""
)
: NSLocalizedString(
- "CONTENT_BLOCKERS_EXPAND_ACCESSIBILITY_ACTION",
+ "SETTINGS_HEADER_EXPAND_ACCESSIBILITY_ACTION",
tableName: "Settings",
- value: "Expand content blockers",
+ value: "Expand \(accessibilityCustomActionName)",
comment: ""
)