IHCentralizedManager.swift 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // IHCentralizedManager.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2019/12/14.
  6. // Copyright © 2019 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHCentralizedManager: NSObject ,IHViewManagerProtocolDelegate{
  10. lazy var mainView: IHCentralizedView = {
  11. let mainView = Bundle.main.loadNibNamed("IHCentralizedView", owner: nil, options: nil)?.last as! IHCentralizedView
  12. mainView.delegate = self
  13. return mainView
  14. }()
  15. lazy var scenemodeView: IHSceneModeView = {
  16. let mainView = Bundle.main.loadNibNamed("IHSceneModeView", owner: nil, options: nil)?.last as! IHSceneModeView
  17. mainView.delegate = self
  18. return mainView
  19. }()
  20. // private var vc = UIViewController()
  21. private weak var vc : UIViewController?
  22. func bindController(_ vc: UIViewController) {
  23. self.vc = vc
  24. self.vc?.navigationBarTitle = "批量设置"
  25. createUI()
  26. let centralizedVC = self.vc as! IHCentralizedVCtr
  27. if centralizedVC.isSetSencenModel == true {
  28. mainView.removeFromSuperview()
  29. scenemodeView.roomId = centralizedVC.roomId
  30. createUI2()
  31. }else{
  32. scenemodeView.removeFromSuperview()
  33. mainView.floorList = centralizedVC.floorList
  34. createUI()
  35. }
  36. }
  37. func createUI2() {
  38. scenemodeView.frame = CGRect(x: 0, y: 0, width: KSCREENWIDTH, height: 812 - KNavBarHeight)
  39. let sc = UIScrollView(frame: self.vc!.view.bounds)
  40. sc.addSubview(mainView)
  41. sc.contentSize = CGSize(width: 0, height: 812)
  42. self.vc?.view.addSubview(sc)
  43. }
  44. func createUI() {
  45. mainView.frame = CGRect(x: 0, y: 0, width: KSCREENWIDTH, height: 812 - KNavBarHeight)
  46. let sc = UIScrollView(frame: self.vc!.view.bounds)
  47. sc.addSubview(mainView)
  48. sc.contentSize = CGSize(width: 0, height: 812)
  49. self.vc?.view.addSubview(sc)
  50. }
  51. }
  52. extension IHCentralizedManager : IHCentralizedViewDelegate ,IHSceneModeViewDelegate{
  53. func sceneModeViewSetting(roomId: String, light: String?, color: String?, colorR: String?, colorG: String?, colorB: String?, status: String?, level: String?) {
  54. if light != nil && color != nil && colorR != nil && colorG != nil && colorB != nil && status != nil && level != nil {
  55. IHCentrlizedService.share.setLampCmd(roomId, light: light!, color: color!, colorR: colorR!, colorG: colorG!, colorB: colorB!, status: status!, level: level!, requestSuccess: { (isSuccess) in
  56. }) {
  57. }
  58. }
  59. }
  60. func centralizeSetting(roomId: String, light: String, color: String, colorR: String, colorG: String, colorB: String, status: String, level: String) {
  61. IHCentrlizedService.share.setLampCmd(roomId, light: light, color: color, colorR: colorR, colorG: colorG, colorB: colorB, status: status, level: level, requestSuccess: { (isSuccess) in
  62. }) {
  63. }
  64. }
  65. }