forked from shadowfacts/Tusker
VoiceOver: improve description of gap cell, add actions to specify direction
This commit is contained in:
parent
0dcb7e71c4
commit
40ff8d0a2a
|
@ -15,6 +15,8 @@ class TimelineGapCollectionViewCell: UICollectionViewCell {
|
|||
private let indicator = UIActivityIndicatorView(style: .medium)
|
||||
private let chevronView = AnimatingChevronView()
|
||||
|
||||
var fillGap: ((TimelineGapDirection) async -> Void)?
|
||||
|
||||
override var isHighlighted: Bool {
|
||||
didSet {
|
||||
backgroundColor = isHighlighted ? .systemFill : .systemGroupedBackground
|
||||
|
@ -100,6 +102,36 @@ class TimelineGapCollectionViewCell: UICollectionViewCell {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: Accessibility
|
||||
|
||||
override var isAccessibilityElement: Bool {
|
||||
get { true }
|
||||
set {}
|
||||
}
|
||||
|
||||
override var accessibilityLabel: String? {
|
||||
get {
|
||||
"Load \(direction.accessibilityLabel)"
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
override var accessibilityCustomActions: [UIAccessibilityCustomAction]? {
|
||||
get {
|
||||
[TimelineGapDirection.below, .above].map { dir in
|
||||
UIAccessibilityCustomAction(name: "Load \(dir.accessibilityLabel)") { [unowned self] _ in
|
||||
Task {
|
||||
showsIndicator = true
|
||||
await fillGap?(dir)
|
||||
showsIndicator = false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class AnimatingChevronView: UIView {
|
||||
|
|
|
@ -137,8 +137,11 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
}
|
||||
let zeroHeightCell = UICollectionView.CellRegistration<ZeroHeightCollectionViewCell, Void> { _, _, _ in
|
||||
}
|
||||
let gapCell = UICollectionView.CellRegistration<TimelineGapCollectionViewCell, Void> { cell, indexPath, _ in
|
||||
let gapCell = UICollectionView.CellRegistration<TimelineGapCollectionViewCell, Void> { [unowned self] cell, indexPath, _ in
|
||||
cell.showsIndicator = false
|
||||
cell.fillGap = { [unowned self] direction in
|
||||
await self.controller.fillGap(in: direction)
|
||||
}
|
||||
}
|
||||
let timelineDescriptionCell = UICollectionView.CellRegistration<PublicTimelineDescriptionCollectionViewCell, Item> { [unowned self] cell, indexPath, item in
|
||||
guard case .public(let local) = timeline else {
|
||||
|
|
|
@ -379,4 +379,13 @@ enum TimelineGapDirection {
|
|||
case below
|
||||
/// Fill in above the gap. I.e., statuses that are immediately older than the status above the gap.
|
||||
case above
|
||||
|
||||
var accessibilityLabel: String {
|
||||
switch self {
|
||||
case .below:
|
||||
return "Newer"
|
||||
case .above:
|
||||
return "Older"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue