Browse Source

VLCEditController: Handle empty rename

Soomin Lee 6 years ago
parent
commit
4239212049
1 changed files with 9 additions and 2 deletions
  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)
                 })