WIP: Present CollectionPicker as child view

-[x] establish parent/child relation
-[x] reconcile changes with collection picker delegate
-[] present/dismiss animation
-[] animate title label
-[] hide (some?) bar button items when collection picker presented
This commit is contained in:
Michael Kirk 2018-12-09 10:17:32 -05:00
parent 0e1a65446f
commit 083d587ef0
2 changed files with 1 additions and 51 deletions

View File

@ -414,6 +414,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
}
reloadDataAndRestoreSelection()
hideCollectionPicker()
}
// MARK: - Event Handlers

View File

@ -41,48 +41,11 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg
tableView.backgroundColor = Theme.darkThemeBackgroundColor
tableView.separatorColor = .clear
if #available(iOS 11, *) {
let titleLabel = UILabel()
titleLabel.text = previousPhotoCollection.localizedTitle()
titleLabel.textColor = Theme.darkThemePrimaryColor
titleLabel.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight()
let titleIconView = UIImageView()
titleIconView.tintColor = Theme.darkThemePrimaryColor
titleIconView.image = UIImage(named: "navbar_disclosure_up")?.withRenderingMode(.alwaysTemplate)
let titleView = UIStackView(arrangedSubviews: [titleLabel, titleIconView])
titleView.axis = .horizontal
titleView.alignment = .center
titleView.spacing = 5
titleView.isUserInteractionEnabled = true
titleView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(titleTapped)))
navigationItem.titleView = titleView
} else {
navigationItem.title = previousPhotoCollection.localizedTitle()
}
library.add(delegate: self)
let cancelButton = UIBarButtonItem(barButtonSystemItem: .stop,
target: self,
action: #selector(didPressCancel))
cancelButton.tintColor = Theme.darkThemePrimaryColor
navigationItem.leftBarButtonItem = cancelButton
updateContents()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if let navBar = self.navigationController?.navigationBar as? OWSNavigationBar {
navBar.overrideTheme(type: .alwaysDark)
} else {
owsFailDebug("Invalid nav bar.")
}
}
// MARK: -
private func updateContents() {
@ -164,22 +127,8 @@ class PhotoCollectionPickerController: OWSTableViewController, PhotoLibraryDeleg
// MARK: Actions
@objc
func didPressCancel(sender: UIBarButtonItem) {
self.dismiss(animated: true)
}
func didSelectCollection(collection: PhotoCollection) {
collectionDelegate?.photoCollectionPicker(self, didPickCollection: collection)
self.dismiss(animated: true)
}
@objc func titleTapped(sender: UIGestureRecognizer) {
guard sender.state == .recognized else {
return
}
self.dismiss(animated: true)
}
// MARK: PhotoLibraryDelegate