Enhance full image view support to work with 3 panel mode and split window views
This commit is contained in:
parent
6c562f93b5
commit
eca5f8259a
|
@ -444,11 +444,7 @@ private extension ArticleViewController {
|
||||||
transition.maskFrame = webView.convert(webView.frame, to: nil)
|
transition.maskFrame = webView.convert(webView.frame, to: nil)
|
||||||
transition.originImage = image
|
transition.originImage = image
|
||||||
|
|
||||||
let imageVC = UIStoryboard.main.instantiateController(ofType: ImageViewController.self)
|
coordinator.showFullScreenImage(image: image, transitioningDelegate: self)
|
||||||
imageVC.image = image
|
|
||||||
imageVC.modalPresentationStyle = .fullScreen
|
|
||||||
imageVC.transitioningDelegate = self
|
|
||||||
present(imageVC, animated: true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
@objc public protocol ImageScrollViewDelegate: UIScrollViewDelegate {
|
@objc public protocol ImageScrollViewDelegate: UIScrollViewDelegate {
|
||||||
func imageScrollViewDidChangeOrientation(imageScrollView: ImageScrollView)
|
|
||||||
func imageScrollViewDidGestureSwipeUp(imageScrollView: ImageScrollView)
|
func imageScrollViewDidGestureSwipeUp(imageScrollView: ImageScrollView)
|
||||||
func imageScrollViewDidGestureSwipeDown(imageScrollView: ImageScrollView)
|
func imageScrollViewDidGestureSwipeDown(imageScrollView: ImageScrollView)
|
||||||
}
|
}
|
||||||
|
@ -72,18 +71,12 @@ open class ImageScrollView: UIScrollView {
|
||||||
initialize()
|
initialize()
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
|
||||||
NotificationCenter.default.removeObserver(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func initialize() {
|
private func initialize() {
|
||||||
showsVerticalScrollIndicator = false
|
showsVerticalScrollIndicator = false
|
||||||
showsHorizontalScrollIndicator = false
|
showsHorizontalScrollIndicator = false
|
||||||
bouncesZoom = true
|
bouncesZoom = true
|
||||||
decelerationRate = UIScrollView.DecelerationRate.fast
|
decelerationRate = UIScrollView.DecelerationRate.fast
|
||||||
delegate = self
|
delegate = self
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(ImageScrollView.changeOrientationNotification), name: UIDevice.orientationDidChangeNotification, object: nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func adjustFrameToCenter() {
|
@objc public func adjustFrameToCenter() {
|
||||||
|
@ -303,14 +296,8 @@ open class ImageScrollView: UIScrollView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Actions
|
open func resize() {
|
||||||
|
|
||||||
@objc func changeOrientationNotification() {
|
|
||||||
// A weird bug that frames are not update right after orientation changed. Need delay a little bit with async.
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
self.configureImageForSize(self.imageSize)
|
self.configureImageForSize(self.imageSize)
|
||||||
self.imageScrollViewDelegate?.imageScrollViewDidChangeOrientation(imageScrollView: self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,13 @@ class ImageViewController: UIViewController {
|
||||||
imageScrollView.display(image: image)
|
imageScrollView.display(image: image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||||
|
super.viewWillTransition(to: size, with: coordinator)
|
||||||
|
coordinator.animate(alongsideTransition: { [weak self] context in
|
||||||
|
self?.imageScrollView.resize()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@IBAction func share(_ sender: Any) {
|
@IBAction func share(_ sender: Any) {
|
||||||
guard let image = image else { return }
|
guard let image = image else { return }
|
||||||
let activityViewController = UIActivityViewController(activityItems: [image], applicationActivities: nil)
|
let activityViewController = UIActivityViewController(activityItems: [image], applicationActivities: nil)
|
||||||
|
@ -46,9 +53,6 @@ class ImageViewController: UIViewController {
|
||||||
|
|
||||||
extension ImageViewController: ImageScrollViewDelegate {
|
extension ImageViewController: ImageScrollViewDelegate {
|
||||||
|
|
||||||
func imageScrollViewDidChangeOrientation(imageScrollView: ImageScrollView) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func imageScrollViewDidGestureSwipeUp(imageScrollView: ImageScrollView) {
|
func imageScrollViewDidGestureSwipeUp(imageScrollView: ImageScrollView) {
|
||||||
dismiss(animated: true)
|
dismiss(animated: true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ class RootSplitViewController: UISplitViewController {
|
||||||
var coordinator: SceneCoordinator!
|
var coordinator: SceneCoordinator!
|
||||||
|
|
||||||
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||||
|
super.viewWillTransition(to: size, with: coordinator)
|
||||||
coordinator.animate(alongsideTransition: { [weak self] context in
|
coordinator.animate(alongsideTransition: { [weak self] context in
|
||||||
self?.coordinator.configureThreePanelMode(for: size)
|
self?.coordinator.configureThreePanelMode(for: size)
|
||||||
})
|
})
|
||||||
|
|
|
@ -819,6 +819,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||||
masterFeedViewController.present(addViewController, animated: true)
|
masterFeedViewController.present(addViewController, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func showFullScreenImage(image: UIImage, transitioningDelegate: UIViewControllerTransitioningDelegate) {
|
||||||
|
let imageVC = UIStoryboard.main.instantiateController(ofType: ImageViewController.self)
|
||||||
|
imageVC.image = image
|
||||||
|
imageVC.modalPresentationStyle = .currentContext
|
||||||
|
imageVC.transitioningDelegate = transitioningDelegate
|
||||||
|
rootSplitViewController.present(imageVC, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
func toggleArticleExtractor() {
|
func toggleArticleExtractor() {
|
||||||
|
|
||||||
guard let article = currentArticle else {
|
guard let article = currentArticle else {
|
||||||
|
|
Loading…
Reference in New Issue