IHAreaSeachManager.swift 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // IHAreaSeachManager.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2019/12/27.
  6. // Copyright © 2019 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHAreaSeachManager: NSObject ,IHViewManagerProtocolDelegate{
  10. lazy var mainView: IHAreaSeachView = {
  11. let mainView = IHAreaSeachView()
  12. mainView.viewDelegate = self
  13. return mainView
  14. }()
  15. // private var vc = UIViewController()
  16. private weak var vc : UIViewController?
  17. func bindController(_ vc: UIViewController) {
  18. self.vc = vc
  19. createUI()
  20. let searchVC = vc as! IHAreaSearchVCtr
  21. mainView.roomList = getAllRoomlist(from: searchVC.floorList)
  22. }
  23. func createUI() {
  24. mainView.frame = CGRect(x: 0, y: 0, width: KSCREENWIDTH, height: KSCREENHEIGHT )
  25. mainView.target = self.vc
  26. self.vc?.view.addSubview(mainView)
  27. self.vc?.navigationBarTitle = "搜索房间"
  28. }
  29. ///获取所有的房间列表
  30. func getAllRoomlist(from floorList:[RoomListData]?) -> [RoomData]? {
  31. log.debug("floorList -- \(floorList)")
  32. var roomList = [RoomData]()
  33. if floorList != nil && floorList!.count > 0 {
  34. if let floors = floorList {
  35. for room in floors {
  36. if let rooms = room.roomList {
  37. roomList += rooms // 拼接所有
  38. }
  39. }
  40. }
  41. }
  42. return roomList
  43. }
  44. }
  45. extension IHAreaSeachManager : IHAreaSearchViewDelegate{
  46. func searchViewDidSelectRowAt(indexPath: IndexPath) {
  47. let roomVC = IHRoomVCtr()
  48. let room = mainView.roomList?[indexPath.row]
  49. roomVC.navigationBarTitle = (room?.number ?? "") + "室"
  50. self.vc?.navigationController?.pushViewController(roomVC, animated: true)
  51. }
  52. }