marinofaggiana 4 жил өмнө
parent
commit
c848b9bf29

+ 40 - 1
iOSClient/Viewer/NCViewerImage/NCViewerImage.swift

@@ -51,7 +51,7 @@ class NCViewerImage: UIViewController {
     var nextIndex: Int?
        
     var currentViewerImageZoom: NCViewerImageZoom?
-    
+    var panGestureRecognizer: UIPanGestureRecognizer!
     var singleTapGestureRecognizer: UITapGestureRecognizer!
     var longtapGestureRecognizer: UILongPressGestureRecognizer!
     
@@ -66,6 +66,7 @@ class NCViewerImage: UIViewController {
         super.viewDidLoad()
         
         singleTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(didSingleTapWith(gestureRecognizer:)))
+        panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(didPanWith(gestureRecognizer:)))
         longtapGestureRecognizer = UILongPressGestureRecognizer()
         longtapGestureRecognizer.delaysTouchesBegan = true
         longtapGestureRecognizer.minimumPressDuration = 0.3
@@ -74,6 +75,7 @@ class NCViewerImage: UIViewController {
         
         pageViewController.delegate = self
         pageViewController.dataSource = self
+        pageViewController.view.addGestureRecognizer(panGestureRecognizer)
         pageViewController.view.addGestureRecognizer(singleTapGestureRecognizer)
         pageViewController.view.addGestureRecognizer(longtapGestureRecognizer)
         
@@ -595,6 +597,43 @@ extension NCViewerImage: UIPageViewControllerDelegate, UIPageViewControllerDataS
 
 extension NCViewerImage: UIGestureRecognizerDelegate {
 
+    func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
+        
+        if let gestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer {
+            let velocity = gestureRecognizer.velocity(in: self.view)
+            
+            var velocityCheck : Bool = false
+            
+            if UIDevice.current.orientation.isLandscape {
+                velocityCheck = velocity.x < 0
+            }
+            else {
+                velocityCheck = velocity.y < 0
+            }
+            if velocityCheck {
+                return false
+            }
+        }
+        
+        return true
+    }
+    
+    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
+        
+        if otherGestureRecognizer == currentViewController.scrollView.panGestureRecognizer {
+            if self.currentViewController.scrollView.contentOffset.y == 0 {
+                return true
+            }
+        }
+        
+        return false
+    }
+
+    @objc func didPanWith(gestureRecognizer: UIPanGestureRecognizer) {
+        
+        currentViewerImageZoom?.didPanWith(gestureRecognizer: gestureRecognizer)
+    }
+    
     @objc func didSingleTapWith(gestureRecognizer: UITapGestureRecognizer) {
         
         if currentMetadata.typeFile == k_metadataTypeFile_video || currentMetadata.typeFile == k_metadataTypeFile_audio {

+ 18 - 12
iOSClient/Viewer/NCViewerImage/NCViewerImageDetailView.swift

@@ -25,23 +25,29 @@ class NCViewerImageDetailView: UIView {
     }
     
     func updateExifLocal(metadata: tableMetadata) {
-        if metadata.typeFile == k_metadataTypeFile_image {
-            CCExifGeo.sharedInstance()?.setExif(metadata)
-        }
         
-        if let localFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
+        DispatchQueue.global().async {
+            
+            if metadata.typeFile == k_metadataTypeFile_image {
+                CCExifGeo.sharedInstance()?.setExif(metadata)
+            }
+        
+            if let localFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
             
-            latitude = Double(localFile.exifLatitude) ?? 0
-            longitude = Double(localFile.exifLongitude) ?? 0
+                self.latitude = Double(localFile.exifLatitude) ?? 0
+                self.longitude = Double(localFile.exifLongitude) ?? 0
             
-            if latitude > 0 && longitude > 0 {
+                if self.latitude > 0 && self.longitude > 0 {
             
-                annotation.coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
-                mapView.addAnnotation(annotation)
-                mapView.setRegion(MKCoordinateRegion(center: annotation.coordinate, latitudinalMeters: 500, longitudinalMeters: 500), animated: false)
+                    /*
+                    annotation.coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
+                    mapView.addAnnotation(annotation)
+                    mapView.setRegion(MKCoordinateRegion(center: annotation.coordinate, latitudinalMeters: 500, longitudinalMeters: 500), animated: false)
                 
-                if let location = NCManageDatabase.sharedInstance.getLocationFromGeoLatitude(localFile.exifLatitude, longitude: localFile.exifLongitude) {
-                    locationButton.setTitle(location, for: .normal)
+                    if let location = NCManageDatabase.sharedInstance.getLocationFromGeoLatitude(localFile.exifLatitude, longitude: localFile.exifLongitude) {
+                        locationButton.setTitle(location, for: .normal)
+                    }
+                    */
                 }
             }
         }

+ 1 - 2
iOSClient/Viewer/NCViewerImage/NCViewerImageZoom.swift

@@ -75,7 +75,6 @@ class NCViewerImageZoom: UIViewController {
         scrollView.contentInsetAdjustmentBehavior = .never
         
         view.addGestureRecognizer(doubleTapGestureRecognizer)
-        view.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(didPanWith(gestureRecognizer:))))
         
         if image == nil {
             image = CCGraphics.changeThemingColorImage(UIImage.init(named: "noPreview"), width: view.frame.width, height: view.frame.width, color: .gray)
@@ -94,7 +93,7 @@ class NCViewerImageZoom: UIViewController {
             statusLabel.text = ""
         }
         
-        detailView.updateExifLocal(metadata: metadata)
+        //detailView.updateExifLocal(metadata: metadata)
     }
     
     override func viewWillAppear(_ animated: Bool) {