diff options
author | marinofaggiana <marino@marinofaggiana.com> | 2021-01-14 20:46:49 +0300 |
---|---|---|
committer | marinofaggiana <marino@marinofaggiana.com> | 2021-01-14 20:46:49 +0300 |
commit | 8135e606252e43e3d46848eb28f779445d8021e7 (patch) | |
tree | e3ffbd0ff95e673fa15ea00b268afea1f21fffc3 /iOSClient | |
parent | 64e53c47bead4c74508c0b8709aca7fd6b3e1413 (diff) |
improvements
Diffstat (limited to 'iOSClient')
-rw-r--r-- | iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift | 15 | ||||
-rw-r--r-- | iOSClient/Media/NCMedia.swift | 13 |
2 files changed, 25 insertions, 3 deletions
diff --git a/iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift b/iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift index d485671f4..548b1a822 100644 --- a/iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift +++ b/iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift @@ -1050,8 +1050,9 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { guard let metadata = dataSource.cellForItemAt(indexPath: indexPath) else { return nil } metadataTouch = metadata - - return UIContextMenuConfiguration(identifier: nil, previewProvider: { + let identifier = indexPath as NSCopying + + return UIContextMenuConfiguration(identifier: identifier, previewProvider: { return NCViewerProviderContextMenu(metadata: metadata) @@ -1119,6 +1120,16 @@ extension NCCollectionViewCommon: UICollectionViewDelegate { } }) } + + @available(iOS 13.0, *) + func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { + animator.addCompletion { + + if let indexPath = configuration.identifier as? IndexPath { + self.collectionView(collectionView, didSelectItemAt: indexPath) + } + } + } } extension NCCollectionViewCommon: UICollectionViewDataSource { diff --git a/iOSClient/Media/NCMedia.swift b/iOSClient/Media/NCMedia.swift index 073e54d3a..19f196624 100644 --- a/iOSClient/Media/NCMedia.swift +++ b/iOSClient/Media/NCMedia.swift @@ -498,8 +498,9 @@ extension NCMedia: UICollectionViewDelegate { func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? { let metadata = metadatas[indexPath.row] + let identifier = indexPath as NSCopying - return UIContextMenuConfiguration(identifier: nil, previewProvider: { + return UIContextMenuConfiguration(identifier: identifier, previewProvider: { return NCViewerProviderContextMenu(metadata: metadata) @@ -541,6 +542,16 @@ extension NCMedia: UICollectionViewDelegate { return UIMenu(title: "", children: [save, openIn, moveCopy, delete]) }) } + + @available(iOS 13.0, *) + func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { + animator.addCompletion { + + if let indexPath = configuration.identifier as? IndexPath { + self.collectionView(collectionView, didSelectItemAt: indexPath) + } + } + } } extension NCMedia: UICollectionViewDataSourcePrefetching { |