Fix not being able to press attachments in new status cells

This commit is contained in:
Shadowfacts 2022-10-08 19:10:21 -04:00
parent cadcc1a92a
commit 164a8e26c4
1 changed files with 19 additions and 2 deletions

View File

@ -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() {