Compare commits

..

No commits in common. "eafb506d64d93a4edcc00ccce770949d87122147" and "6857529d0686b663cc30955ffe8e0c6823c103c8" have entirely different histories.

6 changed files with 12 additions and 40 deletions

View File

@ -43,10 +43,9 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans
let appliedSourceToDestTransform: Bool
if destFrameInContainer.width > 0 && destFrameInContainer.height > 0 {
appliedSourceToDestTransform = true
let scale = min(destFrameInContainer.width / sourceFrameInContainer.width, destFrameInContainer.height / sourceFrameInContainer.height)
let sourceToDestTransform = origSourceTransform
.translatedBy(x: destFrameInContainer.midX - sourceFrameInContainer.midX, y: destFrameInContainer.midY - sourceFrameInContainer.midY)
.scaledBy(x: scale, y: scale)
.scaledBy(x: destFrameInContainer.width / sourceFrameInContainer.width, y: destFrameInContainer.height / sourceFrameInContainer.height)
sourceView.transform = sourceToDestTransform
} else {
appliedSourceToDestTransform = false

View File

@ -64,7 +64,8 @@ class GalleryItemViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
scrollView = UIScrollView()
let scrollView = UIScrollView()
self.scrollView = scrollView
scrollView.translatesAutoresizingMaskIntoConstraints = false
scrollView.delegate = self
@ -90,9 +91,7 @@ class GalleryItemViewController: UIViewController {
topControlsView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(topControlsView)
var shareConfig = UIButton.Configuration.gray()
shareConfig.cornerStyle = .capsule
shareConfig.background.backgroundColor = .black.withAlphaComponent(0.25)
var shareConfig = UIButton.Configuration.plain()
shareConfig.baseForegroundColor = .white
shareConfig.image = UIImage(systemName: "square.and.arrow.up")
shareButton = UIButton(configuration: shareConfig)
@ -101,9 +100,7 @@ class GalleryItemViewController: UIViewController {
updateShareButton()
topControlsView.addSubview(shareButton)
var closeConfig = UIButton.Configuration.gray()
closeConfig.cornerStyle = .capsule
closeConfig.background.backgroundColor = .black.withAlphaComponent(0.25)
var closeConfig = UIButton.Configuration.plain()
closeConfig.baseForegroundColor = .white
closeConfig.image = UIImage(systemName: "xmark")
let closeButton = UIButton(configuration: closeConfig)
@ -291,8 +288,8 @@ class GalleryItemViewController: UIViewController {
return
}
let heightScale = view.bounds.height / content.contentSize.height
let widthScale = view.bounds.width / content.contentSize.width
let heightScale = view.safeAreaLayoutGuide.layoutFrame.height / content.contentSize.height
let widthScale = view.safeAreaLayoutGuide.layoutFrame.width / content.contentSize.width
let minScale = min(widthScale, heightScale)
let maxScale = minScale >= 1 ? minScale + 2 : 2

View File

@ -49,11 +49,9 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
let origSourceTransform = sourceView.transform
let sourceToDestTransform: CGAffineTransform?
if destFrameInContainer.width > 0 && destFrameInContainer.height > 0 {
// Scale evenly in both dimensions, to prevent the source view appearing to stretch/distort during the animation.
let scale = min(destFrameInContainer.width / sourceFrameInContainer.width, destFrameInContainer.height / sourceFrameInContainer.height)
sourceToDestTransform = origSourceTransform
.translatedBy(x: destFrameInContainer.midX - sourceFrameInContainer.midX, y: destFrameInContainer.midY - sourceFrameInContainer.midY)
.scaledBy(x: scale, y: scale)
.scaledBy(x: destFrameInContainer.width / sourceFrameInContainer.width, y: destFrameInContainer.height / sourceFrameInContainer.height)
} else {
sourceToDestTransform = nil
}
@ -61,17 +59,9 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
let content = itemViewController.takeContent()
content.view.translatesAutoresizingMaskIntoConstraints = true
// Use a separate dimming view from to.view, so that the gallery controls can be in front of the moving content.
let dimmingView = UIView()
dimmingView.backgroundColor = .black
dimmingView.frame = container.bounds
dimmingView.layer.opacity = 0
container.addSubview(dimmingView)
container.addSubview(content.view)
container.addSubview(to.view)
to.view.backgroundColor = nil
container.addSubview(content.view)
to.view.layer.opacity = 0
content.view.frame = sourceFrameInContainer
content.view.layer.opacity = 0
@ -87,8 +77,6 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
let animator = UIViewPropertyAnimator(duration: duration, timingParameters: spring)
animator.addAnimations {
dimmingView.layer.opacity = 1
to.view.layer.opacity = 1
content.view.frame = destFrameInContainer
@ -102,8 +90,6 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
}
animator.addCompletion { _ in
to.view.backgroundColor = .black
if sourceToDestTransform != nil {
self.sourceView.transform = origSourceTransform
}

View File

@ -57,7 +57,7 @@ class ImageGalleryContentViewController: UIViewController, GalleryContentViewCon
imageView = GIFImageView(image: maybeGrayscaleImage)
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.contentMode = .scaleAspectFill
imageView.contentMode = .scaleAspectFit
imageView.isUserInteractionEnabled = true
view.addSubview(imageView)
NSLayoutConstraint.activate([

View File

@ -30,7 +30,7 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
switch attachment.kind {
case .image:
if let view = attachmentView(for: attachment),
let image = view.attachmentImage {
let image = view.image {
return ImageGalleryContentViewController(
url: attachment.url,
caption: attachment.description,

View File

@ -32,16 +32,6 @@ class AttachmentView: GIFImageView {
private var loadAttachmentTask: Task<Void, Never>?
private var source: Source?
var attachmentImage: UIImage? {
switch source {
case .image(_, _, let image):
return image
case .gifData(_, _, let image):
return image
case nil:
return nil
}
}
var originalData: Data? {
switch source {
case .image(_, let data, _):