Compare commits
No commits in common. "442f57bfc40e3a855f3770e4bcf4032ba903f8fb" and "46b455c3d1ff4ea8686501aed45e5b5a2e38b597" have entirely different histories.
442f57bfc4
...
46b455c3d1
|
@ -52,9 +52,6 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans
|
||||||
appliedSourceToDestTransform = false
|
appliedSourceToDestTransform = false
|
||||||
}
|
}
|
||||||
|
|
||||||
to.view.frame = container.bounds
|
|
||||||
from.view.frame = container.bounds
|
|
||||||
|
|
||||||
let content = itemViewController.takeContent()
|
let content = itemViewController.takeContent()
|
||||||
content.view.translatesAutoresizingMaskIntoConstraints = true
|
content.view.translatesAutoresizingMaskIntoConstraints = true
|
||||||
content.view.layer.masksToBounds = true
|
content.view.layer.masksToBounds = true
|
||||||
|
@ -115,8 +112,6 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
toVC.view.frame = transitionContext.containerView.bounds
|
|
||||||
fromVC.view.frame = transitionContext.containerView.bounds
|
|
||||||
transitionContext.containerView.addSubview(toVC.view)
|
transitionContext.containerView.addSubview(toVC.view)
|
||||||
transitionContext.containerView.addSubview(fromVC.view)
|
transitionContext.containerView.addSubview(fromVC.view)
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
|
||||||
itemViewController.addContent()
|
itemViewController.addContent()
|
||||||
|
|
||||||
transitionContext.completeTransition(true)
|
transitionContext.completeTransition(true)
|
||||||
|
|
||||||
|
to.presentationAnimationCompleted()
|
||||||
}
|
}
|
||||||
|
|
||||||
animator.startAnimation()
|
animator.startAnimation()
|
||||||
|
@ -119,9 +121,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
to.view.alpha = 0
|
|
||||||
to.view.frame = transitionContext.containerView.bounds
|
|
||||||
transitionContext.containerView.addSubview(to.view)
|
transitionContext.containerView.addSubview(to.view)
|
||||||
|
to.view.alpha = 0
|
||||||
|
|
||||||
let duration = transitionDuration(using: transitionContext)
|
let duration = transitionDuration(using: transitionContext)
|
||||||
let animator = UIViewPropertyAnimator(duration: duration, curve: .easeInOut)
|
let animator = UIViewPropertyAnimator(duration: duration, curve: .easeInOut)
|
||||||
|
@ -130,6 +131,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
|
||||||
}
|
}
|
||||||
animator.addCompletion { _ in
|
animator.addCompletion { _ in
|
||||||
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
|
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
|
||||||
|
|
||||||
|
to.presentationAnimationCompleted()
|
||||||
}
|
}
|
||||||
animator.startAnimation()
|
animator.startAnimation()
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,17 +68,6 @@ public class GalleryViewController: UIPageViewController {
|
||||||
setViewControllers([makeItemVC(index: initialItemIndex)], direction: .forward, animated: false)
|
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) {
|
public override func viewWillDisappear(_ animated: Bool) {
|
||||||
super.viewWillDisappear(animated)
|
super.viewWillDisappear(animated)
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,10 @@ import AVFoundation
|
||||||
class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
||||||
let attachments: [Attachment]
|
let attachments: [Attachment]
|
||||||
let sourceViews: NSHashTable<AttachmentView>
|
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.attachments = attachments
|
||||||
self.sourceViews = sourceViews
|
self.sourceViews = sourceViews
|
||||||
self.moreView = moreView
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func galleryItemsCount() -> Int {
|
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
|
// TODO: if automatically play gifs is off, this will start the source view playing too
|
||||||
gifController: view.gifController
|
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 {
|
} else {
|
||||||
return LoadingGalleryContentViewController {
|
return LoadingGalleryContentViewController {
|
||||||
let (data, image) = await ImageCache.attachments.get(attachment.url, loadOriginal: true)
|
let (data, image) = await ImageCache.attachments.get(attachment.url, loadOriginal: true)
|
||||||
|
@ -109,13 +92,9 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func galleryContentTransitionSourceView(forItemAt index: Int) -> UIView? {
|
func galleryContentTransitionSourceView(forItemAt index: Int) -> UIView? {
|
||||||
if attachments.count > 4 && index >= 3 {
|
|
||||||
return moreView
|
|
||||||
} else {
|
|
||||||
let attachment = attachments[index]
|
let attachment = attachments[index]
|
||||||
return attachmentView(for: attachment)
|
return attachmentView(for: attachment)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func galleryApplicationActivities(forItemAt index: Int) -> [UIActivity]? {
|
func galleryApplicationActivities(forItemAt index: Int) -> [UIActivity]? {
|
||||||
[SaveToPhotosActivity()]
|
[SaveToPhotosActivity()]
|
||||||
|
|
|
@ -238,8 +238,7 @@ extension StatusEditCollectionViewCell: AttachmentViewDelegate {
|
||||||
func attachmentViewGallery(startingAt index: Int) -> UIViewController? {
|
func attachmentViewGallery(startingAt index: Int) -> UIViewController? {
|
||||||
let attachments = attachmentsView.attachments!
|
let attachments = attachmentsView.attachments!
|
||||||
let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable<AttachmentView>
|
let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable<AttachmentView>
|
||||||
let dataSource = StatusAttachmentsGalleryDataSource(attachments: attachments, sourceViews: sourceViews, moreView: attachmentsView.moreView)
|
return GalleryVC.GalleryViewController(dataSource: StatusAttachmentsGalleryDataSource(attachments: attachments, sourceViews: sourceViews), initialItemIndex: index)
|
||||||
return GalleryVC.GalleryViewController(dataSource: dataSource, initialItemIndex: index)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {
|
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ class AttachmentsContainerView: UIView {
|
||||||
|
|
||||||
let attachmentViews: NSHashTable<AttachmentView> = .weakObjects()
|
let attachmentViews: NSHashTable<AttachmentView> = .weakObjects()
|
||||||
let attachmentStacks: NSHashTable<UIStackView> = .weakObjects()
|
let attachmentStacks: NSHashTable<UIStackView> = .weakObjects()
|
||||||
private(set) var moreView: UIView?
|
var moreView: UIView?
|
||||||
private var aspectRatioConstraint: NSLayoutConstraint?
|
private var aspectRatioConstraint: NSLayoutConstraint?
|
||||||
private(set) var aspectRatio: CGFloat = 16/9 {
|
private(set) var aspectRatio: CGFloat = 16/9 {
|
||||||
didSet {
|
didSet {
|
||||||
|
|
|
@ -334,8 +334,7 @@ extension StatusCollectionViewCell {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable<AttachmentView>
|
let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable<AttachmentView>
|
||||||
let dataSource = StatusAttachmentsGalleryDataSource(attachments: status.attachments, sourceViews: sourceViews, moreView: attachmentsView.moreView)
|
return GalleryVC.GalleryViewController(dataSource: StatusAttachmentsGalleryDataSource(attachments: status.attachments, sourceViews: sourceViews), initialItemIndex: index)
|
||||||
return GalleryVC.GalleryViewController(dataSource: dataSource, initialItemIndex: index)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {
|
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {
|
||||||
|
|
Loading…
Reference in New Issue