@@ -114,7 +114,10 @@ extension DisplayOptionsViewController {
114
114
fileprivate var digitGroupingRowViewModel : DigitGroupingRowViewModel < DisplayOptions . Effect > {
115
115
return DigitGroupingRowViewModel (
116
116
title: " Digit Grouping " ,
117
- options: [ ( title: " •• •• •• " , value: 2 ) , ( title: " ••• ••• " , value: 3 ) ] ,
117
+ options: [
118
+ ( title: " •• •• •• " , accessibilityLabel: " Groups of two digits " , value: 2 ) ,
119
+ ( title: " ••• ••• " , accessibilityLabel: " Groups of three digits " , value: 3 ) ,
120
+ ] ,
118
121
value: viewModel. digitGroupSize,
119
122
changeAction: DisplayOptions . Effect. setDigitGroupSize
120
123
)
@@ -123,19 +126,21 @@ extension DisplayOptionsViewController {
123
126
124
127
// MARK: Digit Grouping Row
125
128
129
+ // swiftlint:disable large_tuple
126
130
struct DigitGroupingRowViewModel < Action> {
127
131
let title : String
128
- let segments : [ ( title: String , action: Action ) ]
132
+ let segments : [ ( title: String , accessibilityLabel : String , action: Action ) ]
129
133
let selectedSegmentIndex : Int ?
130
134
131
- init < V: Equatable > ( title: String , options: [ ( title: String , value: V ) ] , value: V , changeAction: ( V ) -> Action ) {
135
+ init < V: Equatable > ( title: String , options: [ ( title: String , accessibilityLabel : String , value: V ) ] , value: V , changeAction: ( V ) -> Action ) {
132
136
self . title = title
133
137
segments = options. map ( { option in
134
- ( title: option. title, action: changeAction ( option. value) )
138
+ ( title: option. title, accessibilityLabel : option . accessibilityLabel , action: changeAction ( option. value) )
135
139
} )
136
140
selectedSegmentIndex = options. map ( { $0. value } ) . index ( of: value)
137
141
}
138
142
}
143
+ // swiftlint:enable large_tuple
139
144
140
145
class DigitGroupingRowCell < Action> : UITableViewCell {
141
146
private let titleLabel = UILabel ( )
@@ -165,6 +170,8 @@ class DigitGroupingRowCell<Action>: UITableViewCell {
165
170
titleLabel. translatesAutoresizingMaskIntoConstraints = false
166
171
contentView. addSubview ( titleLabel)
167
172
173
+ accessibilityHint = " The digits of a password can be shown in different sized groups. "
174
+
168
175
let font = UIFont . systemFont ( ofSize: 40 , weight: . light)
169
176
let fontAttributes = [ NSAttributedStringKey . font: font]
170
177
segmentedControl. setTitleTextAttributes ( fontAttributes, for: . normal)
@@ -213,6 +220,10 @@ class DigitGroupingRowCell<Action>: UITableViewCell {
213
220
for i in viewModel. segments. indices {
214
221
let segment = viewModel. segments [ i]
215
222
segmentedControl. insertSegment ( withTitle: segment. title, at: i, animated: false )
223
+
224
+ // This is a hack to set the accessibility label on each segment, but for now it works.
225
+ // If a future iOS update ever changes the internals of UISegmentedControl, this may break horribly.
226
+ segmentedControl. subviews. last? . accessibilityLabel = segment. accessibilityLabel
216
227
}
217
228
// Store the action associated with each segment
218
229
actions = viewModel. segments. map ( { $0. action } )
0 commit comments