preview from FeedCell

This commit is contained in:
nixzhu
2015-11-10 15:45:49 +08:00
parent 37340023a3
commit 8db078e25d
2 changed files with 26 additions and 3 deletions
@@ -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
+2 -2
View File
@@ -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)
}
}