|
|
|
@ -237,7 +237,7 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
|
|
|
|
|
// It's a static image of the media content.
|
|
|
|
|
let presentationView = UIImageView()
|
|
|
|
|
self.presentationView = presentationView
|
|
|
|
|
self.view.addSubview(presentationView)
|
|
|
|
|
self.view.insertSubview(presentationView, at: 0)
|
|
|
|
|
presentationView.isHidden = true
|
|
|
|
|
presentationView.clipsToBounds = true
|
|
|
|
|
presentationView.layer.allowsEdgeAntialiasing = true
|
|
|
|
@ -316,9 +316,14 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
detailView.isHidden = true
|
|
|
|
|
|
|
|
|
|
// At this point our media view should be overlayed perfectly
|
|
|
|
|
// by our presentationView. Swapping them out should be imperceptible.
|
|
|
|
|
self.presentationView.isHidden = false
|
|
|
|
|
// We don't hide the pageViewController entirely - e.g. we want the toolbars to fade in.
|
|
|
|
|
pageViewController.currentViewController.view.isHidden = true
|
|
|
|
|
detailView.backgroundColor = .clear
|
|
|
|
|
self.view.backgroundColor = .clear
|
|
|
|
|
|
|
|
|
|
self.presentationView.layer.cornerRadius = OWSMessageCellCornerRadius
|
|
|
|
|
|
|
|
|
|
fromViewController.present(self, animated: false) {
|
|
|
|
@ -343,12 +348,14 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
|
|
|
|
|
self.presentationView.layer.cornerRadius = 0
|
|
|
|
|
self.presentationView.superview?.layoutIfNeeded()
|
|
|
|
|
|
|
|
|
|
self.view.backgroundColor = UIColor.white
|
|
|
|
|
// fade out content behind the pageViewController
|
|
|
|
|
// and behind the presentation view
|
|
|
|
|
self.view.backgroundColor = .white
|
|
|
|
|
},
|
|
|
|
|
completion: { (_: Bool) in
|
|
|
|
|
// At this point our presentation view should be overlayed perfectly
|
|
|
|
|
// with our media view. Swapping them out should be imperceptible.
|
|
|
|
|
detailView.isHidden = false
|
|
|
|
|
pageViewController.currentViewController.view.isHidden = false
|
|
|
|
|
self.presentationView.isHidden = true
|
|
|
|
|
|
|
|
|
|
self.view.isUserInteractionEnabled = true
|
|
|
|
@ -434,16 +441,17 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func dismissMediaDetailViewController(_ mediaDetailViewController: MediaPageViewController, animated isAnimated: Bool, completion: (() -> Void)?) {
|
|
|
|
|
public func dismissMediaDetailViewController(_ mediaPageViewController: MediaPageViewController, animated isAnimated: Bool, completion: (() -> Void)?) {
|
|
|
|
|
self.view.isUserInteractionEnabled = false
|
|
|
|
|
UIApplication.shared.isStatusBarHidden = false
|
|
|
|
|
|
|
|
|
|
guard let detailView = mediaDetailViewController.view else {
|
|
|
|
|
guard let detailView = mediaPageViewController.view else {
|
|
|
|
|
owsFail("\(logTag) in \(#function) detailView was unexpectedly nil")
|
|
|
|
|
self.presentingViewController?.dismiss(animated: false, completion: completion)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
detailView.isHidden = true
|
|
|
|
|
|
|
|
|
|
mediaPageViewController.currentViewController.view.isHidden = true
|
|
|
|
|
self.presentationView.isHidden = false
|
|
|
|
|
|
|
|
|
|
// Move the presentationView back to it's initial position, i.e. where
|
|
|
|
@ -461,10 +469,10 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
|
|
|
|
|
delay: 0.0,
|
|
|
|
|
options:.curveEaseOut,
|
|
|
|
|
animations: {
|
|
|
|
|
// Move back over it's original location
|
|
|
|
|
self.presentationView.superview?.layoutIfNeeded()
|
|
|
|
|
|
|
|
|
|
// In case user has hidden bars, which changes background to black.
|
|
|
|
|
self.view.backgroundColor = UIColor.white
|
|
|
|
|
detailView.alpha = 0
|
|
|
|
|
|
|
|
|
|
if changedItems {
|
|
|
|
|
self.presentationView.alpha = 0
|
|
|
|
@ -472,7 +480,12 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
|
|
|
|
|
self.presentationView.layer.cornerRadius = OWSMessageCellCornerRadius
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
completion:nil)
|
|
|
|
|
completion: { (_: Bool) in
|
|
|
|
|
// In case user has hidden bars, which changes background to black.
|
|
|
|
|
// We don't want to change this while detailView is visible, lest
|
|
|
|
|
// we obscure out the presentationView
|
|
|
|
|
detailView.backgroundColor = .white
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// This intentionally overlaps the previous animation a bit
|
|
|
|
|
UIView.animate(withDuration: 0.1,
|
|
|
|
@ -484,10 +497,9 @@ class MediaGalleryViewController: UINavigationController, MediaGalleryDataSource
|
|
|
|
|
self.presentingViewController?.dismiss(animated: false, completion: completion)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
replacingView.alpha = 1.0
|
|
|
|
|
|
|
|
|
|
// fade out content and toolbars
|
|
|
|
|
self.navigationController?.view.alpha = 0.0
|
|
|
|
|
self.view.alpha = 0.0
|
|
|
|
|
replacingView.alpha = 1.0
|
|
|
|
|
},
|
|
|
|
|
completion: { (_: Bool) in
|
|
|
|
|
self.presentingViewController?.dismiss(animated: false, completion: completion)
|
|
|
|
|