refactor feedURLContainerView.configureWithFeedURLInfoType

This commit is contained in:
nixzhu
2016-01-15 14:18:05 +08:00
parent 7232a62c7b
commit b138fbe2ec
3 changed files with 16 additions and 18 deletions
+1 -9
View File
@@ -60,16 +60,8 @@ class FeedURLCell: FeedBasicCell {
if let attachment = feed.attachment {
if case let .URL(URLInfo) = attachment {
feedURLContainerView.siteNameLabel.text = URLInfo.siteName
feedURLContainerView.titleLabel.text = URLInfo.title
feedURLContainerView.descriptionLabel.text = URLInfo.description
if let thumbnailImageURL = NSURL(string: URLInfo.thumbnailImageURLString) {
feedURLContainerView.thumbnailImageView.kf_setImageWithURL(thumbnailImageURL, placeholderImage: nil)
} else {
feedURLContainerView.thumbnailImageView.image = nil
feedURLContainerView.thumbnailImageView.backgroundColor = UIColor.lightGrayColor()
}
feedURLContainerView.configureWithFeedURLInfoType(URLInfo)
feedURLContainerView.tapAction = { [weak self] in
self?.tapURLAction?(URLInfo.URL)
@@ -125,5 +125,19 @@ class FeedURLContainerView: UIView {
@objc private func tap(sender: UITapGestureRecognizer) {
tapAction?()
}
func configureWithFeedURLInfoType(URLInfo: FeedURLInfoType) {
siteNameLabel.text = URLInfo.siteName
titleLabel.text = URLInfo.title
descriptionLabel.text = URLInfo.infoDescription
if let thumbnailImageURL = NSURL(string: URLInfo.thumbnailImageURLString) {
thumbnailImageView.kf_setImageWithURL(thumbnailImageURL, placeholderImage: nil)
} else {
thumbnailImageView.image = nil
thumbnailImageView.backgroundColor = UIColor.lightGrayColor()
}
}
}
+1 -9
View File
@@ -353,15 +353,7 @@ class FeedView: UIView {
socialWorkContainerViewHeightConstraint.constant = 80
if let URLInfo = feed.URLInfo {
feedURLContainerView.siteNameLabel.text = URLInfo.siteName
feedURLContainerView.titleLabel.text = URLInfo.title
feedURLContainerView.descriptionLabel.text = URLInfo.infoDescription
if let thumbnailImageURL = NSURL(string: URLInfo.thumbnailImageURLString) {
feedURLContainerView.thumbnailImageView.kf_setImageWithURL(thumbnailImageURL, placeholderImage: nil)
} else {
feedURLContainerView.thumbnailImageView.image = nil
feedURLContainerView.thumbnailImageView.backgroundColor = UIColor.lightGrayColor()
}
feedURLContainerView.configureWithFeedURLInfoType(URLInfo)
}
case .Image: