marinofaggiana 4 жил өмнө
parent
commit
9be5a2f484

+ 22 - 13
iOSClient/EmptyView/NCEmpty.swift

@@ -13,28 +13,37 @@ class NCEmpty: NSObject {
     var emptyView: NCEmptyView?
     var collectioView: UICollectionView?
     
-    init(collectioView: UICollectionView, image: UIImage, title: String, description: String) {
+    init(collectioView: UICollectionView, image: UIImage?, title: String, description: String) {
         super.init()
 
         self.collectioView = collectioView
-        emptyView = UINib(nibName: "NCEmptyView", bundle: nil).instantiate(withOwner: self, options: nil).first as? NCEmptyView
+        if let emptyView = UINib(nibName: "NCEmptyView", bundle: nil).instantiate(withOwner: self, options: nil).first as? NCEmptyView {
+        
+            self.emptyView = emptyView
             
-        emptyView?.emptyImage.image = image
-        emptyView?.emptyTtle.text = title
-        emptyView?.emptyDescription.text = description
-                        
-        emptyView?.leftAnchor.constraint(equalTo: collectioView.leftAnchor).isActive = true
-        emptyView?.rightAnchor.constraint(equalTo: collectioView.rightAnchor).isActive = true
-        emptyView?.topAnchor.constraint(equalTo: collectioView.topAnchor).isActive = true
-        emptyView?.bottomAnchor.constraint(equalTo: collectioView.bottomAnchor).isActive = true
+            emptyView.frame =  CGRect(x:0, y: 0, width:300, height:300)
+            //emptyView.isHidden = true
+            emptyView.translatesAutoresizingMaskIntoConstraints = false
+
+            emptyView.emptyImage.image = image
+            emptyView.emptyTtle.text = NSLocalizedString(title, comment: "")
+            emptyView.emptyDescription.text = NSLocalizedString(description, comment: "")
+                       
+            collectioView.addSubview(emptyView)
+
+            emptyView.centerXAnchor.constraint(equalTo: collectioView.centerXAnchor, constant: 0).isActive = true
+            emptyView.topAnchor.constraint(equalTo: collectioView.topAnchor).isActive = true
+            
+            emptyView.layoutIfNeeded()
+        }
     }
     
     func reload() {
         let items = collectioView?.numberOfItems(inSection: 0)
-        if items == 0 && emptyView != nil {
-            collectioView?.addSubview(emptyView!)
+        if items == 0 {
+            emptyView?.isHidden = false
         } else {
-            emptyView!.removeFromSuperview()
+            //emptyView?.isHidden = true
         }
     }
 }

+ 9 - 9
iOSClient/EmptyView/NCEmptyView.xib

@@ -16,20 +16,20 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="W3d-Us-kU4">
-                    <rect key="frame" x="10" y="0.0" width="300" height="300"/>
+                    <rect key="frame" x="85" y="0.0" width="150" height="150"/>
                     <constraints>
-                        <constraint firstAttribute="height" constant="300" id="A8B-y7-Fre"/>
-                        <constraint firstAttribute="width" constant="300" id="g0C-P6-l3d"/>
+                        <constraint firstAttribute="height" constant="150" id="A8B-y7-Fre"/>
+                        <constraint firstAttribute="width" constant="150" id="g0C-P6-l3d"/>
                     </constraints>
                 </imageView>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="crs-DO-owR">
-                    <rect key="frame" x="10" y="340" width="300" height="20.5"/>
+                    <rect key="frame" x="0.0" y="190" width="320" height="20.5"/>
                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                     <nil key="textColor"/>
                     <nil key="highlightedColor"/>
                 </label>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D4p-sI-mNB">
-                    <rect key="frame" x="10" y="400.5" width="300" height="20.5"/>
+                    <rect key="frame" x="0.0" y="250.5" width="320" height="20.5"/>
                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                     <nil key="textColor"/>
                     <nil key="highlightedColor"/>
@@ -38,12 +38,12 @@
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
             <color key="backgroundColor" systemColor="systemBackgroundColor"/>
             <constraints>
-                <constraint firstItem="crs-DO-owR" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="10" id="CMU-Tp-bUM"/>
+                <constraint firstItem="crs-DO-owR" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="CMU-Tp-bUM"/>
                 <constraint firstItem="W3d-Us-kU4" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="Fyb-so-iAw"/>
-                <constraint firstItem="D4p-sI-mNB" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="10" id="egV-G4-wax"/>
-                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="crs-DO-owR" secondAttribute="trailing" constant="10" id="hHl-iN-Gev"/>
+                <constraint firstItem="D4p-sI-mNB" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="egV-G4-wax"/>
+                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="crs-DO-owR" secondAttribute="trailing" id="hHl-iN-Gev"/>
                 <constraint firstItem="crs-DO-owR" firstAttribute="top" secondItem="W3d-Us-kU4" secondAttribute="bottom" constant="40" id="hLN-L6-0gH"/>
-                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="D4p-sI-mNB" secondAttribute="trailing" constant="10" id="imv-AK-mqu"/>
+                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="D4p-sI-mNB" secondAttribute="trailing" id="imv-AK-mqu"/>
                 <constraint firstItem="W3d-Us-kU4" firstAttribute="centerX" secondItem="vUN-kp-3ea" secondAttribute="centerX" id="kma-1Q-c3Q"/>
                 <constraint firstItem="D4p-sI-mNB" firstAttribute="top" secondItem="crs-DO-owR" secondAttribute="bottom" constant="40" id="zbi-5P-raN"/>
             </constraints>

+ 2 - 0
iOSClient/Files/NCFiles.swift

@@ -80,6 +80,8 @@ class NCFiles: NCCollectionViewCommon  {
             DispatchQueue.main.async {
                 self.refreshControl.endRefreshing()
                 self.collectionView.reloadData()
+                
+                self.empty?.reload()
             }
         }
     }

+ 5 - 7
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -24,7 +24,7 @@
 import Foundation
 import NCCommunication
 
-class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate, UIAdaptivePresentationControllerDelegate  {
+class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, UIAdaptivePresentationControllerDelegate  {
 
     @IBOutlet weak var collectionView: UICollectionView!
 
@@ -32,6 +32,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
 
     internal let refreshControl = UIRefreshControl()
     internal var searchController: UISearchController?
+    internal var empty: NCEmpty?
     
     internal var serverUrl: String = ""
     internal var isEncryptedFolder = false
@@ -113,9 +114,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         refreshControl.tintColor = .gray
         refreshControl.addTarget(self, action: #selector(reloadDataSourceNetworkRefreshControl), for: .valueChanged)
         
-        // empty Data Source
-        self.collectionView.emptyDataSetDelegate = self
-        self.collectionView.emptyDataSetSource = self
+        // Empty
+        empty = NCEmpty.init(collectioView: collectionView, image: emptyImage, title: emptyTitle, description: emptyDescription)
         
         // 3D Touch peek and pop
         if traitCollection.forceTouchCapability == .available {
@@ -551,9 +551,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         
     // MARK: - Empty
     
-    func backgroundColor(forEmptyDataSet scrollView: UIScrollView) -> UIColor? {
-        return NCBrandColor.sharedInstance.backgroundView
-    }
+    
     
     func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {