Explorar o código

Merge pull request #1027 from deltachat/adapt_gallery_image_preview

Adapt gallery image preview
bjoern %!s(int64=4) %!d(string=hai) anos
pai
achega
577ca45e5a
Modificáronse 1 ficheiros con 10 adicións e 7 borrados
  1. 10 7
      deltachat-ios/Controller/GalleryViewController.swift

+ 10 - 7
deltachat-ios/Controller/GalleryViewController.swift

@@ -1,5 +1,6 @@
 import UIKit
 import DcCore
+import QuickLook
 
 class GalleryViewController: UIViewController {
 
@@ -254,13 +255,6 @@ extension GalleryViewController: UICollectionViewDataSource, UICollectionViewDel
             }
         )
     }
-
-    @available(iOS 13, *)
-    func collectionView(_ collectionView: UICollectionView, willEndContextMenuInteraction configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionAnimating?) {
-        if let msgId = (animator?.previewViewController as? ContextMenuController)?.msg.id {
-            self.showPreview(msgId: msgId)
-        }
-    }
 }
 
 // MARK: - grid layout + updates
@@ -309,6 +303,7 @@ private extension GalleryViewController {
         }
 
         let previewController = PreviewController(type: .multi(mediaMessageIds, index))
+        previewController.delegate = self
         present(previewController, animated: true, completion: nil)
     }
 
@@ -404,3 +399,11 @@ extension ContextMenuProvider {
         var onPerform: ((IndexPath) -> Void)?
     }
 }
+
+// MARK: - QLPreviewControllerDataSource
+extension GalleryViewController: QLPreviewControllerDelegate {
+    func previewController(_ controller: QLPreviewController, transitionViewFor item: QLPreviewItem) -> UIView? {
+        let indexPath = IndexPath(row: controller.currentPreviewItemIndex, section: 0)
+        return grid.cellForItem(at: indexPath)
+    }
+}