Browse Source

Merge remote-tracking branch 'refs/remotes/origin/Coherence'

marinofaggiana 4 years ago
parent
commit
6043e228a7
2 changed files with 44 additions and 27 deletions
  1. 39 22
      iOSClient/Media/NCMedia.swift
  2. 5 5
      iOSClient/Media/NCMediaCommandView.xib

+ 39 - 22
iOSClient/Media/NCMedia.swift

@@ -71,7 +71,7 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         collectionView.register(UINib.init(nibName: "NCGridMediaCell", bundle: nil), forCellWithReuseIdentifier: "gridCell")
         
         collectionView.alwaysBounceVertical = true
-        collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 50, right: 0);
+        collectionView.contentInset = UIEdgeInsets(top: 75, left: 0, bottom: 50, right: 0);
                 
         gridLayout = NCGridMediaLayout()
         gridLayout.itemPerLine = CGFloat(min(CCUtility.getMediaWidthImage(), 5))
@@ -105,9 +105,7 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         mediaCommandView?.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
         mediaCommandView?.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0).isActive = true
         mediaCommandView?.heightAnchor.constraint(equalToConstant: 150).isActive = true
-        if self.metadatas.count == 0 {
-            self.mediaCommandView?.isHidden = true
-        }
+        self.updateMediaControlVisibility()
         
         changeTheming()
     }
@@ -186,15 +184,17 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
         var actions: [NCMenuAction] = []
 
         if !isEditMode {
-            actions.append(
-                NCMenuAction(
-                    title: NSLocalizedString("_select_", comment: ""),
-                    icon: CCGraphics.changeThemingColorImage(UIImage(named: "selectFull"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
-                    action: { menuAction in
-                        self.isEditMode = true
-                    }
+            if metadatas.count > 0{
+                actions.append(
+                    NCMenuAction(
+                        title: NSLocalizedString("_select_", comment: ""),
+                        icon: CCGraphics.changeThemingColorImage(UIImage(named: "selectFull"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+                        action: { menuAction in
+                            self.isEditMode = true
+                        }
+                    )
                 )
-            )
+            }
 
             actions.append(
                 NCMenuAction(
@@ -278,11 +278,7 @@ class NCMedia: UIViewController, DropdownMenuDelegate, DZNEmptyDataSetSource, DZ
                 let metadatas = self.metadatas.filter { $0.ocId != metadata.ocId }
                 self.metadatas = metadatas
                     
-                if self.metadatas.count  > 0 {
-                    self.mediaCommandView?.isHidden = false
-                } else {
-                    self.mediaCommandView?.isHidden = true
-                }
+                self.updateMediaControlVisibility()
                 
                 self.reloadDataSource()
                     
@@ -542,11 +538,8 @@ extension NCMedia {
             DispatchQueue.main.sync {
                 self.metadatas = metadatas
                 
-                if self.metadatas.count  > 0 {
-                    self.mediaCommandView?.isHidden = false
-                } else {
-                    self.mediaCommandView?.isHidden = true
-                }
+                self.updateMediaControlVisibility()
+                
                 self.reloadDataThenPerform {
                     self.mediaCommandTitle()
                 }
@@ -554,6 +547,20 @@ extension NCMedia {
         }
     }
     
+    func updateMediaControlVisibility() {
+        if self.metadatas.count == 0 {
+            if !self.filterTypeFileImage && !self.filterTypeFileVideo {
+                self.mediaCommandView?.isHidden = true
+            } else {
+                self.mediaCommandView?.toggleEmptyView(isEmpty: true)
+                self.mediaCommandView?.isHidden = false
+            }
+        } else {
+            self.mediaCommandView?.toggleEmptyView(isEmpty: false)
+            self.mediaCommandView?.isHidden = false
+        }
+    }
+    
     @objc func searchNewPhotoVideo() {
         
         if newInProgress { return }
@@ -732,6 +739,16 @@ class NCMediaCommandView: UIView {
         title.text = ""
     }
     
+    func toggleEmptyView(isEmpty: Bool) {
+        if isEmpty {
+            self.gradient.isHidden = true
+            self.controlButtonView.isHidden = true
+        } else {
+            self.gradient.isHidden = false
+            self.controlButtonView.isHidden = false
+        }
+    }
+    
     @IBAction func moreButtonPressed(_ sender: UIButton) {
         mediaView?.openMenuButtonMore(sender)
     }

+ 5 - 5
iOSClient/Media/NCMediaCommandView.xib

@@ -15,7 +15,7 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="i1s-Qa-dG1">
-                    <rect key="frame" x="272" y="8" width="40" height="40"/>
+                    <rect key="frame" x="224" y="8" width="40" height="40"/>
                     <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="e3Q-e0-SQa">
                         <rect key="frame" x="0.0" y="0.0" width="40" height="40"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -106,7 +106,7 @@
                     <nil key="highlightedColor"/>
                 </label>
                 <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="enp-xt-Y5y">
-                    <rect key="frame" x="224" y="8" width="40" height="40"/>
+                    <rect key="frame" x="272" y="8" width="40" height="40"/>
                     <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="KKR-Hr-av8">
                         <rect key="frame" x="0.0" y="0.0" width="40" height="40"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -137,12 +137,12 @@
             </subviews>
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <constraints>
-                <constraint firstItem="i1s-Qa-dG1" firstAttribute="leading" secondItem="enp-xt-Y5y" secondAttribute="trailing" constant="8" id="MZA-3x-aIl"/>
-                <constraint firstItem="enp-xt-Y5y" firstAttribute="leading" secondItem="IxY-xH-yZQ" secondAttribute="trailing" constant="8" id="TQe-hh-Fom"/>
+                <constraint firstItem="i1s-Qa-dG1" firstAttribute="leading" secondItem="IxY-xH-yZQ" secondAttribute="trailing" constant="8" id="Owq-aa-Sr6"/>
+                <constraint firstItem="enp-xt-Y5y" firstAttribute="leading" secondItem="i1s-Qa-dG1" secondAttribute="trailing" constant="8" id="XcU-G8-k0a"/>
                 <constraint firstItem="IxY-xH-yZQ" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="8" id="ZhO-pY-Qwi"/>
                 <constraint firstItem="i1s-Qa-dG1" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="cWc-xe-8un"/>
                 <constraint firstItem="IxY-xH-yZQ" firstAttribute="centerY" secondItem="i1s-Qa-dG1" secondAttribute="centerY" id="mJJ-pT-yA3"/>
-                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="i1s-Qa-dG1" secondAttribute="trailing" constant="8" id="wDQ-gZ-xCh"/>
+                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="enp-xt-Y5y" secondAttribute="trailing" constant="8" id="rSU-Dz-YXW"/>
                 <constraint firstItem="enp-xt-Y5y" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="8" id="z6I-sd-mmD"/>
             </constraints>
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>