mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-02 18:32:55 +00:00
Restore current-context presentation for the full-screen image viewer. Resize image after scroll view’s layout to reduce jitter during rotation.
This commit is contained in:
1 parent
d85eb9d27a
commit
60dd02cbcc
3 files changed
+14
-12
No files matched your search
@@ -39,6 +39,7 @@ open class ImageScrollView: UIScrollView {
|
||||
var imageSize: CGSize = CGSize.zero
|
||||
private var pointToCenterAfterResize: CGPoint = CGPoint.zero
|
||||
private var scaleToRestoreAfterResize: CGFloat = 1.0
|
||||
private var lastLayoutSize = CGSize.zero
|
||||
var maxScaleFromMinScale: CGFloat = 3.0
|
||||
|
||||
var zoomedFrame: CGRect {
|
||||
@@ -71,6 +72,18 @@ open class ImageScrollView: UIScrollView {
|
||||
initialize()
|
||||
}
|
||||
|
||||
override open func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
// Resize after UIScrollView’s own layout, so that layout can’t move the image
|
||||
// partway through a rotation animation.
|
||||
guard imageSize != .zero, bounds.size != lastLayoutSize else {
|
||||
return
|
||||
}
|
||||
lastLayoutSize = bounds.size
|
||||
resize()
|
||||
}
|
||||
|
||||
private func initialize() {
|
||||
showsVerticalScrollIndicator = false
|
||||
showsHorizontalScrollIndicator = false
|
||||
|
||||
@@ -15,7 +15,6 @@ final class ImageViewController: UIViewController {
|
||||
@IBOutlet var titleLeading: NSLayoutConstraint!
|
||||
|
||||
private var shareButtonItem: UIBarButtonItem?
|
||||
private var lastImageScrollViewSize = CGSize.zero
|
||||
|
||||
// Title margins as a fraction of the view width.
|
||||
private static let regularWidthTitleMarginMultiplier: CGFloat = 0.1
|
||||
@@ -76,16 +75,6 @@ final class ImageViewController: UIViewController {
|
||||
layoutTitleLabel()
|
||||
}
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
super.viewDidLayoutSubviews()
|
||||
|
||||
let imageScrollViewSize = imageScrollView.bounds.size
|
||||
if imageScrollViewSize != lastImageScrollViewSize {
|
||||
lastImageScrollViewSize = imageScrollViewSize
|
||||
imageScrollView.resize()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func share(_ sender: Any) {
|
||||
guard let image else {
|
||||
return
|
||||
|
||||
@@ -1651,7 +1651,7 @@ struct SidebarItemNode: Hashable, Sendable {
|
||||
imageVC.imageTitle = imageTitle
|
||||
imageVC.transition = transition
|
||||
let navController = UINavigationController(rootViewController: imageVC)
|
||||
navController.modalPresentationStyle = .fullScreen
|
||||
navController.modalPresentationStyle = .currentContext
|
||||
navController.transitioningDelegate = transition
|
||||
rootSplitViewController.present(navController, animated: true)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user