marinofaggiana 4 years ago
parent
commit
5ff3d190b3

+ 17 - 5
iOSClient/EmptyView/NCEmptyDataSet.swift

@@ -8,15 +8,22 @@
 
 import Foundation
 
+@objc public protocol NCEmptyDataSetDelegate {
+    @objc optional func emptyDataSetView(_ view: NCEmptyView)
+}
+
 class NCEmptyDataSet: NSObject {
     
     var emptyView: NCEmptyView?
+    var delegate: NCEmptyDataSetDelegate?
+
     
-    init(view: UIView, image: UIImage?, title: String, description: String, offset: CGFloat) {
+    init(view: UIView, image: UIImage?, title: String, description: String, offset: CGFloat = 0, delegate: NCEmptyDataSetDelegate?) {
         super.init()
 
         if let emptyView = UINib(nibName: "NCEmptyView", bundle: nil).instantiate(withOwner: self, options: nil).first as? NCEmptyView {
         
+            self.delegate = delegate
             self.emptyView = emptyView
             
             emptyView.frame =  CGRect(x:0, y: 0, width:300, height:300)
@@ -24,9 +31,11 @@ class NCEmptyDataSet: NSObject {
             emptyView.translatesAutoresizingMaskIntoConstraints = false
 
             emptyView.emptyImage.image = image
-            emptyView.emptyTtle.text = NSLocalizedString(title, comment: "")
+            emptyView.emptyTitle.text = NSLocalizedString(title, comment: "")
+            emptyView.emptyTitle.sizeToFit()
             emptyView.emptyDescription.text = NSLocalizedString(description, comment: "")
-                       
+            emptyView.emptyDescription.sizeToFit()
+            
             view.addSubview(emptyView)
 
             let constantY: CGFloat = (view.frame.height - emptyView.frame.height) / 2 - offset
@@ -37,6 +46,9 @@ class NCEmptyDataSet: NSObject {
     }
     
     func numberOfItemsInSection(_ numberItems: Int) {
+        if let emptyView = emptyView {
+            self.delegate?.emptyDataSetView?(emptyView)
+        }
         if numberItems == 0 {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
                 self.emptyView?.isHidden = false
@@ -49,10 +61,10 @@ class NCEmptyDataSet: NSObject {
     }
 }
 
-class NCEmptyView: UIView {
+public class NCEmptyView: UIView {
     
     @IBOutlet weak var emptyImage: UIImageView!
-    @IBOutlet weak var emptyTtle: UILabel!
+    @IBOutlet weak var emptyTitle: UILabel!
     @IBOutlet weak var emptyDescription: UILabel!
 }
 

+ 17 - 11
iOSClient/EmptyView/NCEmptyView.xib

@@ -23,15 +23,18 @@
                     </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="0.0" y="190" width="320" height="20.5"/>
-                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                    <nil key="textColor"/>
+                    <rect key="frame" x="0.0" y="180" width="320" height="24"/>
+                    <fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
+                    <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <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="0.0" y="250.5" width="320" height="20.5"/>
-                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                    <nil key="textColor"/>
+                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D4p-sI-mNB">
+                    <rect key="frame" x="0.0" y="224" width="320" height="17"/>
+                    <constraints>
+                        <constraint firstAttribute="height" relation="lessThanOrEqual" constant="50" id="u7B-jW-bWI"/>
+                    </constraints>
+                    <fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="14"/>
+                    <color key="textColor" systemColor="systemGrayColor"/>
                     <nil key="highlightedColor"/>
                 </label>
             </subviews>
@@ -42,22 +45,25 @@
                 <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" 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="crs-DO-owR" firstAttribute="top" secondItem="W3d-Us-kU4" secondAttribute="bottom" constant="30" id="hLN-L6-0gH"/>
                 <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"/>
+                <constraint firstItem="D4p-sI-mNB" firstAttribute="top" secondItem="crs-DO-owR" secondAttribute="bottom" constant="20" id="zbi-5P-raN"/>
             </constraints>
             <connections>
                 <outlet property="emptyDescription" destination="D4p-sI-mNB" id="4Rw-TK-oGc"/>
                 <outlet property="emptyImage" destination="W3d-Us-kU4" id="xtd-nV-OUc"/>
-                <outlet property="emptyTtle" destination="crs-DO-owR" id="uoT-Bx-5Uw"/>
+                <outlet property="emptyTitle" destination="crs-DO-owR" id="IkU-6d-P64"/>
             </connections>
-            <point key="canvasLocation" x="138.75" y="75"/>
+            <point key="canvasLocation" x="135" y="38.75"/>
         </view>
     </objects>
     <resources>
         <systemColor name="systemBackgroundColor">
             <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
         </systemColor>
+        <systemColor name="systemGrayColor">
+            <color red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+        </systemColor>
     </resources>
 </document>

+ 2 - 2
iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

@@ -24,7 +24,7 @@
 import Foundation
 import NCCommunication
 
-class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, UIAdaptivePresentationControllerDelegate  {
+class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSet  {
 
     @IBOutlet weak var collectionView: UICollectionView!
 
@@ -115,7 +115,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         refreshControl.addTarget(self, action: #selector(reloadDataSourceNetworkRefreshControl), for: .valueChanged)
         
         // Empty
-        emptyDataSet = NCEmptyDataSet.init(view: collectionView, image: emptyImage, title: emptyTitle, description: emptyDescription, offset: 100)
+        emptyDataSet = NCEmptyDataSet.init(view: collectionView, image: emptyImage, title: emptyTitle, description: emptyDescription, offset: 100, delegate: self)
         
         // 3D Touch peek and pop
         if traitCollection.forceTouchCapability == .available {