CalendarTableViewCell.swift 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // CalendarTableViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2018/8/3.
  6. // Copyright © 2018 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. protocol CalendarCellSwithOnDelegate {
  10. func click(isOn: Bool, calendar: OOCalendarInfo?)
  11. }
  12. class CalendarTableViewCell: UITableViewCell {
  13. var calendarCellDelegate: CalendarCellSwithOnDelegate?
  14. var calendarInfo: OOCalendarInfo?
  15. @IBOutlet weak var calendarColorView: UIView!
  16. @IBOutlet weak var calendarNameView: UILabel!
  17. @IBOutlet weak var calendarSwitch: UISwitch!
  18. @IBAction func calendarSwitchTap(_ sender: UISwitch) {
  19. calendarCellDelegate?.click(isOn: sender.isOn, calendar: self.calendarInfo)
  20. }
  21. override func awakeFromNib() {
  22. super.awakeFromNib()
  23. // Initialization code
  24. }
  25. override func setSelected(_ selected: Bool, animated: Bool) {
  26. super.setSelected(selected, animated: animated)
  27. // Configure the view for the selected state
  28. }
  29. func renderCalendar(info: OOCalendarInfo?, _ calendarIds:[String] = []) {
  30. self.calendarInfo = info
  31. if let color = info?.color {
  32. calendarColorView.backgroundColor = UIColor.init(hex: color)
  33. }else {
  34. calendarColorView.theme_backgroundColor = ThemeColorPicker(keyPath: "Base.base_color")
  35. }
  36. calendarNameView.text = info?.name
  37. if !calendarIds.isEmpty {
  38. if let id = info?.id, calendarIds.contains(id) {
  39. self.calendarSwitch.isOn = true
  40. } else {
  41. self.calendarSwitch.isOn = false
  42. }
  43. }
  44. }
  45. }