@@ -168,6 +168,11 @@ class TimelineTableViewController: UIViewController {
168
168
/// Whether or not the view has been shown on screen yet.
169
169
private var hasAppearedOnce = false
170
170
171
+ /// Value that determines if the table view is flipped or not according to the VoiceOver status.
172
+ private var scaleY : CGFloat {
173
+ UIAccessibility . isVoiceOverRunning ? 1 : - 1
174
+ }
175
+
171
176
init ( coordinator: TimelineViewRepresentable . Coordinator ,
172
177
isScrolledToBottom: Binding < Bool > ,
173
178
scrollToBottomPublisher: PassthroughSubject < Void , Never > ) {
@@ -185,7 +190,7 @@ class TimelineTableViewController: UIViewController {
185
190
186
191
// The tableview should be flipped to display the newest items at the top
187
192
// the only exception is VoiceOver, where we want to keep the latest item at the top as Android.
188
- tableView. transform = CGAffineTransform ( scaleX: 1 , y: UIAccessibility . isVoiceOverRunning ? 1 : - 1 )
193
+ tableView. transform = CGAffineTransform ( scaleX: 1 , y: scaleY )
189
194
view. addSubview ( tableView)
190
195
191
196
// Prevents XCUITest from invoking the diffable dataSource's cellProvider
@@ -223,7 +228,7 @@ class TimelineTableViewController: UIViewController {
223
228
NotificationCenter . default. publisher ( for: UIAccessibility . voiceOverStatusDidChangeNotification)
224
229
. sink { [ weak self] _ in
225
230
guard let self else { return }
226
- tableView. transform = CGAffineTransform ( scaleX: 1 , y: UIAccessibility . isVoiceOverRunning ? 1 : - 1 )
231
+ tableView. transform = CGAffineTransform ( scaleX: 1 , y: scaleY )
227
232
tableView. reloadData ( )
228
233
}
229
234
. store ( in: & cancellables)
@@ -273,7 +278,7 @@ class TimelineTableViewController: UIViewController {
273
278
. background ( Color . clear)
274
279
275
280
// Flipping the cell can create some issues with cell resizing, so flip the content View
276
- cell. contentView. transform = CGAffineTransform ( scaleX: 1 , y: UIAccessibility . isVoiceOverRunning ? 1 : - 1 )
281
+ cell. contentView. transform = CGAffineTransform ( scaleX: 1 , y: scaleY )
277
282
cell. accessibilityElements = [ cell. contentView] // Ensure VoiceOver reads the content view only
278
283
279
284
return cell
@@ -300,7 +305,7 @@ class TimelineTableViewController: UIViewController {
300
305
. background ( Color . clear)
301
306
302
307
// Flipping the cell can create some issues with cell resizing, so flip the content View
303
- cell. contentView. transform = CGAffineTransform ( scaleX: 1 , y: UIAccessibility . isVoiceOverRunning ? 1 : - 1 )
308
+ cell. contentView. transform = CGAffineTransform ( scaleX: 1 , y: scaleY )
304
309
return cell
305
310
}
306
311
}
0 commit comments