Present CollectionPicker as child view

TODO:

-[x] establish parent/child relation
-[x] reconcile changes with collection picker delegate
-[x] present/dismiss animation
-[] animate title label
-[] hide (some?) bar button items when collection picker presented

Nice to have:

-[] crop child view top - so that it comes *up to* the navbar bottom, but
    doesn't go behind
pull/1/head
Michael Kirk 6 years ago
parent 083d587ef0
commit caf0020697

@ -371,7 +371,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
previousPhotoCollection: photoCollection, previousPhotoCollection: photoCollection,
collectionDelegate: self) collectionDelegate: self)
guard let collectionView = collectionPickerController.view else { guard let collectionPickerView = collectionPickerController.view else {
owsFailDebug("collectionView was unexpectedly nil") owsFailDebug("collectionView was unexpectedly nil")
return return
} }
@ -381,8 +381,14 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
addChildViewController(collectionPickerController) addChildViewController(collectionPickerController)
view.addSubview(collectionView) view.addSubview(collectionPickerView)
collectionView.autoPinEdgesToSuperviewEdges() collectionPickerView.autoPinEdgesToSuperviewEdges()
collectionPickerView.layoutIfNeeded()
collectionPickerView.frame = view.frame.offsetBy(dx: 0, dy: view.frame.height)
UIView.animate(.promise, duration: 0.3, delay: 0, options: .curveEaseInOut) {
collectionPickerView.superview?.layoutIfNeeded()
}.retainUntilComplete()
} }
func hideCollectionPicker() { func hideCollectionPicker() {
@ -392,13 +398,13 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
return return
} }
self.collectionPickerController = nil self.collectionPickerController = nil
// TODO animate/hide
// MJK really? This documentation is surprising...
// If you are implementing your own container view controller, it must call the willMove(toParent:) method of the child view controller before calling the removeFromParent() method, passing in a parent value of nil.
collectionPickerController.view.removeFromSuperview() UIView.animate(.promise, duration: 0.3, delay: 0, options: .curveEaseInOut) {
collectionPickerController.removeFromParentViewController() collectionPickerController.view.frame = self.view.frame.offsetBy(dx: 0, dy: self.view.frame.height)
}.done { _ in
collectionPickerController.view.removeFromSuperview()
collectionPickerController.removeFromParentViewController()
}.retainUntilComplete()
} }
// MARK: - PhotoCollectionPickerDelegate // MARK: - PhotoCollectionPickerDelegate

Loading…
Cancel
Save