Add share to trending link actions
This commit is contained in:
parent
ea85b11945
commit
00a23b525f
|
@ -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)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue