mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-11 22:06:40 +10:00
show images of feed
This commit is contained in:
@@ -112,7 +112,7 @@ class NewFeedViewController: UIViewController {
|
||||
|
||||
dispatch_group_enter(uploadMediaImagesGroup)
|
||||
|
||||
s3PublicUploadFile(inFilePath: nil, orFileData: imageData, mimeType: MessageMediaType.Image.mineType, failureHandler: { (reason, errorMessage) in
|
||||
s3PrivateUploadFile(inFilePath: nil, orFileData: imageData, mimeType: MessageMediaType.Image.mineType, failureHandler: { (reason, errorMessage) in
|
||||
|
||||
defaultFailureHandler(reason, errorMessage: errorMessage)
|
||||
|
||||
|
||||
@@ -23,11 +23,20 @@ class FeedCell: UITableViewCell {
|
||||
|
||||
@IBOutlet weak var messageCountLabel: UILabel!
|
||||
|
||||
|
||||
var attachmentURLs = [NSURL]() {
|
||||
didSet {
|
||||
mediaCollectionView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
static let messageLabelMaxWidth: CGFloat = {
|
||||
let maxWidth = UIScreen.mainScreen().bounds.width - (60 + 10)
|
||||
return maxWidth
|
||||
}()
|
||||
|
||||
let feedMediaCellID = "FeedMediaCell"
|
||||
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
@@ -39,6 +48,7 @@ class FeedCell: UITableViewCell {
|
||||
|
||||
messageLabel.font = UIFont.feedMessageFont()
|
||||
|
||||
mediaCollectionView.registerNib(UINib(nibName: feedMediaCellID, bundle: nil), forCellWithReuseIdentifier: feedMediaCellID)
|
||||
mediaCollectionView.dataSource = self
|
||||
mediaCollectionView.delegate = self
|
||||
|
||||
@@ -53,7 +63,7 @@ class FeedCell: UITableViewCell {
|
||||
timeLabelTopConstraint.constant = hasMedia ? 100 : 10
|
||||
mediaCollectionView.hidden = hasMedia ? false : true
|
||||
|
||||
//let URLs = feed.attachments.map({ NSURL(string: $0.URLString) }).flatMap({ $0 })
|
||||
attachmentURLs = feed.attachments.map({ NSURL(string: $0.URLString) }).flatMap({ $0 })
|
||||
|
||||
let avatarURLString = feed.creator.avatarURLString
|
||||
let radius = min(CGRectGetWidth(avatarImageView.bounds), CGRectGetHeight(avatarImageView.bounds)) * 0.5
|
||||
@@ -83,12 +93,19 @@ extension FeedCell: UICollectionViewDataSource, UICollectionViewDelegate {
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return 15
|
||||
return attachmentURLs.count
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
|
||||
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath)
|
||||
cell.backgroundColor = UIColor.greenColor()
|
||||
|
||||
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(feedMediaCellID, forIndexPath: indexPath) as! FeedMediaCell
|
||||
|
||||
let imageURL = attachmentURLs[indexPath.item]
|
||||
|
||||
println("attachment imageURL: \(imageURL)")
|
||||
|
||||
cell.configureWithImageURL(imageURL)
|
||||
|
||||
return cell
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Kingfisher
|
||||
|
||||
class FeedMediaCell: UICollectionViewCell {
|
||||
|
||||
@@ -21,4 +22,8 @@ class FeedMediaCell: UICollectionViewCell {
|
||||
func configureWithImage(image: UIImage) {
|
||||
imageView.image = image
|
||||
}
|
||||
|
||||
func configureWithImageURL(imageURL: NSURL) {
|
||||
imageView.kf_setImageWithURL(imageURL)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user