forked from shadowfacts/Tusker
Enable gallery interactive dismissal for statuses with >4 attachments
Closes #466
This commit is contained in:
parent
ae7101bb30
commit
442f57bfc4
|
@ -15,10 +15,12 @@ import AVFoundation
|
|||
class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
||||
let attachments: [Attachment]
|
||||
let sourceViews: NSHashTable<AttachmentView>
|
||||
weak var moreView: UIView?
|
||||
|
||||
init(attachments: [Attachment], sourceViews: NSHashTable<AttachmentView>) {
|
||||
init(attachments: [Attachment], sourceViews: NSHashTable<AttachmentView>, moreView: UIView?) {
|
||||
self.attachments = attachments
|
||||
self.sourceViews = sourceViews
|
||||
self.moreView = moreView
|
||||
}
|
||||
|
||||
func galleryItemsCount() -> Int {
|
||||
|
@ -107,8 +109,12 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
|
|||
}
|
||||
|
||||
func galleryContentTransitionSourceView(forItemAt index: Int) -> UIView? {
|
||||
let attachment = attachments[index]
|
||||
return attachmentView(for: attachment)
|
||||
if attachments.count > 4 && index >= 3 {
|
||||
return moreView
|
||||
} else {
|
||||
let attachment = attachments[index]
|
||||
return attachmentView(for: attachment)
|
||||
}
|
||||
}
|
||||
|
||||
func galleryApplicationActivities(forItemAt index: Int) -> [UIActivity]? {
|
||||
|
|
|
@ -238,7 +238,8 @@ extension StatusEditCollectionViewCell: AttachmentViewDelegate {
|
|||
func attachmentViewGallery(startingAt index: Int) -> UIViewController? {
|
||||
let attachments = attachmentsView.attachments!
|
||||
let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable<AttachmentView>
|
||||
return GalleryVC.GalleryViewController(dataSource: StatusAttachmentsGalleryDataSource(attachments: attachments, sourceViews: sourceViews), initialItemIndex: index)
|
||||
let dataSource = StatusAttachmentsGalleryDataSource(attachments: attachments, sourceViews: sourceViews, moreView: attachmentsView.moreView)
|
||||
return GalleryVC.GalleryViewController(dataSource: dataSource, initialItemIndex: index)
|
||||
}
|
||||
|
||||
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {
|
||||
|
|
|
@ -18,7 +18,7 @@ class AttachmentsContainerView: UIView {
|
|||
|
||||
let attachmentViews: NSHashTable<AttachmentView> = .weakObjects()
|
||||
let attachmentStacks: NSHashTable<UIStackView> = .weakObjects()
|
||||
var moreView: UIView?
|
||||
private(set) var moreView: UIView?
|
||||
private var aspectRatioConstraint: NSLayoutConstraint?
|
||||
private(set) var aspectRatio: CGFloat = 16/9 {
|
||||
didSet {
|
||||
|
|
|
@ -334,7 +334,8 @@ extension StatusCollectionViewCell {
|
|||
return nil
|
||||
}
|
||||
let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable<AttachmentView>
|
||||
return GalleryVC.GalleryViewController(dataSource: StatusAttachmentsGalleryDataSource(attachments: status.attachments, sourceViews: sourceViews), initialItemIndex: index)
|
||||
let dataSource = StatusAttachmentsGalleryDataSource(attachments: status.attachments, sourceViews: sourceViews, moreView: attachmentsView.moreView)
|
||||
return GalleryVC.GalleryViewController(dataSource: dataSource, initialItemIndex: index)
|
||||
}
|
||||
|
||||
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {
|
||||
|
|
Loading…
Reference in New Issue