ソースを参照

Add file lock info

- include locked by info in NCMenu
- add NCMenuAction.seperator to make it more obvious that the "header cells" can't be tapped
- - don't use custom UIView inside a cell or sections for easier customisation
- - use default heigh of 3, could potentially be included in the action, but would probably be too hack-y

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 年 前
コミット
08518ee4c5

+ 1 - 1
iOSClient/Main/NCFunctionCenter.swift

@@ -639,7 +639,7 @@ import SVGKit
             }
         }
         
-        let lockUnlock = UIAction(title: titleLock, image: NCUtility.shared.loadImage(named: iconLock)) { _ in
+        let lockUnlock = UIAction(title: titleLock, image: UIImage(systemName: iconLock)) { _ in
             NCNetworking.shared.lockUnlockFile(metadata, shoulLock: !metadata.lock)
         }
         let save = UIAction(title: titleSave, image: UIImage(systemName: "square.and.arrow.down")) { _ in

+ 15 - 0
iOSClient/Menu/NCCollectionViewCommon+Menu.swift

@@ -70,6 +70,21 @@ extension NCCollectionViewCommon {
                 action: nil
             )
         )
+        
+        if metadata.lock {
+            let lockOwnerName = metadata.lockOwnerDisplayName.isEmpty ? metadata.lockOwner : metadata.lockOwnerDisplayName
+            actions.append(
+                NCMenuAction(
+                    title: String(format: NSLocalizedString("_file_locked_by_", comment: ""), lockOwnerName),
+                    icon: NCUtility.shared.loadUserImage(
+                        for: metadata.lockOwner,
+                           displayName: lockOwnerName,
+                           userBaseUrl: metadata),
+                    action: nil)
+            )
+        }
+        
+        actions.append(.seperator)
 
         //
         // FAVORITE

+ 7 - 2
iOSClient/Menu/NCMenu.swift

@@ -63,9 +63,14 @@ class NCMenu: UITableViewController {
     }
 
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let action = actions[indexPath.row]
+        guard action.title != NCMenuAction.seperatorIdentifier else {
+            let cell = UITableViewCell()
+            cell.backgroundColor = NCBrandColor.shared.separator
+            return cell
+        }
         let cell = tableView.dequeueReusableCell(withIdentifier: "menuActionCell", for: indexPath)
         cell.tintColor = NCBrandColor.shared.customer
-        let action = actions[indexPath.row]
         let actionIconView = cell.viewWithTag(1) as? UIImageView
         let actionNameLabel = cell.viewWithTag(2) as? UILabel
 
@@ -89,7 +94,7 @@ class NCMenu: UITableViewController {
     // MARK: - Tabel View Layout
 
     override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
-        return 60
+        actions[indexPath.row].title == NCMenuAction.seperatorIdentifier ? 3 : 60
     }
 }
 extension NCMenu: FloatingPanelControllerDelegate {

+ 6 - 0
iOSClient/Menu/NCMenuAction.swift

@@ -41,6 +41,12 @@ class NCMenuAction {
 // MARK: - Actions
 
 extension NCMenuAction {
+    static let seperatorIdentifier = "NCMenuAction.SEPERATOR"
+    
+    /// A static seperator, with no actions, text, or icons
+    static var seperator: NCMenuAction {
+        return NCMenuAction(title: seperatorIdentifier, icon: UIImage(), action: nil)
+    }
 
     /// Select all items
     static func selectAllAction(action: @escaping () -> Void) -> NCMenuAction {

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -152,6 +152,7 @@
 "_unlock_file_"                     = "Unock file";
 "_lock_selected_files_"             = "Lock files";
 "_unlock_selected_files_"           = "Unock files";
+"_file_locked_by_"                  = "File locked by %@";
 
 /* Remove a file from a list, don't delete it entirely */
 "_remove_file_"             = "Remove file";