Merge branch 'experiments/posh-previews'

This commit is contained in:
Stuart Breckenridge committed 2026-10-14 20:49:50 +08:00
commit ea9adedb50
2 files changed
+18 -2

No files matched your search

@@ -547,7 +547,14 @@ extension MainTimelineViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemsAt indexPaths: [IndexPath], point: CGPoint) -> UIContextMenuConfiguration? {
guard let firstIndex = indexPaths.first, let dataSource, let article = dataSource.itemIdentifier(for: firstIndex) else { return nil }
return UIContextMenuConfiguration(identifier: firstIndex.row as NSCopying, previewProvider: nil, actionProvider: { [weak self] _ in
return UIContextMenuConfiguration(identifier: firstIndex.row as NSCopying,
previewProvider: {
let previewController = WebViewController()
previewController.coordinator = self.coordinator
previewController.article = article
return previewController
},
actionProvider: { [weak self] _ in
guard let self = self else { return nil }
@@ -601,6 +608,15 @@ extension MainTimelineViewController: UICollectionViewDelegate {
})
}
func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: any UIContextMenuInteractionCommitAnimating) {
animator.addCompletion { [weak self] in
guard let indexRow = configuration.identifier as? Int,
let dataSource = self?.dataSource,
let article = dataSource.itemIdentifier(for: IndexPath(item: indexRow, section: 0)) else { return }
self?.coordinator?.selectArticle(article)
}
}
func collectionView(_ collectionView: UICollectionView, contextMenuConfiguration configuration: UIContextMenuConfiguration, highlightPreviewForItemAt indexPath: IndexPath) -> UITargetedPreview? {
guard let row = configuration.identifier as? Int,
let cell = collectionView.cellForItem(at: IndexPath(row: row, section: 0)),