Skip to content

Commit d5c2723

Browse files
committed
Add accessibility hints to the digit grouping segmented control
1 parent eeff7b8 commit d5c2723

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Authenticator/Source/DisplayOptionsViewController.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ extension DisplayOptionsViewController {
115115
return DigitGroupingRowViewModel(
116116
title: "Digit Grouping",
117117
options: [
118-
(title: "•• •• ••", accessibilityLabel: "Groups of two digits", value: 2),
119-
(title: "••• •••", accessibilityLabel: "Groups of three digits", value: 3),
118+
(title: "•• •• ••", accessibilityLabel: "Groups of two digits", value: 2, accessibilityHint: "For example, 38 62 47"),
119+
(title: "••• •••", accessibilityLabel: "Groups of three digits", value: 3, accessibilityHint: "For example, 386 247"),
120120
],
121121
value: viewModel.digitGroupSize,
122122
changeAction: DisplayOptions.Effect.setDigitGroupSize
@@ -129,13 +129,13 @@ extension DisplayOptionsViewController {
129129
// swiftlint:disable large_tuple
130130
struct DigitGroupingRowViewModel<Action> {
131131
let title: String
132-
let segments: [(title: String, accessibilityLabel: String, action: Action)]
132+
let segments: [(title: String, accessibilityLabel: String, accessibilityHint: String, action: Action)]
133133
let selectedSegmentIndex: Int?
134134

135-
init<V: Equatable>(title: String, options: [(title: String, accessibilityLabel: String, value: V)], value: V, changeAction: (V) -> Action) {
135+
init<V: Equatable>(title: String, options: [(title: String, accessibilityLabel: String, value: V, accessibilityHint: String)], value: V, changeAction: (V) -> Action) {
136136
self.title = title
137137
segments = options.map({ option in
138-
(title: option.title, accessibilityLabel: option.accessibilityLabel, action: changeAction(option.value))
138+
(title: option.title, accessibilityLabel: option.accessibilityLabel, accessibilityHint: option.accessibilityHint, action: changeAction(option.value))
139139
})
140140
selectedSegmentIndex = options.map({ $0.value }).index(of: value)
141141
}
@@ -224,6 +224,7 @@ class DigitGroupingRowCell<Action>: UITableViewCell {
224224
// This is a hack to set the accessibility label on each segment, but for now it works.
225225
// If a future iOS update ever changes the internals of UISegmentedControl, this may break horribly.
226226
segmentedControl.subviews.last?.accessibilityLabel = segment.accessibilityLabel
227+
segmentedControl.subviews.last?.accessibilityHint = segment.accessibilityHint
227228
}
228229
// Store the action associated with each segment
229230
actions = viewModel.segments.map({ $0.action })

0 commit comments

Comments
 (0)