CalendarEventTableViewCell.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // CalendarEventTableViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2018/7/27.
  6. // Copyright © 2018 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class CalendarEventTableViewCell: UITableViewCell {
  10. @IBOutlet weak var eventColorView: UIView!
  11. @IBOutlet weak var eventTitleView: UILabel!
  12. @IBOutlet weak var eventTimeStack: UIStackView!
  13. @IBOutlet weak var eventStartTime: UILabel!
  14. @IBOutlet weak var eventEndTime: UILabel!
  15. @IBOutlet weak var eventAllDay: UILabel!
  16. override func awakeFromNib() {
  17. super.awakeFromNib()
  18. // Initialization code
  19. eventColorView.setCornerRadius(radius: CGFloat(9))
  20. eventAllDay.isHidden = true
  21. }
  22. override func setSelected(_ selected: Bool, animated: Bool) {
  23. super.setSelected(selected, animated: animated)
  24. // Configure the view for the selected state
  25. }
  26. func renderCell(withItem event: Any?) {
  27. guard let model = event as? OOCalendarEventInfo else {
  28. return
  29. }
  30. eventTitleView.text = model.title
  31. if let color = model.color {
  32. eventColorView.backgroundColor = UIColor.init(hex: color)
  33. }else {
  34. eventColorView.theme_backgroundColor = ThemeColorPicker(keyPath: "Base.base_color")
  35. }
  36. if model.isAllDayEvent == true {
  37. eventTimeStack.isHidden = true
  38. eventAllDay.isHidden = false
  39. }else {
  40. eventTimeStack.isHidden = false
  41. eventAllDay.isHidden = true
  42. let starttime = model.startTimeStr?.subString(from: 11, to: 16) ?? ""
  43. eventStartTime.text = starttime
  44. let endtime = model.endTimeStr?.subString(from: 11, to: 16) ?? ""
  45. eventEndTime.text = endtime
  46. }
  47. }
  48. }