MeetingFormAttachmentItemCell.swift 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // MeetingFormAttachmentItemCell.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2020/11/30.
  6. // Copyright © 2020 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class MeetingFormAttachmentItemCell: UITableViewCell {
  10. @IBOutlet weak var attachmentIcon: UIImageView!
  11. @IBOutlet weak var attachmentName: UILabel!
  12. @IBOutlet weak var deleteBtn: UIButton!
  13. override func awakeFromNib() {
  14. super.awakeFromNib()
  15. }
  16. override func setSelected(_ selected: Bool, animated: Bool) {
  17. super.setSelected(selected, animated: animated)
  18. }
  19. func flushData(atta: OOMeetingAttachmentList, editMode: Bool) {
  20. if editMode {
  21. self.deleteBtn.isHidden = false
  22. } else {
  23. self.deleteBtn.isHidden = true
  24. }
  25. self.setFileTypeImage(ext: atta.extension)
  26. self.attachmentName.text = atta.name
  27. }
  28. private func setFileTypeImage(ext: String?) {
  29. if let type = ext {
  30. switch type {
  31. case "jpg", "png", "jepg", "gif":
  32. self.attachmentIcon.image = UIImage(named: "icon_img")
  33. break
  34. case "html":
  35. self.attachmentIcon.image = UIImage(named: "icon_html")
  36. break
  37. case "xls", "xlsx":
  38. self.attachmentIcon.image = UIImage(named: "icon_excel")
  39. break
  40. case "doc", "docx":
  41. self.attachmentIcon.image = UIImage(named: "icon_word")
  42. break
  43. case "ppt", "pptx":
  44. self.attachmentIcon.image = UIImage(named: "icon_ppt")
  45. break
  46. case "pdf":
  47. self.attachmentIcon.image = UIImage(named: "icon_pdf")
  48. break
  49. case "mp4":
  50. self.attachmentIcon.image = UIImage(named: "icon_mp4")
  51. break
  52. case "mp3":
  53. self.attachmentIcon.image = UIImage(named: "icon_mp3")
  54. break
  55. case "zip", "rar", "7z":
  56. self.attachmentIcon.image = UIImage(named: "icon_zip")
  57. break
  58. default :
  59. self.attachmentIcon.image = UIImage(named: "icon_moren")
  60. break
  61. }
  62. }else {
  63. self.attachmentIcon.image = UIImage(named: "icon_moren")
  64. }
  65. }
  66. }