diff --git a/Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift b/Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift index e4c495a1..c2c53b0d 100644 --- a/Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift +++ b/Tusker/Screens/Gallery/StatusAttachmentsGalleryDataSource.swift @@ -15,10 +15,12 @@ import AVFoundation class StatusAttachmentsGalleryDataSource: GalleryDataSource { let attachments: [Attachment] let sourceViews: NSHashTable + weak var moreView: UIView? - init(attachments: [Attachment], sourceViews: NSHashTable) { + init(attachments: [Attachment], sourceViews: NSHashTable, 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]? { diff --git a/Tusker/Screens/Status Edit History/StatusEditCollectionViewCell.swift b/Tusker/Screens/Status Edit History/StatusEditCollectionViewCell.swift index 061bbff9..b29ce12f 100644 --- a/Tusker/Screens/Status Edit History/StatusEditCollectionViewCell.swift +++ b/Tusker/Screens/Status Edit History/StatusEditCollectionViewCell.swift @@ -238,7 +238,8 @@ extension StatusEditCollectionViewCell: AttachmentViewDelegate { func attachmentViewGallery(startingAt index: Int) -> UIViewController? { let attachments = attachmentsView.attachments! let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable - 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) { diff --git a/Tusker/Views/Attachments/AttachmentsContainerView.swift b/Tusker/Views/Attachments/AttachmentsContainerView.swift index 9c1b34da..a72596cd 100644 --- a/Tusker/Views/Attachments/AttachmentsContainerView.swift +++ b/Tusker/Views/Attachments/AttachmentsContainerView.swift @@ -18,7 +18,7 @@ class AttachmentsContainerView: UIView { let attachmentViews: NSHashTable = .weakObjects() let attachmentStacks: NSHashTable = .weakObjects() - var moreView: UIView? + private(set) var moreView: UIView? private var aspectRatioConstraint: NSLayoutConstraint? private(set) var aspectRatio: CGFloat = 16/9 { didSet { diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index f1a45151..2e09a663 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -334,7 +334,8 @@ extension StatusCollectionViewCell { return nil } let sourceViews = attachmentsView.attachmentViews.copy() as! NSHashTable - 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) {