summaryrefslogtreecommitdiffhomepage
path: root/ios
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-06-03 13:47:53 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-06-04 14:51:03 +0200
commit93d7188918e2e8b044c0dd895fd14c8b98abb1b2 (patch)
tree5821fae11df33a5301f32189efd8650dedff99f3 /ios
parent89a050f74f91a1ccae739f6c5a27c40331c535ad (diff)
downloadmullvadvpn-93d7188918e2e8b044c0dd895fd14c8b98abb1b2.tar.xz
mullvadvpn-93d7188918e2e8b044c0dd895fd14c8b98abb1b2.zip
Accessibility: add custom action to collapse or expand the location cell
Diffstat (limited to 'ios')
-rw-r--r--ios/MullvadVPN/SelectLocationCell.swift24
-rw-r--r--ios/MullvadVPN/en.lproj/Localizable.strings3
2 files changed, 26 insertions, 1 deletions
diff --git a/ios/MullvadVPN/SelectLocationCell.swift b/ios/MullvadVPN/SelectLocationCell.swift
index 5fee38e29a..ef41257303 100644
--- a/ios/MullvadVPN/SelectLocationCell.swift
+++ b/ios/MullvadVPN/SelectLocationCell.swift
@@ -31,12 +31,14 @@ class SelectLocationCell: BasicTableViewCell {
var isExpanded = false {
didSet {
updateCollapseImage()
+ updateAccessibilityCustomActions()
}
}
var showsCollapseControl = false {
didSet {
collapseButton.isHidden = !showsCollapseControl
+ updateAccessibilityCustomActions()
}
}
@@ -92,8 +94,8 @@ class SelectLocationCell: BasicTableViewCell {
tickImageView.tintColor = .white
collapseButton.accessibilityIdentifier = "CollapseButton"
+ collapseButton.isAccessibilityElement = false
collapseButton.tintColor = .white
- collapseButton.setImage(chevronDown, for: .normal)
collapseButton.addTarget(self, action: #selector(handleCollapseButton(_ :)), for: .touchUpInside)
[locationLabel, tickImageView, statusIndicator, collapseButton].forEach { (subview) in
@@ -102,6 +104,7 @@ class SelectLocationCell: BasicTableViewCell {
}
updateCollapseImage()
+ updateAccessibilityCustomActions()
updateDisabled()
updateBackgroundColor()
@@ -170,9 +173,28 @@ class SelectLocationCell: BasicTableViewCell {
didCollapseHandler?(self)
}
+ @objc private func toggleCollapseAccessibilityAction() -> Bool {
+ didCollapseHandler?(self)
+ return true
+ }
+
private func updateCollapseImage() {
let image = isExpanded ? chevronUp : chevronDown
collapseButton.setImage(image, for: .normal)
}
+
+ private func updateAccessibilityCustomActions() {
+ if showsCollapseControl {
+ let actionName = isExpanded
+ ? NSLocalizedString("SELECT_LOCATION_COLLAPSE_ACCESSIBILITY_ACTION", comment: "")
+ : NSLocalizedString("SELECT_LOCATION_EXPAND_ACCESSIBILITY_ACTION", comment: "")
+
+ accessibilityCustomActions = [
+ UIAccessibilityCustomAction(name: actionName, target: self, selector: #selector(toggleCollapseAccessibilityAction))
+ ]
+ } else {
+ accessibilityCustomActions = nil
+ }
+ }
}
diff --git a/ios/MullvadVPN/en.lproj/Localizable.strings b/ios/MullvadVPN/en.lproj/Localizable.strings
index 56d4e1f49c..df0fac65e3 100644
--- a/ios/MullvadVPN/en.lproj/Localizable.strings
+++ b/ios/MullvadVPN/en.lproj/Localizable.strings
@@ -8,3 +8,6 @@
"HEADER_BAR_SETTINGS_BUTTON_ACCESSIBILITY_LABEL" = "Settings";
"RECONNECT_BUTTON_ACCESSIBILITY_LABEL" = "Reconnect";
+
+"SELECT_LOCATION_COLLAPSE_ACCESSIBILITY_ACTION" = "Collapse location";
+"SELECT_LOCATION_EXPAND_ACCESSIBILITY_ACTION" = "Expand location";