pr suggestion: use computed var for scaleY
This commit is contained in:
@@ -168,6 +168,11 @@ class TimelineTableViewController: UIViewController {
|
||||
/// Whether or not the view has been shown on screen yet.
|
||||
private var hasAppearedOnce = false
|
||||
|
||||
/// Value that determines if the table view is flipped or not according to the VoiceOver status.
|
||||
private var scaleY: CGFloat {
|
||||
UIAccessibility.isVoiceOverRunning ? 1 : -1
|
||||
}
|
||||
|
||||
init(coordinator: TimelineViewRepresentable.Coordinator,
|
||||
isScrolledToBottom: Binding<Bool>,
|
||||
scrollToBottomPublisher: PassthroughSubject<Void, Never>) {
|
||||
@@ -185,7 +190,7 @@ class TimelineTableViewController: UIViewController {
|
||||
|
||||
// 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)
|
||||
tableView.transform = CGAffineTransform(scaleX: 1, y: scaleY)
|
||||
view.addSubview(tableView)
|
||||
|
||||
// Prevents XCUITest from invoking the diffable dataSource's cellProvider
|
||||
@@ -223,7 +228,7 @@ class TimelineTableViewController: UIViewController {
|
||||
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.transform = CGAffineTransform(scaleX: 1, y: scaleY)
|
||||
tableView.reloadData()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
@@ -273,7 +278,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: UIAccessibility.isVoiceOverRunning ? 1 : -1)
|
||||
cell.contentView.transform = CGAffineTransform(scaleX: 1, y: scaleY)
|
||||
cell.accessibilityElements = [cell.contentView] // Ensure VoiceOver reads the content view only
|
||||
|
||||
return cell
|
||||
@@ -300,7 +305,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: UIAccessibility.isVoiceOverRunning ? 1 : -1)
|
||||
cell.contentView.transform = CGAffineTransform(scaleX: 1, y: scaleY)
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user