Animate title chevron

TODO:

-[x] establish parent/child relation
-[x] reconcile changes with collection picker delegate
-[x] present/dismiss animation
-[x] 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 caf0020697
commit 5490f07bb9

@ -25,6 +25,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
var collectionViewFlowLayout: UICollectionViewFlowLayout var collectionViewFlowLayout: UICollectionViewFlowLayout
private let titleLabel = UILabel() private let titleLabel = UILabel()
private let titleIconView = UIImageView()
private var selectedIds = Set<String>() private var selectedIds = Set<String>()
@ -70,7 +71,6 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
titleLabel.textColor = .ows_gray05 titleLabel.textColor = .ows_gray05
titleLabel.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight() titleLabel.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight()
let titleIconView = UIImageView()
titleIconView.tintColor = .ows_gray05 titleIconView.tintColor = .ows_gray05
titleIconView.image = UIImage(named: "navbar_disclosure_down")?.withRenderingMode(.alwaysTemplate) titleIconView.image = UIImage(named: "navbar_disclosure_down")?.withRenderingMode(.alwaysTemplate)
@ -388,6 +388,10 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
UIView.animate(.promise, duration: 0.3, delay: 0, options: .curveEaseInOut) { UIView.animate(.promise, duration: 0.3, delay: 0, options: .curveEaseInOut) {
collectionPickerView.superview?.layoutIfNeeded() collectionPickerView.superview?.layoutIfNeeded()
// *slightly* more than `pi` to ensure the chevron animates anti-clockwise
let chevronRotationAngle = CGFloat.pi.nextUp
self.titleIconView.transform = CGAffineTransform(rotationAngle: chevronRotationAngle)
}.retainUntilComplete() }.retainUntilComplete()
} }
@ -401,6 +405,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
UIView.animate(.promise, duration: 0.3, delay: 0, options: .curveEaseInOut) { UIView.animate(.promise, duration: 0.3, delay: 0, options: .curveEaseInOut) {
collectionPickerController.view.frame = self.view.frame.offsetBy(dx: 0, dy: self.view.frame.height) collectionPickerController.view.frame = self.view.frame.offsetBy(dx: 0, dy: self.view.frame.height)
self.titleIconView.transform = .identity
}.done { _ in }.done { _ in
collectionPickerController.view.removeFromSuperview() collectionPickerController.view.removeFromSuperview()
collectionPickerController.removeFromParentViewController() collectionPickerController.removeFromParentViewController()

Loading…
Cancel
Save