Эх сурвалжийг харах

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 жил өмнө
parent
commit
a730640262

+ 6 - 11
iOSClient/Main/Collection Common/NCCollectionViewCommon.swift

@@ -1483,7 +1483,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
         let tableShare = dataSource.metadatasForSection[indexPath.section].metadataShare[metadata.ocId]
         var isShare = false
         var isMounted = false
-        
+        var a11yValues: [String] = []
+
         if metadataFolder != nil {
             isShare = metadata.permissions.contains(NCGlobal.shared.permissionShared) && !metadataFolder!.permissions.contains(NCGlobal.shared.permissionShared)
             isMounted = metadata.permissions.contains(NCGlobal.shared.permissionMounted) && !metadataFolder!.permissions.contains(NCGlobal.shared.permissionMounted)
@@ -1537,7 +1538,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.fileProgressView?.isHidden = false
             cell.fileProgressView?.progress = progress
         }
-        var a11yValues: [String] = []
+
+        // Accessibility [shared]
         if metadata.ownerId != appDelegate.userId, appDelegate.account == metadata.account {
             a11yValues.append(NSLocalizedString("_shared_with_you_by_", comment: "") + " " + metadata.ownerDisplayName)
         }
@@ -1691,15 +1693,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
             cell.selectMode(false)
         }
 
-        if cell is NCListCell {
-            (cell as? NCListCell)?.accessibilityLabel = metadata.fileNameView + ", " + (cell.fileInfoLabel?.text ?? "")
-            (cell as? NCListCell)?.accessibilityValue = a11yValues.joined(separator: ", ")
-        }
-        if cell is NCGridCell {
-            (cell as? NCGridCell)?.accessibilityLabel = metadata.fileNameView + ", " + (cell.fileInfoLabel?.text ?? "")
-            (cell as? NCGridCell)?.accessibilityValue = a11yValues.joined(separator: ", ")
-        }
-
+        // Accessibility
+        cell.setAccessibility(label: metadata.fileNameView + ", " + (cell.fileInfoLabel?.text ?? ""), value: a11yValues.joined(separator: ", "))
 
         return cell
     }

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

@@ -199,6 +199,11 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
 
         labelInfo.text = dateFormatter.string(from: date as Date) + ", " + CCUtility.transformedSize(size)
     }
+
+    func setAccessibility(label: String, value: String) {
+        accessibilityLabel = label
+        accessibilityValue = value
+    }
 }
 
 protocol NCGridCellDelegate: AnyObject {

+ 5 - 0
iOSClient/Main/Collection Common/NCListCell.swift

@@ -253,6 +253,11 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
     func writeInfoDateSize(date: NSDate, size: Int64) {
         labelInfo.text = CCUtility.dateDiff(date as Date) + " · " + CCUtility.transformedSize(size)
     }
+
+    func setAccessibility(label: String, value: String) {
+        accessibilityLabel = label
+        accessibilityValue = value
+    }
 }
 
 protocol NCListCellDelegate: AnyObject {

+ 2 - 0
iOSClient/Main/NCCellProtocol.swift

@@ -48,6 +48,7 @@ protocol NCCellProtocol {
     func hideButtonMore(_ status: Bool)
     func selectMode(_ status: Bool)
     func selected(_ status: Bool)
+    func setAccessibility(label: String, value: String)
 }
 
 extension NCCellProtocol {
@@ -112,4 +113,5 @@ extension NCCellProtocol {
     func hideButtonMore(_ status: Bool) {}
     func selectMode(_ status: Bool) {}
     func selected(_ status: Bool) {}
+    func setAccessibility(label: String, value: String) {}
 }