VoiceOver: Indicate filtered posts, make double tapping expand them

This commit is contained in:
Shadowfacts 2022-12-03 23:20:19 -05:00
parent e1886509d3
commit fabe339215
6 changed files with 44 additions and 2 deletions

View File

@ -207,6 +207,10 @@ extension TrendingStatusesViewController: StatusCollectionViewCellDelegate {
dataSource.apply(snapshot, animatingDifferences: animated, completion: completion)
}
}
func statusCellShowFiltered(_ cell: StatusCollectionViewCell) {
fatalError()
}
}
extension TrendingStatusesViewController: StatusBarTappableViewController {

View File

@ -499,6 +499,17 @@ extension ProfileStatusesViewController: StatusCollectionViewCellDelegate {
dataSource.apply(snapshot, animatingDifferences: animated, completion: completion)
}
}
func statusCellShowFiltered(_ cell: StatusCollectionViewCell) {
if let indexPath = collectionView.indexPath(for: cell),
let item = dataSource.itemIdentifier(for: indexPath),
case .status(id: _, collapseState: _, filterState: let filterState, pinned: _) = item {
filterState.setResult(.allow)
var snapshot = dataSource.snapshot()
snapshot.reconfigureItems([item])
dataSource.apply(snapshot, animatingDifferences: true)
}
}
}
extension ProfileStatusesViewController: TabBarScrollableViewController {

View File

@ -260,6 +260,10 @@ extension StatusActionAccountListViewController: StatusCollectionViewCellDelegat
dataSource.apply(snapshot, animatingDifferences: animated, completion: completion)
}
}
func statusCellShowFiltered(_ cell: StatusCollectionViewCell) {
fatalError()
}
}
extension StatusActionAccountListViewController: StatusBarTappableViewController {

View File

@ -848,6 +848,17 @@ extension TimelineViewController: StatusCollectionViewCellDelegate {
dataSource.apply(snapshot, animatingDifferences: animated, completion: completion)
}
}
func statusCellShowFiltered(_ cell: StatusCollectionViewCell) {
if let indexPath = collectionView.indexPath(for: cell),
let item = dataSource.itemIdentifier(for: indexPath),
case .status(id: _, collapseState: _, filterState: let filterState) = item {
filterState.setResult(.allow)
var snapshot = dataSource.snapshot()
snapshot.reconfigureItems([item])
dataSource.apply(snapshot, animatingDifferences: true)
}
}
}
extension TimelineViewController: TabBarScrollableViewController {

View File

@ -13,6 +13,7 @@ import Combine
@MainActor
protocol StatusCollectionViewCellDelegate: AnyObject, TuskerNavigationDelegate, MenuActionProvider {
func statusCellNeedsReconfigure(_ cell: StatusCollectionViewCell, animated: Bool, completion: (() -> Void)?)
func statusCellShowFiltered(_ cell: StatusCollectionViewCell)
}
@MainActor

View File

@ -281,6 +281,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
var accountID: String!
private var reblogStatusID: String?
private var rebloggerID: String?
private var filterReason: String?
private var firstLayout = true
var isGrayscale = false
@ -356,6 +357,11 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
override var accessibilityAttributedLabel: NSAttributedString? {
get {
if contentViewMode == .filtered,
let filterReason {
return NSAttributedString(string: "Filtered: \(filterReason)")
}
guard let status = mastodonController.persistentContainer.status(for: statusID) else {
return nil
}
@ -395,7 +401,9 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
override var accessibilityHint: String? {
get {
if statusState.collapsed ?? false {
if contentViewMode == .filtered {
return "Double tap to show the post."
} else if statusState.collapsed ?? false {
return "Double tap to expand the post."
} else {
return nil
@ -405,7 +413,9 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
}
override func accessibilityActivate() -> Bool {
if statusState.collapsed ?? false {
if contentViewMode == .filtered {
delegate?.statusCellShowFiltered(self)
} else if statusState.collapsed ?? false {
toggleCollapse()
} else {
delegate?.selected(status: statusID, state: statusState.copy())
@ -478,6 +488,7 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
case .allow:
setContentViewMode(.status)
case .warn(let filterTitle):
filterReason = filterTitle
let attrStr = NSMutableAttributedString(string: "Filtered: \(filterTitle) ")
let showStr = NSAttributedString(string: "Show", attributes: [.foregroundColor: UIColor.tintColor])
attrStr.append(showStr)