mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
unflip timeline table view in voice over mode only
This commit is contained in:
@@ -182,7 +182,10 @@ class TimelineTableViewController: UIViewController {
|
|||||||
tableView.allowsSelection = false
|
tableView.allowsSelection = false
|
||||||
tableView.keyboardDismissMode = .onDrag
|
tableView.keyboardDismissMode = .onDrag
|
||||||
tableView.backgroundColor = .compound.bgCanvasDefault
|
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)
|
view.addSubview(tableView)
|
||||||
|
|
||||||
// Prevents XCUITest from invoking the diffable dataSource's cellProvider
|
// Prevents XCUITest from invoking the diffable dataSource's cellProvider
|
||||||
@@ -216,6 +219,15 @@ class TimelineTableViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.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()
|
configureDataSource()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +273,8 @@ class TimelineTableViewController: UIViewController {
|
|||||||
.background(Color.clear)
|
.background(Color.clear)
|
||||||
|
|
||||||
// Flipping the cell can create some issues with cell resizing, so flip the content View
|
// 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
|
return cell
|
||||||
default:
|
default:
|
||||||
@@ -287,7 +300,7 @@ class TimelineTableViewController: UIViewController {
|
|||||||
.background(Color.clear)
|
.background(Color.clear)
|
||||||
|
|
||||||
// Flipping the cell can create some issues with cell resizing, so flip the content View
|
// 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
|
return cell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user