marinofaggiana 5 年之前
父節點
當前提交
dd6271b368
共有 2 個文件被更改,包括 22 次插入0 次删除
  1. 1 0
      iOSClient/Main/Menu/CCMain+Menu.swift
  2. 21 0
      iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift

+ 1 - 0
iOSClient/Main/Menu/CCMain+Menu.swift

@@ -360,6 +360,7 @@ extension CCMain {
                     )
                 )
             }
+            
         } else {
             var iconHeader: UIImage!
             if let icon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, fileNameView: metadata.fileNameView)) {

+ 21 - 0
iOSClient/Main/Menu/NCDetailNavigationController+Menu.swift

@@ -62,6 +62,27 @@ extension NCDetailNavigationController {
             )
         )
 
+        actions.append(
+            NCMenuAction(
+                title: NSLocalizedString("_rename_", comment: ""),
+                icon: CCGraphics.changeThemingColorImage(UIImage(named: "rename"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon),
+                action: { menuAction in
+                    let alertController = UIAlertController(title: NSLocalizedString("_rename_", comment: ""), message: nil, preferredStyle: .alert)
+
+                    alertController.addTextField { (textField) in textField.text = metadata.fileNameView }
+                    let cancelAction = UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil)
+                    let okAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in
+                        let fileNameNew = alertController.textFields![0].text
+                        NCNetworking.sharedInstance.renameMetadata(metadata, fileNameNew: fileNameNew!, viewController: self) { (errorCode, errorDescription) in }
+                    })
+                    alertController.addAction(cancelAction)
+                    alertController.addAction(okAction)
+
+                    self.present(alertController, animated: true, completion: nil)
+                }
+            )
+        )
+        
         actions.append(
             NCMenuAction(title: NSLocalizedString("_delete_", comment: ""),
                          icon: CCGraphics.changeThemingColorImage(UIImage(named: "trash"), width: 50, height: 50, color: .red),