SubjectTableViewCell.swift 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // SubjectTableViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2016/11/4.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import SDWebImage
  10. import Alamofire
  11. import ObjectMapper
  12. import CocoaLumberjack
  13. class SubjectTableViewCell: UITableViewCell {
  14. @IBOutlet weak var topSubjectImageView: UIImageView!
  15. @IBOutlet weak var subjectTitleLabel: UILabel!
  16. @IBOutlet weak var subjectNameLabel: UILabel!
  17. @IBOutlet weak var subjectPubDateLabel: UILabel!
  18. @IBOutlet weak var subjectViewNumberLabel: UILabel!
  19. @IBOutlet weak var subjectReplyNumberLabel: UILabel!
  20. var bbsSubjectData:BBSSubjectData? {
  21. didSet {
  22. self.topSubjectImageView.isHidden = !(bbsSubjectData?.isTopSubject)!
  23. let type = "[\(bbsSubjectData?.type ?? "")]"
  24. let allTitle = "\(type) \(bbsSubjectData?.title ?? "")"
  25. let mas = NSMutableAttributedString(string: allTitle)
  26. mas.addAttributes([NSAttributedString.Key.foregroundColor:UIColor.hexInt(0x999999)], range: NSRange(location: 0, length: type.length))
  27. self.subjectTitleLabel.attributedText = mas
  28. self.subjectNameLabel.text = (bbsSubjectData?.creatorName?.contains("@"))! ? bbsSubjectData?.creatorName?.split("@")[0] : bbsSubjectData?.creatorName
  29. self.subjectViewNumberLabel.text = bbsSubjectData?.viewTotal?.toString
  30. self.subjectReplyNumberLabel.text = bbsSubjectData?.replyTotal?.toString
  31. if let time = bbsSubjectData?.latestReplyTime, let date = Date.date(time) {
  32. self.subjectPubDateLabel.text = date.friendlyTime()
  33. } else {
  34. self.subjectPubDateLabel.text = ""
  35. }
  36. //let urlString = AppDelegate.o2Collect.generateURLWithAppContextKey(ContactContext.contactsContextKey, query: ContactContext.personIconByNameQuery, parameter: ["##name##":bbsSubjectData?.creatorName as AnyObject])
  37. //let url = URL(string: urlString!)
  38. //self.subjectPersonIconImageView.af_setImage(withURL: url!)
  39. // let urlstr = AppDelegate.o2Collect.generateURLWithAppContextKey(ContactContext.contactsContextKeyV2, query: ContactContext.personIconByNameQueryV2, parameter: ["##name##":bbsSubjectData?.creatorName as AnyObject], generateTime: false)
  40. // let url = URL(string: urlstr!)
  41. // self.subjectPersonIconImageView.hnk_setImageFromURL(url!)
  42. }
  43. }
  44. override func setSelected(_ selected: Bool, animated: Bool) {
  45. super.setSelected(selected, animated: animated)
  46. // Configure the view for the selected state
  47. }
  48. }