MindMapItemTableViewCell.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // MindMapItemTableViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2021/12/16.
  6. // Copyright © 2021 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class MindMapItemTableViewCell: UITableViewCell {
  10. override func awakeFromNib() {
  11. super.awakeFromNib()
  12. // Initialization code
  13. }
  14. override func setSelected(_ selected: Bool, animated: Bool) {
  15. super.setSelected(selected, animated: animated)
  16. }
  17. @IBOutlet weak var preViewImage: UIImageView! //预览图
  18. @IBOutlet weak var titleLabel: UILabel!
  19. @IBOutlet weak var versionLabel: UILabel!
  20. @IBOutlet weak var timeLabel: UILabel!
  21. func setItem(item: MindMapItem) {
  22. self.titleLabel.text = item.name
  23. self.versionLabel.text = "版本:\(item.fileVersion ?? 1)"
  24. self.timeLabel.text = timeFormat(time: item.updateTime)
  25. // todo 图片
  26. if let icon = item.icon, icon != "" {
  27. let urlstr = O2AuthSDK.shared.getFileDownloadUrl(fileId: icon)
  28. let url = URL(string: urlstr)
  29. self.preViewImage.hnk_setImageFromURL(url!)
  30. }
  31. }
  32. /// @param time 2019-02-11 12:20:00
  33. private func timeFormat(time: String?)-> String {
  34. guard let t = time else {
  35. return ""
  36. }
  37. let thisYear = Date().year
  38. let timeYear = t.subString(from: 0, to: 4)
  39. if timeYear == "\(thisYear)" {
  40. return t.subString(from: 5, to: 16)
  41. } else {
  42. return t.subString(from: 0, to: 16)
  43. }
  44. }
  45. }