unflip timeline table view in voice over mode only

This commit is contained in:
Mauro Romito
2025-06-17 14:17:54 +02:00
committed by Mauro
parent 12e55d6c28
commit 5e342a91dd
@@ -182,7 +182,10 @@ class TimelineTableViewController: UIViewController {
tableView.allowsSelection = false
tableView.keyboardDismissMode = .onDrag
tableView.backgroundColor = .compound.bgCanvasDefault
tableView.transform = CGAffineTransform(scaleX: 1, y: -1)
// The tableview should be flipped to display the newest items at the top
// the only exception is VoiceOver, where we want to keep the latest item at the top as Android.
tableView.transform = CGAffineTransform(scaleX: 1, y: UIAccessibility.isVoiceOverRunning ? 1 : -1)
view.addSubview(tableView)
// Prevents XCUITest from invoking the diffable dataSource's cellProvider
@@ -216,6 +219,15 @@ class TimelineTableViewController: UIViewController {
}
.store(in: &cancellables)
// Observe voice over status changes to flip the table view accordingly
NotificationCenter.default.publisher(for: UIAccessibility.voiceOverStatusDidChangeNotification)
.sink { [weak self] _ in
guard let self else { return }
tableView.transform = CGAffineTransform(scaleX: 1, y: UIAccessibility.isVoiceOverRunning ? 1 : -1)
tableView.reloadData()
}
.store(in: &cancellables)
configureDataSource()
}
@@ -261,7 +273,8 @@ class TimelineTableViewController: UIViewController {
.background(Color.clear)
// Flipping the cell can create some issues with cell resizing, so flip the content View
cell.contentView.transform = CGAffineTransform(scaleX: 1, y: -1)
cell.contentView.transform = CGAffineTransform(scaleX: 1, y: UIAccessibility.isVoiceOverRunning ? 1 : -1)
cell.accessibilityElements = [cell.contentView] // Ensure VoiceOver reads the content view only
return cell
default:
@@ -287,7 +300,7 @@ class TimelineTableViewController: UIViewController {
.background(Color.clear)
// Flipping the cell can create some issues with cell resizing, so flip the content View
cell.contentView.transform = CGAffineTransform(scaleX: 1, y: -1)
cell.contentView.transform = CGAffineTransform(scaleX: 1, y: UIAccessibility.isVoiceOverRunning ? 1 : -1)
return cell
}
}