瀏覽代碼

VLCEditController: Handle empty rename

Soomin Lee 7 年之前
父節點
當前提交
4239212049
共有 1 個文件被更改,包括 9 次插入2 次删除
  1. 9 2
      Sources/VLCEditController.swift

+ 9 - 2
Sources/VLCEditController.swift

@@ -156,14 +156,21 @@ extension VLCEditController: VLCEditToolbarDelegate {
     }
 
     func rename() {
+        // FIXME: Multiple renaming of files(multiple alert can get unfriendly if too many files)
         for indexPath in selectedCellIndexPaths {
             if let media = category.anyfiles[indexPath.row] as? VLCMLMedia {
                 // Not using VLCAlertViewController to have more customization in text fields
                 let alertInfo = TextFieldAlertInfo(alertTitle: String(format: NSLocalizedString("RENAME_MEDIA_TO", comment: ""), media.title),
-                                                   placeHolder: "NEW_NAME")
-
+                                                   placeHolder: "NEW_NAME",
+                                                   confirmActionTitle: NSLocalizedString("BUTTON_RENAME", comment: ""))
                 presentTextFieldAlert(with: alertInfo, completionHandler: {
                     [weak self] text -> Void in
+                    guard text != "" else {
+                        VLCAlertViewController.alertViewManager(title: NSLocalizedString("ERROR_RENAME_FAILED", comment: ""),
+                                                                errorMessage: NSLocalizedString("ERROR_EMPTY_NAME", comment: ""),
+                                                                viewController: (UIApplication.shared.keyWindow?.rootViewController)!)
+                        return
+                    }
                     media.updateTitle(text)
                     self?.resetCell(at: indexPath)
                 })