mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-10 21:36:49 +10:00
part of configureWithFeed in FeedBasicCell
This commit is contained in:
@@ -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)"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user