diff --git a/Yep/Views/Cells/Feed/FeedCell.swift b/Yep/Views/Cells/Feed/FeedCell.swift index 4c81cd0c..c39b53fc 100644 --- a/Yep/Views/Cells/Feed/FeedCell.swift +++ b/Yep/Views/Cells/Feed/FeedCell.swift @@ -100,29 +100,8 @@ class FeedCell: FeedBasicCell { messageTextView.attributedText = nil } - - private func calHeightOfMessageTextView() { - - let rect = messageTextView.text.boundingRectWithSize(CGSize(width: FeedCell.messageTextViewMaxWidth, height: CGFloat(FLT_MAX)), options: [.UsesLineFragmentOrigin, .UsesFontLeading], attributes: YepConfig.FeedCell.textAttributes, context: nil) - messageTextViewHeightConstraint.constant = ceil(rect.height) - } - - func configureWithFeed(feed: DiscoveredFeed, needShowSkill: Bool) { - - messageTextView.text = "\u{200B}\(feed.body)" // ref http://stackoverflow.com/a/25994821 - - calHeightOfMessageTextView() - - if needShowSkill, let skill = feed.skill { - skillLabel.text = skill.localName - - skillBubbleImageView.hidden = false - skillLabel.hidden = false - - } else { - skillBubbleImageView.hidden = true - skillLabel.hidden = true - } + override func configureWithFeed(feed: DiscoveredFeed, needShowSkill: Bool) { + super.configureWithFeed(feed, needShowSkill: needShowSkill) let hasMedia = !feed.attachments.isEmpty @@ -135,24 +114,6 @@ class FeedCell: FeedBasicCell { mediaCollectionView.hidden = hasMedia ? false : true attachments = feed.attachments - - let plainAvatar = PlainAvatar(avatarURLString: feed.creator.avatarURLString, avatarStyle: nanoAvatarStyle) - avatarImageView.navi_setAvatar(plainAvatar) - - nicknameLabel.text = feed.creator.nickname - - if let distance = feed.distance { - - if distance < 1 { - distanceLabel.text = NSLocalizedString("Nearby", comment: "") - } else { - distanceLabel.text = "\(distance.format(".1")) km" - } - - } - - timeLabel.text = "\(NSDate(timeIntervalSince1970: feed.createdUnixTime).timeAgo)" - messageCountLabel.text = "\(feed.messagesCount)" } } diff --git a/Yep/Views/Cells/FeedBasic/FeedBasicCell.swift b/Yep/Views/Cells/FeedBasic/FeedBasicCell.swift index c0eaefc6..e7711499 100644 --- a/Yep/Views/Cells/FeedBasic/FeedBasicCell.swift +++ b/Yep/Views/Cells/FeedBasic/FeedBasicCell.swift @@ -82,6 +82,48 @@ class FeedBasicCell: UITableViewCell { // Configure the view for the selected state } + private func calHeightOfMessageTextView() { + + let rect = messageTextView.text.boundingRectWithSize(CGSize(width: FeedCell.messageTextViewMaxWidth, height: CGFloat(FLT_MAX)), options: [.UsesLineFragmentOrigin, .UsesFontLeading], attributes: YepConfig.FeedCell.textAttributes, context: nil) + messageTextViewHeightConstraint.constant = ceil(rect.height) + } + + func configureWithFeed(feed: DiscoveredFeed, needShowSkill: Bool) { + + messageTextView.text = "\u{200B}\(feed.body)" // ref http://stackoverflow.com/a/25994821 + + calHeightOfMessageTextView() + + if needShowSkill, let skill = feed.skill { + skillLabel.text = skill.localName + + skillBubbleImageView.hidden = false + skillLabel.hidden = false + + } else { + skillBubbleImageView.hidden = true + skillLabel.hidden = true + } + + let plainAvatar = PlainAvatar(avatarURLString: feed.creator.avatarURLString, avatarStyle: nanoAvatarStyle) + avatarImageView.navi_setAvatar(plainAvatar) + + nicknameLabel.text = feed.creator.nickname + + if let distance = feed.distance { + + if distance < 1 { + distanceLabel.text = NSLocalizedString("Nearby", comment: "") + } else { + distanceLabel.text = "\(distance.format(".1")) km" + } + + } + + timeLabel.text = "\(NSDate(timeIntervalSince1970: feed.createdUnixTime).timeAgo)" + messageCountLabel.text = "\(feed.messagesCount)" + } + // MARK: Actions func tapAvatar(sender: UITapGestureRecognizer) { diff --git a/Yep/Views/Cells/FeedSocialWork/FeedSocialWorkCell.swift b/Yep/Views/Cells/FeedSocialWork/FeedSocialWorkCell.swift index de2f579a..3f5736e3 100644 --- a/Yep/Views/Cells/FeedSocialWork/FeedSocialWorkCell.swift +++ b/Yep/Views/Cells/FeedSocialWork/FeedSocialWorkCell.swift @@ -24,19 +24,6 @@ class FeedSocialWorkCell: FeedBasicCell { override func awakeFromNib() { super.awakeFromNib() - - nicknameLabel.textColor = UIColor.yepTintColor() - messageTextView.textColor = UIColor.yepMessageColor() - distanceLabel.textColor = UIColor.grayColor() - timeLabel.textColor = UIColor.grayColor() - dotLabel.textColor = UIColor.grayColor() - messageCountLabel.textColor = UIColor.yepTintColor() - skillLabel.textColor = UIColor.yepTintColor() - - messageTextView.font = UIFont.feedMessageFont() - messageTextView.textContainer.lineFragmentPadding = 0 - messageTextView.textContainerInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) - messageTextView.dataDetectorTypes = .Link } override func setSelected(selected: Bool, animated: Bool) {