Browse Source

Improved message detail

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 years ago
parent
commit
93eddc05b3

+ 16 - 14
iOSClient/Viewer/NCViewerMedia/NCViewerMedia.storyboard

@@ -106,6 +106,10 @@
                                                     <constraint firstAttribute="height" constant="1" id="X4S-cr-F2P"/>
                                                 </constraints>
                                             </view>
+                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dJP-ZX-iug">
+                                                <rect key="frame" x="15" y="150" width="384" height="222"/>
+                                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                            </view>
                                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="size" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WXS-Lw-DkI">
                                                 <rect key="frame" x="15" y="36" width="80" height="16"/>
                                                 <constraints>
@@ -166,19 +170,17 @@
                                                 <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                                 <nil key="highlightedColor"/>
                                             </label>
-                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="message" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="03V-nM-JHv">
-                                                <rect key="frame" x="15" y="135" width="384" height="31"/>
+                                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GWF-lf-c8t">
+                                                <rect key="frame" x="15" y="140" width="384" height="30"/>
                                                 <constraints>
-                                                    <constraint firstAttribute="height" constant="31" id="8Ex-vg-76t"/>
+                                                    <constraint firstAttribute="height" constant="30" id="ehZ-sm-6Om"/>
                                                 </constraints>
                                                 <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                                                <color key="textColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                                <nil key="highlightedColor"/>
-                                            </label>
-                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dJP-ZX-iug">
-                                                <rect key="frame" x="15" y="150" width="384" height="222"/>
-                                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                            </view>
+                                                <state key="normal" title="message"/>
+                                                <connections>
+                                                    <action selector="touchMessage:" destination="P8R-4f-zAl" eventType="touchUpInside" id="pa6-KU-ig2"/>
+                                                </connections>
+                                            </button>
                                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oov-9f-Oeu">
                                                 <rect key="frame" x="15" y="372" width="384" height="28"/>
                                                 <fontDescription key="fontDescription" type="system" pointSize="13"/>
@@ -190,11 +192,11 @@
                                         </subviews>
                                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                         <constraints>
+                                            <constraint firstItem="GWF-lf-c8t" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="0Ub-x3-dQs"/>
                                             <constraint firstItem="WXS-Lw-DkI" firstAttribute="top" secondItem="HRq-3M-yeb" secondAttribute="bottom" constant="15" id="2RK-lk-nQe"/>
                                             <constraint firstItem="uaE-Lv-t0Q" firstAttribute="top" secondItem="Son-CZ-zFa" secondAttribute="bottom" constant="10" id="3jD-4U-zwi"/>
                                             <constraint firstItem="XLb-0a-du9" firstAttribute="centerY" secondItem="WXS-Lw-DkI" secondAttribute="centerY" id="6k5-Ur-AKZ"/>
                                             <constraint firstAttribute="trailing" secondItem="n1C-OB-gq2" secondAttribute="trailing" constant="15" id="6o9-lb-LZc"/>
-                                            <constraint firstItem="03V-nM-JHv" firstAttribute="top" secondItem="uYI-ic-d8g" secondAttribute="bottom" constant="5" id="7Uh-9y-EY1"/>
                                             <constraint firstAttribute="trailing" secondItem="dJP-ZX-iug" secondAttribute="trailing" constant="15" id="AbM-Mc-iC7"/>
                                             <constraint firstAttribute="trailing" secondItem="HRq-3M-yeb" secondAttribute="trailing" constant="15" id="DIq-e4-T4P"/>
                                             <constraint firstAttribute="height" constant="400" id="HzF-N7-BQ8"/>
@@ -203,18 +205,18 @@
                                             <constraint firstItem="uYI-ic-d8g" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="MTM-eQ-CXC"/>
                                             <constraint firstItem="dJP-ZX-iug" firstAttribute="top" secondItem="ix8-uQ-chU" secondAttribute="bottom" constant="20" id="Mxt-43-sew"/>
                                             <constraint firstItem="ix8-uQ-chU" firstAttribute="centerY" secondItem="uYI-ic-d8g" secondAttribute="centerY" id="Oae-3R-C5Z"/>
+                                            <constraint firstAttribute="trailing" secondItem="GWF-lf-c8t" secondAttribute="trailing" constant="15" id="QJp-6z-62f"/>
                                             <constraint firstItem="oov-9f-Oeu" firstAttribute="top" secondItem="dJP-ZX-iug" secondAttribute="bottom" id="SXt-nb-5Bf"/>
                                             <constraint firstAttribute="trailing" secondItem="ix8-uQ-chU" secondAttribute="trailing" constant="15" id="TIp-le-wVn"/>
                                             <constraint firstItem="hBd-KD-Jq5" firstAttribute="centerY" secondItem="Son-CZ-zFa" secondAttribute="centerY" id="Tez-na-gqC"/>
                                             <constraint firstItem="HRq-3M-yeb" firstAttribute="top" secondItem="P8R-4f-zAl" secondAttribute="top" constant="20" id="UF1-fO-9hX"/>
-                                            <constraint firstItem="03V-nM-JHv" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="Wkx-6P-u9F"/>
-                                            <constraint firstAttribute="trailing" secondItem="03V-nM-JHv" secondAttribute="trailing" constant="15" id="YYB-CF-RWS"/>
                                             <constraint firstAttribute="bottom" secondItem="oov-9f-Oeu" secondAttribute="bottom" id="YuK-2v-kzk"/>
                                             <constraint firstItem="hBd-KD-Jq5" firstAttribute="leading" secondItem="Son-CZ-zFa" secondAttribute="trailing" constant="10" id="YuO-13-KTh"/>
                                             <constraint firstItem="WXS-Lw-DkI" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="bRd-bi-Imh"/>
                                             <constraint firstItem="uYI-ic-d8g" firstAttribute="top" secondItem="uaE-Lv-t0Q" secondAttribute="bottom" constant="10" id="bkM-Ic-ZoE"/>
                                             <constraint firstItem="dJP-ZX-iug" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="ife-ps-Lx5"/>
                                             <constraint firstItem="oov-9f-Oeu" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="lXY-IM-uQB"/>
+                                            <constraint firstItem="GWF-lf-c8t" firstAttribute="top" secondItem="ix8-uQ-chU" secondAttribute="bottom" constant="10" id="m7R-Xs-f01"/>
                                             <constraint firstAttribute="trailing" secondItem="oov-9f-Oeu" secondAttribute="trailing" constant="15" id="mpQ-4V-Yfc"/>
                                             <constraint firstItem="HRq-3M-yeb" firstAttribute="leading" secondItem="P8R-4f-zAl" secondAttribute="leading" constant="15" id="oJB-7U-UpU"/>
                                             <constraint firstAttribute="trailing" secondItem="XLb-0a-du9" secondAttribute="trailing" constant="15" id="p7C-ox-HFw"/>
@@ -234,7 +236,7 @@
                                             <outlet property="lensModelValue" destination="ix8-uQ-chU" id="GNF-8F-10P"/>
                                             <outlet property="locationButton" destination="oov-9f-Oeu" id="cGg-Gb-m5S"/>
                                             <outlet property="mapContainer" destination="dJP-ZX-iug" id="9xS-le-Hhe"/>
-                                            <outlet property="messageLabel" destination="03V-nM-JHv" id="dpK-Iy-LCD"/>
+                                            <outlet property="messageButton" destination="GWF-lf-c8t" id="cls-X9-Urf"/>
                                             <outlet property="separator" destination="HRq-3M-yeb" id="ENP-xc-AWZ"/>
                                             <outlet property="sizeLabel" destination="WXS-Lw-DkI" id="JG0-G0-oHg"/>
                                             <outlet property="sizeValue" destination="XLb-0a-du9" id="9jm-Ku-sgt"/>

+ 25 - 8
iOSClient/Viewer/NCViewerMedia/NCViewerMediaDetailView.swift

@@ -25,6 +25,10 @@ import UIKit
 import MapKit
 import NCCommunication
 
+public protocol NCViewerMediaDetailViewDelegate {
+    func downloadFullResolution()
+}
+
 class NCViewerMediaDetailView: UIView {
     
     @IBOutlet weak var separator: UIView!
@@ -36,7 +40,7 @@ class NCViewerMediaDetailView: UIView {
     @IBOutlet weak var dimValue: UILabel!
     @IBOutlet weak var lensModelLabel: UILabel!
     @IBOutlet weak var lensModelValue: UILabel!
-    @IBOutlet weak var messageLabel: UILabel!
+    @IBOutlet weak var messageButton: UIButton!
     @IBOutlet weak var mapContainer: UIView!
     @IBOutlet weak var locationButton: UIButton!
     
@@ -45,8 +49,9 @@ class NCViewerMediaDetailView: UIView {
     var location: String?
     var date: Date?
     var lensModel: String?
-    
+    var metadata: tableMetadata?
     var mapView: MKMapView?
+    var delegate: NCViewerMediaDetailViewDelegate?
         
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -60,8 +65,7 @@ class NCViewerMediaDetailView: UIView {
         dimValue.text = ""
         lensModelLabel.text = ""
         lensModelValue.text = ""
-        messageLabel.text = ""
-        messageLabel.textColor = NCBrandColor.shared.brand
+        messageButton.setTitle("" , for: .normal)
         locationButton.setTitle("" , for: .normal)
     }
     
@@ -72,13 +76,15 @@ class NCViewerMediaDetailView: UIView {
         self.mapView = nil
     }
     
-    func show(metadata: tableMetadata, image: UIImage?, textColor: UIColor?, latitude: Double, longitude: Double, location: String?, date: Date?, lensModel: String?) {
+    func show(metadata: tableMetadata, image: UIImage?, textColor: UIColor?, latitude: Double, longitude: Double, location: String?, date: Date?, lensModel: String?, delegate: NCViewerMediaDetailViewDelegate?) {
                         
+        self.metadata = metadata
         self.latitude = latitude
         self.longitude = longitude
         self.location = location
         self.date = date
         self.lensModel = lensModel
+        self.delegate = delegate
         
         if mapView == nil && (latitude != -1 && latitude != 0 && longitude != -1 && longitude != 0) {
             
@@ -149,14 +155,20 @@ class NCViewerMediaDetailView: UIView {
         
         // 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: "")
+            messageButton.setTitle(NSLocalizedString("_try_download_full_resolution_", comment: ""), for: .normal)
+            messageButton.isHidden = false
         } else {
-            messageLabel.text = ""
+            messageButton.setTitle("" , for: .normal)
+            messageButton.isHidden = true
         }
         
         // Location
         if let location = location {
-            self.locationButton.setTitle(location, for: .normal)
+            locationButton.setTitle(location, for: .normal)
+            locationButton.isHidden = false
+        } else {
+            locationButton.setTitle("" , for: .normal)
+            locationButton.isHidden = true
         }
         
         self.isHidden = false
@@ -197,6 +209,11 @@ class NCViewerMediaDetailView: UIView {
         
     }
     
+    @IBAction func touchMessage(_ sender: Any) {
+        
+        delegate?.downloadFullResolution()
+    }
+    
     //MARK: -
     func secondsToHoursMinutesSeconds (seconds : Int) -> (Int, Int, Int) {
       return (seconds / 3600, (seconds % 3600) / 60, (seconds % 3600) % 60)

+ 11 - 2
iOSClient/Viewer/NCViewerMedia/NCViewerMediaZoom.swift

@@ -277,11 +277,12 @@ extension NCViewerMediaZoom {
             if (latitude != -1 && latitude != 0 && longitude != -1 && longitude != 0) {
                 self.detailViewHeighConstraint.constant = self.view.bounds.height / 2
             } else {
+                //let height = self.detailView.messageButton.frame.origin.y + self.detailView.messageButton.frame.height
                 self.detailViewHeighConstraint.constant = 170
             }
             self.view.layoutIfNeeded()
             
-           self.detailView.show(metadata:self.metadata, image: self.image, textColor: self.viewerMedia?.textColor, latitude: latitude, longitude: longitude, location: location, date: date, lensModel: lensModel)
+           self.detailView.show(metadata:self.metadata, image: self.image, textColor: self.viewerMedia?.textColor, latitude: latitude, longitude: longitude, location: location, date: date, lensModel: lensModel, delegate: self)
                 
             if let image = self.imageVideoContainer.image {
                 let ratioW = self.imageVideoContainer.frame.width / image.size.width
@@ -328,7 +329,7 @@ extension NCViewerMediaZoom {
         
         if self.detailView.isShow() {
             CCUtility.setExif(metadata) { (latitude, longitude, location, date, lensModel) in
-                self.detailView.show(metadata:self.metadata, image: self.image, textColor: self.viewerMedia?.textColor, latitude: latitude, longitude: longitude, location: location, date: date, lensModel: lensModel)
+                self.detailView.show(metadata:self.metadata, image: self.image, textColor: self.viewerMedia?.textColor, latitude: latitude, longitude: longitude, location: location, date: date, lensModel: lensModel, delegate: self)
             }
         }
     }
@@ -397,6 +398,14 @@ extension NCViewerMediaZoom: UIScrollViewDelegate {
     }
 }
 
+extension NCViewerMediaZoom: NCViewerMediaDetailViewDelegate  {
+    
+    func downloadFullResolution() {
+        closeDetail()
+        NCNetworking.shared.download(metadata: metadata, selector: "") { (_) in }
+    }
+}
+
 //MARK: -
 
 class imageVideoContainerView: UIImageView {