Compare commits

..

No commits in common. "442f57bfc40e3a855f3770e4bcf4032ba903f8fb" and "46b455c3d1ff4ea8686501aed45e5b5a2e38b597" have entirely different histories.

7 changed files with 11 additions and 47 deletions

View File

@ -52,9 +52,6 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans
appliedSourceToDestTransform = false
}
to.view.frame = container.bounds
from.view.frame = container.bounds
let content = itemViewController.takeContent()
content.view.translatesAutoresizingMaskIntoConstraints = true
content.view.layer.masksToBounds = true
@ -115,8 +112,6 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans
return
}
toVC.view.frame = transitionContext.containerView.bounds
fromVC.view.frame = transitionContext.containerView.bounds
transitionContext.containerView.addSubview(toVC.view)
transitionContext.containerView.addSubview(fromVC.view)

View File

@ -109,6 +109,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
itemViewController.addContent()
transitionContext.completeTransition(true)
to.presentationAnimationCompleted()
}
animator.startAnimation()
@ -119,9 +121,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
return
}
to.view.alpha = 0
to.view.frame = transitionContext.containerView.bounds
transitionContext.containerView.addSubview(to.view)
to.view.alpha = 0
let duration = transitionDuration(using: transitionContext)
let animator = UIViewPropertyAnimator(duration: duration, curve: .easeInOut)
@ -130,6 +131,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
}
animator.addCompletion { _ in
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
to.presentationAnimationCompleted()
}
animator.startAnimation()
}

View File

@ -68,17 +68,6 @@ public class GalleryViewController: UIPageViewController {
setViewControllers([makeItemVC(index: initialItemIndex)], direction: .forward, animated: false)
}
public override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if animated {
// Wait until the transition is no longer in-progress, otherwise things will just get deferred again.
DispatchQueue.main.async {
self.presentationAnimationCompleted()
}
}
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)

View File

@ -15,12 +15,10 @@ import AVFoundation
class StatusAttachmentsGalleryDataSource: GalleryDataSource {
let attachments: [Attachment]
let sourceViews: NSHashTable<AttachmentView>
weak var moreView: UIView?
init(attachments: [Attachment], sourceViews: NSHashTable<AttachmentView>, moreView: UIView?) {
init(attachments: [Attachment], sourceViews: NSHashTable<AttachmentView>) {
self.attachments = attachments
self.sourceViews = sourceViews
self.moreView = moreView
}
func galleryItemsCount() -> Int {
@ -41,21 +39,6 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
// TODO: if automatically play gifs is off, this will start the source view playing too
gifController: view.gifController
)
} else if let entry = ImageCache.attachments.get(attachment.url, loadOriginal: true) {
let gifController: GIFController? =
if attachment.url.pathExtension == "gif",
let data = entry.data {
GIFController(gifData: data)
} else {
nil
}
return ImageGalleryContentViewController(
url: attachment.url,
caption: attachment.description,
originalData: entry.data,
image: entry.image,
gifController: gifController
)
} else {
return LoadingGalleryContentViewController {
let (data, image) = await ImageCache.attachments.get(attachment.url, loadOriginal: true)
@ -109,12 +92,8 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
}
func galleryContentTransitionSourceView(forItemAt index: Int) -> UIView? {
if attachments.count > 4 && index >= 3 {
return moreView
} else {
let attachment = attachments[index]
return attachmentView(for: attachment)
}
let attachment = attachments[index]
return attachmentView(for: attachment)
}
func galleryApplicationActivities(forItemAt index: Int) -> [UIActivity]? {

View File

@ -238,8 +238,7 @@ extension StatusEditCollectionViewCell: AttachmentViewDelegate {
func attachmentViewGallery(startingAt index: Int) -> UIViewController? {
let attachments = attachmentsView.attachments!
let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable<AttachmentView>
let dataSource = StatusAttachmentsGalleryDataSource(attachments: attachments, sourceViews: sourceViews, moreView: attachmentsView.moreView)
return GalleryVC.GalleryViewController(dataSource: dataSource, initialItemIndex: index)
return GalleryVC.GalleryViewController(dataSource: StatusAttachmentsGalleryDataSource(attachments: attachments, sourceViews: sourceViews), initialItemIndex: index)
}
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {

View File

@ -18,7 +18,7 @@ class AttachmentsContainerView: UIView {
let attachmentViews: NSHashTable<AttachmentView> = .weakObjects()
let attachmentStacks: NSHashTable<UIStackView> = .weakObjects()
private(set) var moreView: UIView?
var moreView: UIView?
private var aspectRatioConstraint: NSLayoutConstraint?
private(set) var aspectRatio: CGFloat = 16/9 {
didSet {

View File

@ -334,8 +334,7 @@ extension StatusCollectionViewCell {
return nil
}
let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable<AttachmentView>
let dataSource = StatusAttachmentsGalleryDataSource(attachments: status.attachments, sourceViews: sourceViews, moreView: attachmentsView.moreView)
return GalleryVC.GalleryViewController(dataSource: dataSource, initialItemIndex: index)
return GalleryVC.GalleryViewController(dataSource: StatusAttachmentsGalleryDataSource(attachments: status.attachments, sourceViews: sourceViews), initialItemIndex: index)
}
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {