Explorar o código

detail view image

marinofaggiana %!s(int64=4) %!d(string=hai) anos
pai
achega
0b44a2e7c8

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

@@ -15,8 +15,10 @@ class NCViewerImageDetailView: UIView {
     @IBOutlet weak var locationButton: UIButton!
 
     var annotation = MKPointAnnotation()
+    
     var latitude: Double = 0
     var longitude: Double = 0
+    var location: String = ""
     
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -33,23 +35,35 @@ class NCViewerImageDetailView: UIView {
             }
         
             if let localFile = NCManageDatabase.sharedInstance.getTableLocalFile(predicate: NSPredicate(format: "ocId == %@", metadata.ocId)) {
-            
+                
+                let latitudeString = localFile.exifLatitude
+                let longitudeString = localFile.exifLongitude
                 self.latitude = Double(localFile.exifLatitude) ?? 0
                 self.longitude = Double(localFile.exifLongitude) ?? 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)
                 
-                    if let location = NCManageDatabase.sharedInstance.getLocationFromGeoLatitude(localFile.exifLatitude, longitude: localFile.exifLongitude) {
-                        locationButton.setTitle(location, for: .normal)
-                    }
-                    */
+                if let location = NCManageDatabase.sharedInstance.getLocationFromGeoLatitude(latitudeString, longitude: longitudeString) {
+                    self.location = location
                 }
             }
         }
     }
+    
+    func insertDataDetail() {
+        
+        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)
+            locationButton.setTitle(location, for: .normal)
+        }
+    }
+    
+    func hasData() -> Bool {
+        if self.latitude > 0 && self.longitude > 0 {
+            return true
+        } else {
+            return false
+        }
+    }
 }

+ 4 - 3
iOSClient/Viewer/NCViewerImage/NCViewerImageZoom.swift

@@ -91,9 +91,7 @@ class NCViewerImageZoom: UIViewController {
         }  else {
             statusViewImage.image = nil
             statusLabel.text = ""
-        }
-        
-        //detailView.updateExifLocal(metadata: metadata)
+        }        
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -144,6 +142,8 @@ class NCViewerImageZoom: UIViewController {
     @objc func didPanWith(gestureRecognizer: UIPanGestureRecognizer) {
         let currentLocation = gestureRecognizer.translation(in: self.view)
 
+        if !detailView.hasData() { return }
+        
         switch gestureRecognizer.state {
         case .began:
             
@@ -179,6 +179,7 @@ class NCViewerImageZoom: UIViewController {
                 detailViewHeightConstraint.constant = (view.frame.width / 3) * 2
                 let offsetBottom = self.view.safeAreaInsets.bottom + 20
                 detailViewBottomConstraint.constant = imageViewBottomConstraint.constant - offsetBottom
+                detailView.insertDataDetail()
                 openDetailView = true
             }