properly deselect items when switching collections

pull/1/head
Michael Kirk 6 years ago
parent 635401dc5e
commit 82d49350ef

@ -425,6 +425,15 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
// MARK: - PhotoCollectionPickerDelegate
func photoCollectionPicker(_ photoCollectionPicker: PhotoCollectionPickerController, didPickCollection collection: PhotoCollection) {
guard photoCollection != collection else {
hideCollectionPicker()
return
}
// Iff we switched albums, discard any selection and make sure the "Select" button shows,
// not the "Done" button
endSelectMode()
photoCollection = collection
photoCollectionContents = photoCollection.contents()
@ -434,7 +443,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
navigationItem.title = photoCollection.localizedTitle()
}
reloadDataAndRestoreSelection()
collectionView?.reloadData()
hideCollectionPicker()
}

@ -227,6 +227,12 @@ class PhotoCollection {
}
}
extension PhotoCollection: Equatable {
static func == (lhs: PhotoCollection, rhs: PhotoCollection) -> Bool {
return lhs.collection == rhs.collection
}
}
class PhotoLibrary: NSObject, PHPhotoLibraryChangeObserver {
typealias WeakDelegate = Weak<PhotoLibraryDelegate>
var delegates = [WeakDelegate]()

Loading…
Cancel
Save