Просмотр исходного кода

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 лет назад
Родитель
Сommit
a2e7636d59

+ 2 - 0
iOSClient/Activity/NCActivityTableViewCell.swift

@@ -105,6 +105,8 @@ class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
 }
 
 // MARK: - Collection View

+ 26 - 13
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1483,10 +1483,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
         let tableShare = dataSource.metadatasForSection[indexPath.section].metadataShare[metadata.ocId]
 
-
-        //
         // LAYOUT LIST
-        //
         if layoutForView?.layout == NCGlobal.shared.layoutList {
             cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCListCell
             if cell is NCListCell {
@@ -1494,9 +1491,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             }
         }
 
-        //
         // LAYOUT GRID
-        //
         if layoutForView?.layout == NCGlobal.shared.layoutGrid {
             cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell
             if cell is NCGridCell {
@@ -1504,10 +1499,35 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             }
         }
 
-        //
         if var cell = cell as? NCCellProtocol {
+
             cell.fileObjectId = metadata.ocId
             cell.fileUser = metadata.ownerId
+            cell.title?.textColor = NCBrandColor.shared.label
+            cell.info?.textColor = NCBrandColor.shared.systemGray
+            cell.titleInfoTrailingDefault()
+
+            if isSearching {
+                cell.title?.text = metadata.fileName
+                cell.title?.lineBreakMode = .byTruncatingTail
+                if metadata.name == NCGlobal.shared.appName {
+                    cell.info?.text = NSLocalizedString("_in_", comment: "") + " " + NCUtilityFileSystem.shared.getPath(metadata: metadata, withFileName: false)
+                } else {
+                    cell.info?.text = metadata.subline
+                    cell.titleInfoTrailingFull()
+                }
+                if let literalSearch = self.literalSearch {
+                    let longestWordRange = (metadata.fileName.lowercased() as NSString).range(of: literalSearch)
+                    let attributedString = NSMutableAttributedString(string: metadata.fileName, attributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 15)])
+                    attributedString.setAttributes([NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 15)], range: longestWordRange)
+                    cell.title?.attributedText = attributedString
+                }
+            } else {
+                cell.title?.text = metadata.fileNameView
+                cell.title?.lineBreakMode = .byTruncatingMiddle
+                cell.info?.text = CCUtility.dateDiff(metadata.date as Date) + " · " + CCUtility.transformedSize(metadata.size)
+            }
+
         }
 
 
@@ -1525,14 +1545,7 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         //
         if layoutForView?.layout == NCGlobal.shared.layoutList {
 
-//            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
-//            cell.delegate = self
 
-//            cell.fileObjectId = metadata.ocId
-            cell.fileUser = metadata.ownerId
-            cell.labelTitle.textColor = NCBrandColor.shared.label
-            cell.labelInfo.textColor = NCBrandColor.shared.systemGray
-            cell.titleInfoTrailingDefault()
 
             if isSearching {
                 cell.labelTitle.text = metadata.fileName

+ 3 - 0
iOSClient/Main/Collection Common/NCGridCell.swift

@@ -207,6 +207,9 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
 
         labelInfo.text = dateFormatter.string(from: date as Date) + " · " + CCUtility.transformedSize(totalBytes)
     }
+
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
 }
 
 protocol NCGridCellDelegate: AnyObject {

+ 2 - 0
iOSClient/Main/NCCellProtocol.swift

@@ -32,6 +32,8 @@ protocol NCCellProtocol {
     var info: UILabel? { get set }
     var progress: UIProgressView? { get set }
 
+    func titleInfoTrailingDefault()
+    func titleInfoTrailingFull()
     func writeInfoDateSize(date: NSDate, totalBytes: Int64)
     func setButtonMore(named: String, image: UIImage)
 }

+ 2 - 0
iOSClient/Media/Cell/NCGridMediaCell.swift

@@ -116,4 +116,6 @@ class NCGridMediaCell: UICollectionViewCell, NCCellProtocol {
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
 }

+ 2 - 0
iOSClient/Notification/NCNotification.swift

@@ -387,6 +387,8 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol {
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
 }
 
 protocol NCNotificationCellDelegate: AnyObject {

+ 2 - 0
iOSClient/Share/NCShareCommentsCell.swift

@@ -84,6 +84,8 @@ class NCShareCommentsCell: UITableViewCell, NCCellProtocol {
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
 }
 
 protocol NCShareCommentsCellDelegate: AnyObject {

+ 4 - 0
iOSClient/Share/NCShareUserCell.swift

@@ -134,6 +134,8 @@ class NCShareUserCell: UITableViewCell, NCCellProtocol {
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
 }
 
 protocol NCShareUserCellDelegate: AnyObject {
@@ -223,4 +225,6 @@ class NCSearchUserDropDownCell: DropDownCell, NCCellProtocol {
 
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {}
     func setButtonMore(named: String, image: UIImage) {}
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
 }

+ 3 - 0
iOSClient/Transfers/NCTransferCell.swift

@@ -157,6 +157,9 @@ class NCTransferCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellP
     func writeInfoDateSize(date: NSDate, totalBytes: Int64) {
         labelInfo.text = CCUtility.dateDiff(date as Date) + " · " + CCUtility.transformedSize(totalBytes)
     }
+
+    func titleInfoTrailingDefault() {}
+    func titleInfoTrailingFull() {}
 }
 
 protocol NCTransferCellDelegate: AnyObject {