Browse Source

VLCEditController: Create resetCellat helper

Soomin Lee 7 years ago
parent
commit
6e29f815fa
1 changed files with 12 additions and 4 deletions
  1. 12 4
      Sources/VLCEditController.swift

+ 12 - 4
Sources/VLCEditController.swift

@@ -36,6 +36,17 @@ class VLCEditController: NSObject {
     }
 }
 
+// MARK: - Helpers
+
+private extension VLCEditController {
+    private func resetCell(at indexPath: IndexPath) {
+        if let cell = collectionView.cellForItem(at: indexPath) as? VLCMediaViewEditCell {
+            cell.checkView.isEnabled = false
+        }
+        collectionView.reloadData()
+    }
+}
+
 extension VLCEditController: VLCEditControllerDataSource {
     func toolbarNeedsUpdate(editing: Bool) {
         editToolbar.isHidden = !editing
@@ -77,10 +88,7 @@ extension VLCEditController: VLCEditToolbarDelegate {
                     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()
+                    self?.resetCell(at: indexPath)
                 }
 
                 alertController.addAction(cancelButton)