marinofaggiana 4 年之前
父节点
当前提交
2eaef74e03
共有 2 个文件被更改,包括 16 次插入53 次删除
  1. 1 4
      iOSClient/EmptyView/NCEmptyDataSet.swift
  2. 15 49
      iOSClient/Main/Colleaction Common/NCCollectionViewCommon.swift

+ 1 - 4
iOSClient/EmptyView/NCEmptyDataSet.swift

@@ -18,7 +18,7 @@ class NCEmptyDataSet: NSObject {
     var delegate: NCEmptyDataSetDelegate?
 
     
-    init(view: UIView, image: UIImage?, title: String, description: String, offset: CGFloat = 0, delegate: NCEmptyDataSetDelegate?) {
+    init(view: UIView, offset: CGFloat = 0, delegate: NCEmptyDataSetDelegate?) {
         super.init()
 
         if let emptyView = UINib(nibName: "NCEmptyView", bundle: nil).instantiate(withOwner: self, options: nil).first as? NCEmptyView {
@@ -30,10 +30,7 @@ class NCEmptyDataSet: NSObject {
             emptyView.isHidden = true
             emptyView.translatesAutoresizingMaskIntoConstraints = false
 
-            emptyView.emptyImage.image = image
-            emptyView.emptyTitle.text = NSLocalizedString(title, comment: "")
             emptyView.emptyTitle.sizeToFit()
-            emptyView.emptyDescription.text = NSLocalizedString(description, comment: "")
             emptyView.emptyDescription.sizeToFit()
             
             view.addSubview(emptyView)

+ 15 - 49
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, NCEmptyDataSet  {
+class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, UIAdaptivePresentationControllerDelegate, NCEmptyDataSetDelegate  {
 
     @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, delegate: self)
+        emptyDataSet = NCEmptyDataSet.init(view: collectionView, offset: 100, delegate: self)
         
         // 3D Touch peek and pop
         if traitCollection.forceTouchCapability == .available {
@@ -551,59 +551,25 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         
     // MARK: - Empty
     
-    
-    
-    func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {
-        
-        if searchController?.isActive ?? false {
-            return CCGraphics.changeThemingColorImage(UIImage.init(named: "search"), width: 300, height: 300, color: .gray)
-        }
-        
-        if isReloadDataSourceNetworkInProgress {
-            return CCGraphics.changeThemingColorImage(UIImage.init(named: "networkInProgress"), width: 300, height: 300, color: .gray)
-        }
-        
-        return emptyImage
-    }
-    
-    func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
-        
-        var text = "\n"+NSLocalizedString(emptyTitle, comment: "")
-        
-        if isReloadDataSourceNetworkInProgress {
-            text = "\n"+NSLocalizedString("_request_in_progress_", comment: "")
-        }
+    func emptyDataSetView(_ view: NCEmptyView) {
         
         if searchController?.isActive ?? false {
+            view.emptyImage.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "search"), width: 300, height: 300, color: .gray)
             if isReloadDataSourceNetworkInProgress {
-                text = "\n"+NSLocalizedString("_search_in_progress_", comment: "")
+                view.emptyTitle.text = NSLocalizedString("_search_in_progress_", comment: "")
             } else {
-                text = "\n"+NSLocalizedString("_search_no_record_found_", comment: "")
+                view.emptyTitle.text = NSLocalizedString("_search_no_record_found_", comment: "")
             }
+            view.emptyDescription.text = NSLocalizedString("_search_instruction_", comment: "")
+        } else if isReloadDataSourceNetworkInProgress {
+            view.emptyImage.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "networkInProgress"), width: 300, height: 300, color: .gray)
+            view.emptyTitle.text = NSLocalizedString("_request_in_progress_", comment: "")
+            view.emptyDescription.text = ""
+        } else {
+            view.emptyImage.image = emptyImage
+            view.emptyTitle.text = NSLocalizedString(emptyTitle, comment: "")
+            view.emptyDescription.text = NSLocalizedString(emptyDescription, comment: "")
         }
-        
-        let attributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 20), NSAttributedString.Key.foregroundColor: UIColor.gray]
-        return NSAttributedString.init(string: text, attributes: attributes)
-    }
-    
-    func description(forEmptyDataSet scrollView: UIScrollView!) -> NSAttributedString! {
-        
-        var text = "\n"+NSLocalizedString(emptyDescription, comment: "")
-        
-        if isReloadDataSourceNetworkInProgress {
-            text = ""
-        }
-        
-        if searchController?.isActive ?? false {
-            text = "\n"+NSLocalizedString("_search_instruction_", comment: "")
-        }
-        
-        let attributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.lightGray]
-        return NSAttributedString.init(string: text, attributes: attributes)
-    }
-    
-    func emptyDataSetShouldAllowScroll(_ scrollView: UIScrollView) -> Bool {
-        return true
     }
     
     // MARK: - SEARCH