OOMeetingRoomDetailViewController.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // OOMeetingRoomDetailViewController.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2018/1/22.
  6. // Copyright © 2018年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. private let roomIdentifier = "OOMeetingRoomMainCell"
  10. private let meetingIdentifier = "OOMeetingInforItemCell"
  11. class OOMeetingRoomDetailViewController: UIViewController {
  12. var ooMeetingRoomInfo:OOMeetingRoomInfo!{
  13. didSet {
  14. viewModel.ooMeetingRoomInfo = ooMeetingRoomInfo
  15. }
  16. }
  17. @IBOutlet weak var tableView: UITableView!
  18. private lazy var viewModel:OOMeetingRoomDetailViewModel = {
  19. return OOMeetingRoomDetailViewModel()
  20. }()
  21. override func viewDidLoad() {
  22. super.viewDidLoad()
  23. self.title = viewModel.ooMeetingRoomInfo?.name
  24. tableView.register(UINib.init(nibName: "OOMeetingRoomMainCell", bundle: nil), forCellReuseIdentifier: roomIdentifier)
  25. tableView.register(UINib.init(nibName: "OOMeetingInforItemCell", bundle: nil), forCellReuseIdentifier: meetingIdentifier)
  26. tableView.delegate = self
  27. tableView.dataSource = self
  28. viewModel.callbackExecutor = {
  29. msg in
  30. self.tableView.reloadData()
  31. }
  32. }
  33. override func didReceiveMemoryWarning() {
  34. super.didReceiveMemoryWarning()
  35. // Dispose of any resources that can be recreated.
  36. }
  37. }
  38. extension OOMeetingRoomDetailViewController:UITableViewDataSource,UITableViewDelegate {
  39. func numberOfSections(in tableView: UITableView) -> Int {
  40. return viewModel.numberOfSections()
  41. }
  42. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  43. return viewModel.numberOfRowsInSection(section)
  44. }
  45. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  46. if indexPath.section == 0 {
  47. let cell = tableView.dequeueReusableCell(withIdentifier: roomIdentifier, for: indexPath)
  48. let uCell = cell as! OOMeetingRoomMainCell
  49. let item = viewModel.nodeForIndexPath(indexPath)
  50. uCell.config(withItem: item)
  51. return cell
  52. }else if(indexPath.section == 1){
  53. let cell = tableView.dequeueReusableCell(withIdentifier: meetingIdentifier, for: indexPath)
  54. let uCell = cell as! OOMeetingInforItemCell
  55. uCell.meetingroomLabel.text = ooMeetingRoomInfo.name
  56. let item = viewModel.nodeForIndexPath(indexPath)
  57. uCell.config(withItem: item)
  58. return cell
  59. }else{
  60. return UITableViewCell()
  61. }
  62. }
  63. }