marinofaggiana 4 yıl önce
ebeveyn
işleme
87fa9b18da

+ 22 - 2
iOSClient/Main/Cell/NCGridCell.swift

@@ -100,8 +100,28 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         buttonMore.setImage(image, for: .normal)
     }
     
-    func hideButtonMore() {
-        buttonMore.isHidden = true
+    func hideButtonMore(_ status: Bool) {
+        buttonMore.isHidden = status
+    }
+    
+    func selectMode(_ status: Bool) {
+        if status {
+            imageSelect.isHidden = false
+        } else {
+            imageSelect.isHidden = true
+            imageVisualEffect.isHidden = true
+        }
+    }
+    
+    func selected(_ status: Bool) {
+        if status {
+            imageSelect.image = NCCollectionCommon.images.cellCheckedYes
+            imageVisualEffect.isHidden = false
+            imageVisualEffect.alpha = 0.4
+        } else {
+            imageSelect.isHidden = true
+            imageVisualEffect.isHidden = true
+        }
     }
 }
 

+ 24 - 4
iOSClient/Main/Cell/NCListCell.swift

@@ -40,7 +40,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
 
     @IBOutlet weak var imageShared: UIImageView!
     @IBOutlet weak var buttonShared: UIButton!
-    @IBOutlet weak var sharedLeftConstraint: NSLayoutConstraint!
 
     @IBOutlet weak var imageMore: UIImageView!
     @IBOutlet weak var buttonMore: UIButton!
@@ -111,15 +110,36 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         imageMore.image = image
     }
     
-    func hideButtonMore() {
-        imageMore.isHidden = true
-        sharedLeftConstraint.constant = 5
+    func hideButtonMore(_ status: Bool) {
+        imageMore.isHidden = status
+        buttonMore.isHidden = status
     }
     
     func hideButtonShare(_ status: Bool) {
         imageShared.isHidden = status
         buttonShared.isHidden = status
     }
+    
+    func selectMode(_ status: Bool) {
+        if status {
+            imageItemLeftConstraint.constant = 45
+            imageSelect.isHidden = false
+        } else {
+            imageItemLeftConstraint.constant = 10
+            imageSelect.isHidden = true
+            backgroundView = nil
+        }
+    }
+    
+    func selected(_ status: Bool) {
+        if status {
+            imageSelect.image = NCCollectionCommon.images.cellCheckedYes
+            backgroundView = NCUtility.shared.cellBlurEffect(with: self.bounds)
+        } else {
+            imageSelect.image = NCCollectionCommon.images.cellCheckedNo
+            backgroundView = nil
+        }
+    }
 }
 
 protocol NCListCellDelegate {

+ 9 - 10
iOSClient/Main/Cell/NCListCell.xib

@@ -18,21 +18,21 @@
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="w2m-Vw-hpd" userLabel="ImageItem">
-                        <rect key="frame" x="45" y="10" width="40" height="40"/>
+                        <rect key="frame" x="10" y="10" width="40" height="40"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="40" id="Dpd-Xj-z4U"/>
                             <constraint firstAttribute="width" constant="40" id="v0e-MW-EeE"/>
                         </constraints>
                     </imageView>
                     <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="7Q9-Tv-9yo" userLabel="imageStatus">
-                        <rect key="frame" x="40" y="40" width="15" height="15"/>
+                        <rect key="frame" x="5" y="40" width="15" height="15"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="15" id="f8p-9B-Rgw"/>
                             <constraint firstAttribute="height" constant="15" id="ndy-wW-xdL"/>
                         </constraints>
                     </imageView>
                     <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="C4K-Nv-phA" userLabel="imageFavorite">
-                        <rect key="frame" x="75" y="5" width="15" height="15"/>
+                        <rect key="frame" x="40" y="5" width="15" height="15"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="15" id="hXC-b9-Q2V"/>
                             <constraint firstAttribute="height" constant="15" id="mPH-zc-eH5"/>
@@ -46,20 +46,20 @@
                         </constraints>
                     </imageView>
                     <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="H4E-G2-C1H" userLabel="imageLocal">
-                        <rect key="frame" x="75" y="40" width="15" height="15"/>
+                        <rect key="frame" x="40" y="40" width="15" height="15"/>
                         <constraints>
                             <constraint firstAttribute="width" constant="15" id="BEs-Rd-5Ov"/>
                             <constraint firstAttribute="height" constant="15" id="N8h-3R-JpE"/>
                         </constraints>
                     </imageView>
                     <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UtT-L6-mgW" userLabel="labelTitle">
-                        <rect key="frame" x="95" y="13" width="415" height="18"/>
+                        <rect key="frame" x="60" y="13" width="450" height="18"/>
                         <fontDescription key="fontDescription" type="system" pointSize="15"/>
                         <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <nil key="highlightedColor"/>
                     </label>
                     <label opaque="NO" userInteractionEnabled="NO" tag="102" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AXX-71-9Q6" userLabel="labelInfo">
-                        <rect key="frame" x="95" y="31" width="415" height="15"/>
+                        <rect key="frame" x="60" y="31" width="450" height="15"/>
                         <fontDescription key="fontDescription" type="system" pointSize="12"/>
                         <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
                         <nil key="highlightedColor"/>
@@ -100,10 +100,10 @@
                         </constraints>
                     </imageView>
                     <progressView hidden="YES" opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="m2p-oJ-j15">
-                        <rect key="frame" x="95" y="49" width="415" height="4"/>
+                        <rect key="frame" x="60" y="49" width="450" height="4"/>
                     </progressView>
                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Egg-cb-EhZ" userLabel="separator">
-                        <rect key="frame" x="85" y="59" width="515" height="1"/>
+                        <rect key="frame" x="50" y="59" width="550" height="1"/>
                         <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
@@ -135,7 +135,7 @@
                 <constraint firstItem="Gu8-oz-zWa" firstAttribute="bottom" secondItem="AXX-71-9Q6" secondAttribute="bottom" constant="14" id="d06-sn-I3Y"/>
                 <constraint firstItem="jc6-Vg-TaS" firstAttribute="centerX" secondItem="o4u-0K-Qpt" secondAttribute="centerX" id="fAq-0d-u57"/>
                 <constraint firstItem="Gu8-oz-zWa" firstAttribute="trailing" secondItem="Egg-cb-EhZ" secondAttribute="trailing" id="k8f-bU-D6I"/>
-                <constraint firstItem="w2m-Vw-hpd" firstAttribute="leading" secondItem="Gu8-oz-zWa" secondAttribute="leading" constant="45" id="mBb-ff-7HD"/>
+                <constraint firstItem="w2m-Vw-hpd" firstAttribute="leading" secondItem="Gu8-oz-zWa" secondAttribute="leading" constant="10" id="mBb-ff-7HD"/>
                 <constraint firstItem="w2m-Vw-hpd" firstAttribute="leading" secondItem="7Q9-Tv-9yo" secondAttribute="trailing" constant="-10" id="mon-aq-gcP"/>
                 <constraint firstItem="UtT-L6-mgW" firstAttribute="top" secondItem="Gu8-oz-zWa" secondAttribute="top" constant="13" id="nrY-2F-QZ2"/>
                 <constraint firstItem="Gu8-oz-zWa" firstAttribute="trailing" secondItem="AXX-71-9Q6" secondAttribute="trailing" constant="90" id="p0M-zU-aDG"/>
@@ -161,7 +161,6 @@
                 <outlet property="labelTitle" destination="UtT-L6-mgW" id="Xv6-zM-2v1"/>
                 <outlet property="progressView" destination="m2p-oJ-j15" id="yFv-KS-nEy"/>
                 <outlet property="separator" destination="Egg-cb-EhZ" id="uhq-Nc-z8K"/>
-                <outlet property="sharedLeftConstraint" destination="tOD-Sd-Uhy" id="JCh-1t-rwp"/>
             </connections>
             <point key="canvasLocation" x="97.599999999999994" y="129.53523238380811"/>
         </collectionViewCell>

+ 8 - 18
iOSClient/Main/NCCollectionViewCommon.swift

@@ -1425,20 +1425,14 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             }
             
             if isEditMode {
-                cell.imageItemLeftConstraint.constant = 45
-                cell.imageSelect.isHidden = false
-                
+                cell.selectMode(true)
                 if selectOcId.contains(metadata.ocId) {
-                    cell.imageSelect.image = NCCollectionCommon.images.cellCheckedYes
-                    cell.backgroundView = NCUtility.shared.cellBlurEffect(with: cell.bounds)
+                    cell.selected(true)
                 } else {
-                    cell.imageSelect.image = NCCollectionCommon.images.cellCheckedNo
-                    cell.backgroundView = nil
+                    cell.selected(false)
                 }
             } else {
-                cell.imageItemLeftConstraint.constant = 10
-                cell.imageSelect.isHidden = true
-                cell.backgroundView = nil
+                cell.selectMode(false)
             }
             
             // Transfer
@@ -1583,18 +1577,14 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             }
             
             if isEditMode {
-                cell.imageSelect.isHidden = false
+                cell.selectMode(true)
                 if selectOcId.contains(metadata.ocId) {
-                    cell.imageSelect.image = NCCollectionCommon.images.cellCheckedYes
-                    cell.imageVisualEffect.isHidden = false
-                    cell.imageVisualEffect.alpha = 0.4
+                    cell.selected(true)
                 } else {
-                    cell.imageSelect.isHidden = true
-                    cell.imageVisualEffect.isHidden = true
+                    cell.selected(false)
                 }
             } else {
-                cell.imageSelect.isHidden = true
-                cell.imageVisualEffect.isHidden = true
+                cell.selectMode(false)
             }
             
             // Transfer

+ 4 - 2
iOSClient/Select/NCSelect.swift

@@ -583,9 +583,11 @@ extension NCSelect: UICollectionViewDataSource {
                 }
             }
             
-            cell.imageItemLeftConstraint.constant = 10
             cell.imageSelect.isHidden = true
             cell.backgroundView = nil
+            cell.hideButtonMore(true)
+            cell.hideButtonShare(true)
+            cell.selectMode(false)
     
             // Live Photo
             if metadata.livePhoto {
@@ -683,7 +685,7 @@ extension NCSelect: UICollectionViewDataSource {
             
             cell.imageSelect.isHidden = true
             cell.backgroundView = nil
-            cell.hideButtonMore()
+            cell.hideButtonMore(true)
 
             // Live Photo
             if metadata.livePhoto {

+ 11 - 0
iOSClient/Trash/Cell/NCTrashListCell.swift

@@ -65,6 +65,17 @@ class NCTrashListCell: UICollectionViewCell {
     @IBAction func touchUpInsideRestore(_ sender: Any) {
         delegate?.tapRestoreListItem(with: objectId, sender: sender)
     }
+    
+    func selectMode(_ status: Bool) {
+        if status {
+            imageItemLeftConstraint.constant = 45
+            imageSelect.isHidden = false
+        } else {
+            imageItemLeftConstraint.constant = 10
+            imageSelect.isHidden = true
+            backgroundView = nil
+        }
+    }
 }
 
 protocol NCTrashListCellDelegate {

+ 2 - 6
iOSClient/Trash/NCTrash.swift

@@ -496,9 +496,7 @@ extension NCTrash: UICollectionViewDataSource {
             }
             
             if isEditMode {
-                cell.imageItemLeftConstraint.constant = 45
-                cell.imageSelect.isHidden = false
-                
+                cell.selectMode(true)
                 if selectOcId.contains(tableTrash.fileId) {
                     cell.imageSelect.image = CCGraphics.scale(UIImage.init(named: "checkedYes"), to: CGSize(width: 50, height: 50), isAspectRation: true)
                     cell.backgroundView = NCUtility.shared.cellBlurEffect(with: cell.bounds)
@@ -507,9 +505,7 @@ extension NCTrash: UICollectionViewDataSource {
                     cell.backgroundView = nil
                 }
             } else {
-                cell.imageItemLeftConstraint.constant = 10
-                cell.imageSelect.isHidden = true
-                cell.backgroundView = nil
+                cell.selectMode(false)
             }
             
             return cell