浏览代码

coding image view

marinofaggiana 4 年之前
父节点
当前提交
5d4ee680a9

+ 24 - 8
iOSClient/Viewer/NCViewerImage/NCViewerImageDetailView.swift

@@ -31,11 +31,13 @@ class NCViewerImageDetailView: UIView {
     @IBOutlet weak var mapView: MKMapView!
     @IBOutlet weak var locationButton: UIButton!
 
+    var localFile: tableLocalFile?
     var latitude: Double = 0
     var longitude: Double = 0
     var location: String?
     var date: NSDate?
     var heightMap: CGFloat = 0
+    var size: Double = 0
     
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -58,6 +60,13 @@ class NCViewerImageDetailView: UIView {
         return !isHidden
     }
     
+    func hasData() -> Bool {
+        if localFile != nil {
+            return true
+        }
+        return false
+    }
+    
     //MARK: - EXIF
     
     func update(metadata: tableMetadata, heightMap:  CGFloat, textColor: UIColor) {
@@ -82,6 +91,7 @@ class NCViewerImageDetailView: UIView {
             self.latitude = Double(localFile.exifLatitude) ?? 0
             self.longitude = Double(localFile.exifLongitude) ?? 0
             self.date = localFile.exifDate
+            self.size = localFile.size
             
             if let locationDB = NCManageDatabase.sharedInstance.getLocationFromGeoLatitude(latitudeString, longitude: longitudeString) {
                 location = locationDB
@@ -95,8 +105,6 @@ class NCViewerImageDetailView: UIView {
     
     func updateContent() {
         
-        let annotation = MKPointAnnotation()
-        
         if let date = self.date {
             let formatter = DateFormatter()
             formatter.dateStyle = .full
@@ -106,12 +114,20 @@ class NCViewerImageDetailView: UIView {
             self.dateLabel.text = dateString + ", " + timeString
         }
         
-        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)
-        
-        mapHeightConstraint.constant = self.heightMap
+        if latitude > 0 && longitude > 0 {
+            
+            let annotation = MKPointAnnotation()
+            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)
+            mapHeightConstraint.constant = self.heightMap
+            
+        } else {
+            
+            mapHeightConstraint.constant = 0
+            locationButton.setTitle("" , for: .normal)
+        }
     }
     
     //MARK: - Action

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

@@ -189,7 +189,9 @@ class NCViewerImageZoom: UIViewController {
             // OPEN DETAIL
             if imageView.center.y < view.center.y - 50 {
                 
-                detailView.show()
+                if detailView.hasData() {
+                    detailView.show()
+                }
             }
             
             // CLOSE DETAIL