From fdcd2aa540e6e693d78caea9b1b969799b593cff Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 27 Jun 2021 10:30:53 -0400 Subject: [PATCH] Add Open in New Window context menu action to sidebar items --- .../Screens/Main/MainSidebarViewController.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tusker/Screens/Main/MainSidebarViewController.swift b/Tusker/Screens/Main/MainSidebarViewController.swift index 9fa01706..8cf56eaa 100644 --- a/Tusker/Screens/Main/MainSidebarViewController.swift +++ b/Tusker/Screens/Main/MainSidebarViewController.swift @@ -462,6 +462,21 @@ extension MainSidebarViewController: UICollectionViewDelegate { return true } } + + func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { + guard #available(iOS 15.0, *), + let item = dataSource.itemIdentifier(for: indexPath), + let activity = userActivityForItem(item) else { + return nil + } + return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { (_) in + return UIMenu(children: [ + UIWindowScene.ActivationAction({ action in + return UIWindowScene.ActivationConfiguration(userActivity: activity) + }), + ]) + } + } } extension MainSidebarViewController: UICollectionViewDragDelegate {