|
@@ -37,24 +37,17 @@ class NCViewerMediaDetailView: UIView {
|
|
|
@IBOutlet weak var lensModelLabel: UILabel!
|
|
|
@IBOutlet weak var lensModelValue: UILabel!
|
|
|
@IBOutlet weak var messageLabel: UILabel!
|
|
|
- @IBOutlet weak var mapHeightConstraint: NSLayoutConstraint!
|
|
|
- @IBOutlet weak var mapView: MKMapView!
|
|
|
+ @IBOutlet weak var mapContainer: UIView!
|
|
|
@IBOutlet weak var locationButton: UIButton!
|
|
|
-
|
|
|
- var metadata: tableMetadata?
|
|
|
|
|
|
var latitude: Double = 0
|
|
|
var longitude: Double = 0
|
|
|
var location: String?
|
|
|
- var date: NSDate?
|
|
|
- var lensModel: String?
|
|
|
- var heightMap: CGFloat = 0
|
|
|
- var size: Int64 = 0
|
|
|
- var image: UIImage?
|
|
|
-
|
|
|
+
|
|
|
override func awakeFromNib() {
|
|
|
super.awakeFromNib()
|
|
|
|
|
|
+ separator.backgroundColor = NCBrandColor.shared.separator
|
|
|
sizeLabel.text = ""
|
|
|
sizeValue.text = ""
|
|
|
dateLabel.text = ""
|
|
@@ -70,124 +63,107 @@ class NCViewerMediaDetailView: UIView {
|
|
|
|
|
|
deinit {
|
|
|
print("deinit NCViewerMediaDetailView")
|
|
|
-
|
|
|
- mapView.delegate = nil
|
|
|
- }
|
|
|
-
|
|
|
- func textColor(_ textColor: UIColor?) {
|
|
|
- sizeValue.textColor = textColor
|
|
|
- dateValue.textColor = textColor
|
|
|
- dimValue.textColor = textColor
|
|
|
- lensModelValue.textColor = textColor
|
|
|
- separator.backgroundColor = NCBrandColor.shared.separator
|
|
|
- }
|
|
|
-
|
|
|
- func show(textColor: UIColor?) {
|
|
|
- self.textColor(textColor)
|
|
|
- isHidden = false
|
|
|
- }
|
|
|
-
|
|
|
- func hide() {
|
|
|
- isHidden = true
|
|
|
- }
|
|
|
-
|
|
|
- func isShow() -> Bool {
|
|
|
- return !isHidden
|
|
|
}
|
|
|
|
|
|
- //MARK: - EXIF
|
|
|
-
|
|
|
- func update(metadata: tableMetadata, image: UIImage?, heightMap: CGFloat) {
|
|
|
-
|
|
|
- self.metadata = metadata
|
|
|
- self.heightMap = heightMap
|
|
|
- self.image = image
|
|
|
- self.size = metadata.size
|
|
|
+ func show(metadata: tableMetadata, image: UIImage?, textColor: UIColor?, detailView: UIView) {
|
|
|
+
|
|
|
+ func updateContent(date: Date?, lensModel: String?, location: String?) {
|
|
|
+
|
|
|
+ // Size
|
|
|
+ sizeLabel.text = NSLocalizedString("_size_", comment: "")
|
|
|
+ sizeValue.text = CCUtility.transformedSize(metadata.size)
|
|
|
+ sizeValue.textColor = textColor
|
|
|
+
|
|
|
+ // Date
|
|
|
+ if let date = date {
|
|
|
+ let formatter = DateFormatter()
|
|
|
+ formatter.dateStyle = .full
|
|
|
+ formatter.timeStyle = .medium
|
|
|
+ let dateString = formatter.string(from: date as Date)
|
|
|
+
|
|
|
+ dateLabel.text = NSLocalizedString("_date_", comment: "")
|
|
|
+ dateValue.text = dateString
|
|
|
+ } else {
|
|
|
+ dateLabel.text = NSLocalizedString("_date_", comment: "")
|
|
|
+ dateValue.text = NSLocalizedString("_not_available_", comment: "")
|
|
|
+ }
|
|
|
+ dateValue.textColor = textColor
|
|
|
+
|
|
|
+
|
|
|
+ // Dimension / Duration
|
|
|
+ if metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue {
|
|
|
+ if let image = image {
|
|
|
+ dimLabel.text = NSLocalizedString("_resolution_", comment: "")
|
|
|
+ dimValue.text = "\(Int(image.size.width)) x \(Int(image.size.height))"
|
|
|
+ }
|
|
|
+ } else if metadata.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || metadata.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {
|
|
|
+ if let durationTime = NCManageDatabase.shared.getVideoDurationTime(metadata: metadata) {
|
|
|
+ self.dimLabel.text = NSLocalizedString("_duration_", comment: "")
|
|
|
+ self.dimValue.text = NCUtility.shared.stringFromTime(durationTime)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dimValue.textColor = textColor
|
|
|
+
|
|
|
+ // Model
|
|
|
+ if let lensModel = lensModel {
|
|
|
+ lensModelLabel.text = NSLocalizedString("_model_", comment: "")
|
|
|
+ lensModelValue.text = lensModel
|
|
|
+ lensModelValue.textColor = textColor
|
|
|
+ }
|
|
|
+
|
|
|
+ // Message
|
|
|
+ if metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue && !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) && metadata.session == "" {
|
|
|
+ messageLabel.text = NSLocalizedString("_try_download_full_resolution_", comment: "")
|
|
|
+ } else {
|
|
|
+ messageLabel.text = ""
|
|
|
+ }
|
|
|
+
|
|
|
+ // Location
|
|
|
+ if let location = location {
|
|
|
+ self.locationButton.setTitle(location, for: .normal)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue {
|
|
|
CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensModel) in
|
|
|
-
|
|
|
+
|
|
|
self.latitude = latitude
|
|
|
self.longitude = longitude
|
|
|
self.location = location
|
|
|
- self.date = date as NSDate?
|
|
|
- self.lensModel = lensModel
|
|
|
|
|
|
- self.updateContent()
|
|
|
+ if latitude != -1 && latitude != 0 && longitude != -1 && longitude != 0 {
|
|
|
+
|
|
|
+ let annotation = MKPointAnnotation()
|
|
|
+ annotation.coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
|
|
|
+
|
|
|
+ let mapView = MKMapView.init(frame: self.frame)
|
|
|
+ mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
|
+ mapView.layer.cornerRadius = 6
|
|
|
+ mapView.isZoomEnabled = false
|
|
|
+ mapView.isScrollEnabled = false
|
|
|
+ mapView.isUserInteractionEnabled = false
|
|
|
+ mapView.addAnnotation(annotation)
|
|
|
+ mapView.setRegion(MKCoordinateRegion(center: annotation.coordinate, latitudinalMeters: 500, longitudinalMeters: 500), animated: false)
|
|
|
+ self.addSubview(mapView)
|
|
|
+ }
|
|
|
+
|
|
|
+ updateContent(date: date, lensModel: lensModel, location: location)
|
|
|
+ self.isHidden = false
|
|
|
};
|
|
|
} else {
|
|
|
- self.updateContent()
|
|
|
+ updateContent(date: nil, lensModel: nil, location: nil)
|
|
|
+ self.isHidden = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //MARK: - Map
|
|
|
-
|
|
|
- func updateContent() {
|
|
|
-
|
|
|
- // Size
|
|
|
- sizeLabel.text = NSLocalizedString("_size_", comment: "")
|
|
|
- sizeValue.text = CCUtility.transformedSize(self.size)
|
|
|
-
|
|
|
- // Date
|
|
|
- if let date = self.date {
|
|
|
- let formatter = DateFormatter()
|
|
|
- formatter.dateStyle = .full
|
|
|
- formatter.timeStyle = .medium
|
|
|
- let dateString = formatter.string(from: date as Date)
|
|
|
-
|
|
|
- dateLabel.text = NSLocalizedString("_date_", comment: "")
|
|
|
- dateValue.text = dateString
|
|
|
- } else {
|
|
|
- dateLabel.text = NSLocalizedString("_date_", comment: "")
|
|
|
- dateValue.text = NSLocalizedString("_not_available_", comment: "")
|
|
|
- }
|
|
|
-
|
|
|
- // Dimension / Duration
|
|
|
- if metadata?.classFile == NCCommunicationCommon.typeClassFile.image.rawValue {
|
|
|
- if let image = self.image {
|
|
|
- dimLabel.text = NSLocalizedString("_resolution_", comment: "")
|
|
|
- dimValue.text = "\(Int(image.size.width)) x \(Int(image.size.height))"
|
|
|
- }
|
|
|
- } else if metadata?.classFile == NCCommunicationCommon.typeClassFile.video.rawValue || metadata?.classFile == NCCommunicationCommon.typeClassFile.audio.rawValue {
|
|
|
- if let durationTime = NCManageDatabase.shared.getVideoDurationTime(metadata: metadata) {
|
|
|
- self.dimLabel.text = NSLocalizedString("_duration_", comment: "")
|
|
|
- self.dimValue.text = NCUtility.shared.stringFromTime(durationTime)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Model
|
|
|
- if let lensModel = self.lensModel {
|
|
|
- lensModelLabel.text = NSLocalizedString("_model_", comment: "")
|
|
|
- lensModelValue.text = lensModel
|
|
|
- }
|
|
|
-
|
|
|
- // Message
|
|
|
- if let metadata = self.metadata, metadata.classFile == NCCommunicationCommon.typeClassFile.image.rawValue && !CCUtility.fileProviderStorageExists(metadata.ocId, fileNameView: metadata.fileNameView) && metadata.session == "" {
|
|
|
- messageLabel.text = NSLocalizedString("_try_download_full_resolution_", comment: "")
|
|
|
- } else {
|
|
|
- messageLabel.text = ""
|
|
|
- }
|
|
|
-
|
|
|
- // Map
|
|
|
- if latitude != -1 && latitude != 0 && longitude != -1 && longitude != 0 {
|
|
|
-
|
|
|
- let annotation = MKPointAnnotation()
|
|
|
- annotation.coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
|
|
|
- mapView.layer.cornerRadius = 6
|
|
|
- mapView.isZoomEnabled = false
|
|
|
- mapView.isScrollEnabled = false
|
|
|
- mapView.isUserInteractionEnabled = false
|
|
|
- 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
|
|
|
- }
|
|
|
+ func hide() {
|
|
|
+ self.isHidden = true
|
|
|
}
|
|
|
|
|
|
+ func isShow() -> Bool {
|
|
|
+ return !self.isHidden
|
|
|
+ }
|
|
|
+
|
|
|
//MARK: - Action
|
|
|
|
|
|
@IBAction func touchLocation(_ sender: Any) {
|