소스 검색

MediaEditCell: fix correct selected state

the cell was showing the empty state for selected and selected for unselected,
when the cell was reused it didn't correct show the selected state when scrolling up as well
Carola Nitz 6 년 전
부모
커밋
7d7e41ab4d
2개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 1
      Sources/MediaEditCell.swift
  2. 2 1
      Sources/VLCEditController.swift

+ 2 - 1
Sources/MediaEditCell.swift

@@ -55,7 +55,7 @@ class MediaEditCell: BaseCollectionViewCell {
 
     var isChecked: Bool = false {
          didSet {
-            checkboxImageView.image = isChecked ? UIImage(named: "checkboxEmpty") : UIImage(named: "checkboxSelected")
+            checkboxImageView.image = isChecked ? UIImage(named: "checkboxSelected") : UIImage(named: "checkboxEmpty")
         }
     }
 
@@ -65,5 +65,6 @@ class MediaEditCell: BaseCollectionViewCell {
         timeLabel.text = ""
         sizeLabel.text = ""
         thumbnailImageView.image = nil
+        isChecked = false
     }
 }

+ 2 - 1
Sources/VLCEditController.swift

@@ -192,8 +192,9 @@ extension VLCEditController: UICollectionViewDataSource {
 
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: category.editCellType.defaultReuseIdentifier,
-                                                         for: indexPath) as? BaseCollectionViewCell {
+                                                         for: indexPath) as? MediaEditCell {
             cell.media = category.anyfiles[indexPath.row]
+            cell.isChecked = selectedCellIndexPaths.contains(indexPath)
             return cell
         }
         return UICollectionViewCell()