diff --git a/Tusker/Screens/Explore/TrendingStatusesViewController.swift b/Tusker/Screens/Explore/TrendingStatusesViewController.swift index 885501ed..9864bdf1 100644 --- a/Tusker/Screens/Explore/TrendingStatusesViewController.swift +++ b/Tusker/Screens/Explore/TrendingStatusesViewController.swift @@ -207,6 +207,10 @@ extension TrendingStatusesViewController: StatusCollectionViewCellDelegate { dataSource.apply(snapshot, animatingDifferences: animated, completion: completion) } } + + func statusCellShowFiltered(_ cell: StatusCollectionViewCell) { + fatalError() + } } extension TrendingStatusesViewController: StatusBarTappableViewController { diff --git a/Tusker/Screens/Profile/ProfileStatusesViewController.swift b/Tusker/Screens/Profile/ProfileStatusesViewController.swift index be8e9746..b10216b6 100644 --- a/Tusker/Screens/Profile/ProfileStatusesViewController.swift +++ b/Tusker/Screens/Profile/ProfileStatusesViewController.swift @@ -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 { diff --git a/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift b/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift index 26d48bc7..0debd7be 100644 --- a/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift +++ b/Tusker/Screens/Status Action Account List/StatusActionAccountListViewController.swift @@ -260,6 +260,10 @@ extension StatusActionAccountListViewController: StatusCollectionViewCellDelegat dataSource.apply(snapshot, animatingDifferences: animated, completion: completion) } } + + func statusCellShowFiltered(_ cell: StatusCollectionViewCell) { + fatalError() + } } extension StatusActionAccountListViewController: StatusBarTappableViewController { diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index 4b85a795..5993172e 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -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 { diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index 332adcbe..b76317cb 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -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 diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index eaafe92e..370397bd 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -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)