diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/Attachments/AttachmentsGalleryDataSource.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/Attachments/AttachmentsGalleryDataSource.swift index 30b84475..6a013e62 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/Attachments/AttachmentsGalleryDataSource.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/Attachments/AttachmentsGalleryDataSource.swift @@ -64,7 +64,12 @@ struct AttachmentsGalleryDataSource: GalleryDataSource { } func galleryContentTransitionSourceView(forItemAt index: Int) -> UIView? { - collectionView.cellForItem(at: IndexPath(item: index, section: 0)) + if let cell = collectionView.cellForItem(at: IndexPath(item: index, section: 0)) as? HostingCollectionViewCell { + // Use the hostView, because otherwise, the animation's changes to the source view opacity get clobbered by SwiftUI + cell.hostView + } else { + nil + } } private func fetchImageAndGIFData(assetID id: String) async -> (UIImage, Data?)? { diff --git a/Packages/ComposeUI/Sources/ComposeUI/Views/Attachments/AttachmentsSection.swift b/Packages/ComposeUI/Sources/ComposeUI/Views/Attachments/AttachmentsSection.swift index 60d3000a..bef0a6d0 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Views/Attachments/AttachmentsSection.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Views/Attachments/AttachmentsSection.swift @@ -363,7 +363,7 @@ private final class IntrinsicContentSizeCollectionView: UICollectionView { } #if os(visionOS) -private class HostingCollectionViewCell: UICollectionViewCell { +final class HostingCollectionViewCell: UICollectionViewCell { private(set) var hostView: UIView? func setView(_ view: V) { @@ -382,7 +382,7 @@ private class HostingCollectionViewCell: UICollectionViewCell { } #else @available(iOS, obsoleted: 16.0) -private class HostingCollectionViewCell: UICollectionViewCell { +final class HostingCollectionViewCell: UICollectionViewCell { weak var containingViewController: UIViewController? @available(iOS, obsoleted: 16.0)