Skip to content

Commit

Permalink
Conform to UIAccessibility.isReduceMotionEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Sep 20, 2023
1 parent 29bcc53 commit bba3fab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public extension Animation {

/// `noAnimation` if running UI tests, otherwise `default` animation.
static var elementDefault: Animation {
Tests.isRunningUITests ? .noAnimation : .default
Tests.isRunningUITests ? .noAnimation : (UIAccessibility.isReduceMotionEnabled ? .noAnimation : .default)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,17 @@ class TimelineTableViewController: UIViewController {

// We only animate when there's a new last message, so its safe
// to animate from the bottom (which is the top as we're flipped).
dataSource?.defaultRowAnimation = .top
dataSource?.defaultRowAnimation = (UIAccessibility.isReduceMotionEnabled ? .none : .top)
tableView.delegate = self

NotificationCenter.default.addObserver(self,
selector: #selector(accessibilityReduceMotionDidChange),
name: UIAccessibility.reduceMotionStatusDidChangeNotification,
object: nil)
}

@objc private func accessibilityReduceMotionDidChange() {
dataSource?.defaultRowAnimation = (UIAccessibility.isReduceMotionEnabled ? .none : .top)
}

/// Updates the table view with the latest items from the ``timelineItems`` array. After
Expand Down

0 comments on commit bba3fab

Please sign in to comment.