diff --git a/Yep/ViewControllers/Feeds/FeedsViewController.swift b/Yep/ViewControllers/Feeds/FeedsViewController.swift index fe0696f0..a560c6fb 100644 --- a/Yep/ViewControllers/Feeds/FeedsViewController.swift +++ b/Yep/ViewControllers/Feeds/FeedsViewController.swift @@ -585,13 +585,36 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate { } } - cell.tapMediaAction = { [weak self] transitionView, attachments, index in + cell.tapMediaAction = { [weak self] transitionView, image, attachments, index in + + let vc = UIStoryboard(name: "MediaPreview", bundle: nil).instantiateViewControllerWithIdentifier("MediaPreviewViewController") as! MediaPreviewViewController + + vc.previewMedias = attachments.map({ PreviewMedia.AttachmentType(attachment: $0) }) + vc.startIndex = index + + let transitionView = transitionView + let frame = transitionView.convertRect(transitionView.frame, toView: self?.view) + vc.previewImageViewInitalFrame = frame + vc.previewImage = image + + transitionView.alpha = 0 + vc.afterDismissAction = { [weak self] in + self?.view.window?.makeKeyAndVisible() + transitionView.alpha = 1 + } + + mediaPreviewWindow.rootViewController = vc + mediaPreviewWindow.windowLevel = UIWindowLevelAlert - 1 + mediaPreviewWindow.makeKeyAndVisible() + + /* let info: [String: AnyObject] = [ "transitionView": transitionView, "attachments": Box(value: attachments), "index": index, ] self?.performSegueWithIdentifier("showFeedMedia", sender: info) + */ } // simulate select effects when tap on messageTextView or cell.mediaCollectionView's space part diff --git a/Yep/Views/Cells/Feed/FeedCell.swift b/Yep/Views/Cells/Feed/FeedCell.swift index 13edc43b..c3db4b03 100644 --- a/Yep/Views/Cells/Feed/FeedCell.swift +++ b/Yep/Views/Cells/Feed/FeedCell.swift @@ -30,7 +30,7 @@ class FeedCell: UITableViewCell { var tapAvatarAction: (UITableViewCell -> Void)? var tapSkillAction: (UITableViewCell -> Void)? - var tapMediaAction: ((transitionView: UIView, attachments: [DiscoveredAttachment], index: Int) -> Void)? + var tapMediaAction: ((transitionView: UIView, image: UIImage?, attachments: [DiscoveredAttachment], index: Int) -> Void)? var touchesBeganAction: (UITableViewCell -> Void)? var touchesEndedAction: (UITableViewCell -> Void)? @@ -263,7 +263,7 @@ extension FeedCell: UICollectionViewDataSource, UICollectionViewDelegate { let cell = collectionView.cellForItemAtIndexPath(indexPath) as! FeedMediaCell let transitionView = cell.imageView - tapMediaAction?(transitionView: transitionView, attachments: attachments, index: indexPath.item) + tapMediaAction?(transitionView: transitionView, image: cell.imageView.image, attachments: attachments, index: indexPath.item) } }