Add Open in New Window context menu action to sidebar items

This commit is contained in:
Shadowfacts 2021-06-27 10:30:53 -04:00
parent 667d30a710
commit fdcd2aa540
1 changed files with 15 additions and 0 deletions

View File

@ -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 {