diff --git a/Tusker/Screens/Explore/TrendingLinksViewController.swift b/Tusker/Screens/Explore/TrendingLinksViewController.swift index 89e09f48..85df6798 100644 --- a/Tusker/Screens/Explore/TrendingLinksViewController.swift +++ b/Tusker/Screens/Explore/TrendingLinksViewController.swift @@ -246,7 +246,8 @@ extension TrendingLinksViewController: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { guard case .link(let card) = dataSource.itemIdentifier(for: indexPath), - let url = URL(card.url) else { + let url = URL(card.url), + let cell = collectionView.cellForItem(at: indexPath) else { return nil } return UIContextMenuConfiguration { @@ -254,7 +255,7 @@ extension TrendingLinksViewController: UICollectionViewDelegate { vc.preferredControlTintColor = Preferences.shared.accentColor.color return vc } actionProvider: { _ in - UIMenu(children: self.actionsForTrendingLink(card: card)) + UIMenu(children: self.actionsForTrendingLink(card: card, source: .view(cell))) } } diff --git a/Tusker/Screens/Explore/TrendsViewController.swift b/Tusker/Screens/Explore/TrendsViewController.swift index 4380fbff..711d82c9 100644 --- a/Tusker/Screens/Explore/TrendsViewController.swift +++ b/Tusker/Screens/Explore/TrendsViewController.swift @@ -369,12 +369,13 @@ extension TrendsViewController: UICollectionViewDelegate { guard let url = URL(card.url) else { return nil } + let cell = collectionView.cellForItem(at: indexPath)! return UIContextMenuConfiguration { let vc = SFSafariViewController(url: url) vc.preferredControlTintColor = Preferences.shared.accentColor.color return vc } actionProvider: { _ in - UIMenu(children: self.actionsForTrendingLink(card: card)) + UIMenu(children: self.actionsForTrendingLink(card: card, source: .view(cell))) } case let .status(id, state): diff --git a/Tusker/Screens/Utilities/Previewing.swift b/Tusker/Screens/Utilities/Previewing.swift index e385ad6d..cd35dd38 100644 --- a/Tusker/Screens/Utilities/Previewing.swift +++ b/Tusker/Screens/Utilities/Previewing.swift @@ -346,12 +346,16 @@ extension MenuActionProvider { } } - func actionsForTrendingLink(card: Card) -> [UIMenuElement] { + func actionsForTrendingLink(card: Card, source: PopoverSource) -> [UIMenuElement] { guard let url = URL(card.url) else { return [] } return [ openInSafariAction(url: url), + createAction(identifier: "share", title: "Share", systemImageName: "square.and.arrow.up", handler: { [weak self] (_) in + guard let self else { return } + self.navigationDelegate?.showMoreOptions(forURL: url, source: source) + }), createAction(identifier: "postlink", title: "Post this Link", systemImageName: "square.and.pencil", handler: { [weak self] _ in guard let self = self else { return } let draft = self.mastodonController!.createDraft()