Merge branch 'mkirk/fix-pan-swipe'

pull/1/head
Michael Kirk 7 years ago
commit ddf14250da

@ -174,7 +174,7 @@ protocol MediaGalleryDataSource: class {
func galleryItem(after currentItem: MediaGalleryItem) -> MediaGalleryItem? func galleryItem(after currentItem: MediaGalleryItem) -> MediaGalleryItem?
func showAllMedia(focusedItem: MediaGalleryItem) func showAllMedia(focusedItem: MediaGalleryItem)
func dismissSelf(animated isAnimated: Bool, completion: (() -> Void)?) func dismissMediaDetailViewController(_ mediaDetailViewController: MediaPageViewController, animated isAnimated: Bool, completion: (() -> Void)?)
} }
class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource, MediaTileViewControllerDelegate { class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource, MediaTileViewControllerDelegate {
@ -283,6 +283,10 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
self.presentationView.image = initialDetailItem.fullSizedImage self.presentationView.image = initialDetailItem.fullSizedImage
self.applyInitialMediaViewConstraints() self.applyInitialMediaViewConstraints()
// Restore presentationView.alpha in case a previous dismiss left us in a bad state.
pageViewController.navigationController?.setNavigationBarHidden(false, animated: false)
self.presentationView.alpha = 1
// We want to animate the tapped media from it's position in the previous VC // We want to animate the tapped media from it's position in the previous VC
// to it's resting place in the center of this view controller. // to it's resting place in the center of this view controller.
// //
@ -405,8 +409,9 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
// //
guard let pageViewController = self.pageViewController else { guard let pageViewController = self.pageViewController else {
owsFail("\(logTag) in \(#function) pageeViewController was unexpectedly nil") owsFail("\(logTag) in \(#function) pageViewController was unexpectedly nil")
self.dismissSelf(animated: true) self.dismiss(animated: true)
return return
} }
@ -418,11 +423,11 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
} }
} }
public func dismissSelf(animated isAnimated: Bool, completion: (() -> Void)? = nil) { public func dismissMediaDetailViewController(_ mediaDetailViewController: MediaPageViewController, animated isAnimated: Bool, completion: (() -> Void)?) {
self.view.isUserInteractionEnabled = false self.view.isUserInteractionEnabled = false
UIApplication.shared.isStatusBarHidden = false UIApplication.shared.isStatusBarHidden = false
guard let detailView = pageViewController?.view else { guard let detailView = mediaDetailViewController.view else {
owsFail("\(logTag) in \(#function) detailView was unexpectedly nil") owsFail("\(logTag) in \(#function) detailView was unexpectedly nil")
self.presentingViewController?.dismiss(animated: false, completion: completion) self.presentingViewController?.dismiss(animated: false, completion: completion)
return return

@ -203,6 +203,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
currentViewController.playVideo() currentViewController.playVideo()
} }
} }
@objc @objc
public func didPressAllMediaButton(sender: Any) { public func didPressAllMediaButton(sender: Any) {
Logger.debug("\(logTag) in \(#function)") Logger.debug("\(logTag) in \(#function)")
@ -255,7 +256,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
private func updateFooterBarButtonItems(isPlayingVideo: Bool) { private func updateFooterBarButtonItems(isPlayingVideo: Bool) {
// TODO do we still need this? seems like a vestige // TODO do we still need this? seems like a vestige
// from when media detail view was used for attachment approval // from when media detail view was used for attachment approval
if (self.footerBar == nil) { if self.footerBar == nil {
owsFail("\(logTag) No footer bar visible.") owsFail("\(logTag) No footer bar visible.")
return return
} }
@ -453,7 +454,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
return return
} }
mediaGalleryDataSource.dismissSelf(animated: isAnimated, completion: completion) mediaGalleryDataSource.dismissMediaDetailViewController(self, animated: isAnimated, completion: completion)
} }
public func mediaDetailViewController(_ mediaDetailViewController: MediaDetailViewController, isPlayingVideo: Bool) { public func mediaDetailViewController(_ mediaDetailViewController: MediaDetailViewController, isPlayingVideo: Bool) {

Loading…
Cancel
Save