diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index 107b0101f8..2a95544f29 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -16,7 +16,7 @@ protocol StatusCollectionViewCellDelegate: AnyObject, TuskerNavigationDelegate, } @MainActor -protocol StatusCollectionViewCell: UICollectionViewCell { +protocol StatusCollectionViewCell: UICollectionViewCell, AttachmentViewDelegate { // MARK: Subviews var avatarImageView: CachedImageView { get } var displayNameLabel: EmojiLabel { get } @@ -82,8 +82,9 @@ extension StatusCollectionViewCell { updateAccountUI(account: status.account) updateUIForPreferences(status: status) - contentContainer.contentTextView.setTextFrom(status: status) + contentContainer.contentTextView.setTextFrom(status: status) + contentContainer.attachmentsView.delegate = self contentContainer.cardView.updateUI(status: status) contentContainer.cardView.isHidden = status.card == nil contentContainer.cardView.navigationDelegate = delegate @@ -224,6 +225,22 @@ extension StatusCollectionViewCell { } } +extension StatusCollectionViewCell { + func attachmentViewGallery(startingAt index: Int) -> GalleryViewController? { + guard let delegate = delegate, + let status = mastodonController.persistentContainer.status(for: statusID) else { return nil } + let sourceViews = status.attachments.map(contentContainer.attachmentsView.getAttachmentView(for:)) + let gallery = delegate.gallery(attachments: status.attachments, sourceViews: sourceViews, startIndex: index) + // TODO: PiP +// gallery.avPlayerViewControllerDelegate = self + return gallery + } + + func attachmentViewPresent(_ vc: UIViewController, animated: Bool) { + delegate?.present(vc, animated: animated) + } +} + extension StatusCollectionViewCell { func contextMenuConfigurationForAccount(sourceView: UIView) -> UIContextMenuConfiguration? { return UIContextMenuConfiguration() {