Commit a5921e53 authored by Soomin Lee's avatar Soomin Lee

VLCEditController: Handle basic renaming

parent 8c53a807
......@@ -56,7 +56,39 @@ extension VLCEditController: VLCEditToolbarDelegate {
}
func rename() {
for indexPath in selectedCellIndexPaths {
if let media = category.anyfiles[indexPath.row] as? VLCMLMedia {
// Not using VLCAlertViewController to have more customization in text fields
let alertController = UIAlertController(title: String(format: NSLocalizedString("RENAME_MEDIA_TO", comment: ""), media.title),
message: "",
preferredStyle: .alert)
alertController.addTextField(configurationHandler: {
textField in
textField.placeholder = NSLocalizedString("NEW_NAME", comment: "")
})
let cancelButton = UIAlertAction(title: NSLocalizedString("BUTTON_CANCEL", comment: ""),
style: .default)
let confirmAction = UIAlertAction(title: NSLocalizedString("BUTTON_DONE", comment: ""), style: .default) {
[weak alertController, weak self] _ in
guard let alertController = alertController,
let textField = alertController.textFields?.first else { return }
media.updateTitle(textField.text)
if let cell = self?.collectionView.cellForItem(at: indexPath) as? VLCMediaViewEditCell {
cell.checkView.isEnabled = false
}
self?.collectionView.reloadData()
}
alertController.addAction(cancelButton)
alertController.addAction(confirmAction)
UIApplication.shared.keyWindow?.rootViewController?.present(alertController, animated: true, completion: nil)
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment