| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 | 
							- //
 
- //  IHRoomVCtr.swift
 
- //  Inhealth
 
- //
 
- //  Created by weclouds on 2019/12/14.
 
- //  Copyright © 2019 weclouds. All rights reserved.
 
- //
 
- import UIKit
 
- import JXSegmentedView
 
- class IHRoomVCtr: UIViewController {
 
-     var hotelId :String?
 
-     var buildId :String?
 
-     var floorId:String?
 
-     var roomId :String?
 
-    var gatewayList : [GatewayData]?
 
-     
 
-     var totalItemWidth: CGFloat = 0 //总长度
 
-     var segmentedDataSource:JXSegmentedBaseDataSource?
 
-     var segmentedView = JXSegmentedView()
 
-     lazy var listContainerView: JXSegmentedListContainerView! = {
 
-         return JXSegmentedListContainerView(dataSource: self)
 
-     }()
 
-     override func viewDidLoad() {
 
-         super.viewDidLoad()
 
-        setNavigationBar()
 
-        cinfigSegmentdView()
 
-     }
 
-     
 
-  
 
-     func  cinfigSegmentdView()  {
 
-        // self.navigationBarTitle = "Room 1001"
 
-         totalItemWidth = UIScreen.main.bounds.size.width - 20*2
 
-         view.backgroundColor = .white
 
-         let titles = ["所有", "灯控","HCL灯控","感应器","空气净化器"]
 
-         let titleDataSource = JXSegmentedTitleDataSource()
 
-         titleDataSource.itemContentWidth = totalItemWidth/CGFloat(titles.count)
 
-         titleDataSource.titles = titles
 
-         titleDataSource.titleNormalFont = UIFont(name: Alibaba_PuHuiTi_Regular, size: 13)!
 
-         titleDataSource.titleSelectedFont = UIFont(name: Alibaba_PuHuiTi_Bold, size: 13)!
 
-         titleDataSource.isTitleMaskEnabled = true
 
-         titleDataSource.titleNormalColor = UIColor(hexString: "#657085")!
 
-         titleDataSource.titleSelectedColor = UIColor(hexString: "#FFFFFF")!
 
-         titleDataSource.itemSpacing = 0
 
-         titleDataSource.itemContentWidth = 120
 
-         //titleDataSource.isItemSpacingAverageEnabled = false
 
-         segmentedDataSource = titleDataSource
 
-         segmentedView.dataSource = segmentedDataSource
 
-         segmentedView.layer.masksToBounds = true
 
-         segmentedView.layer.cornerRadius = 15
 
-         segmentedView.backgroundColor = UIColor(hexString: "#F6F8F7")
 
-         segmentedView.delegate = self
 
-         view.addSubview(segmentedView)
 
-         let indicator = JXSegmentedIndicatorBackgroundView()
 
-         indicator.indicatorHeight = 25
 
-         indicator.backgroundWidthIncrement = -10
 
-         indicator.indicatorColor = UIColor(hexString: "#573F95")!
 
-         indicator.layer.shadowColor = UIColor(hexString: "#573F95")!.cgColor
 
-         indicator.layer.shadowRadius = 3
 
-         indicator.layer.shadowOffset = CGSize.zero
 
-         indicator.layer.shadowOpacity = 0.7
 
-         segmentedView.indicators = [indicator]
 
-         segmentedView.listContainer = listContainerView
 
-         view.addSubview(listContainerView)
 
-     }
 
-     override func viewWillAppear(_ animated: Bool) {
 
-         super.viewWillAppear(animated)
 
-         //处于第一个item的时候,才允许屏幕边缘手势返回
 
-         navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
 
-      
 
-     }
 
-     override func viewWillDisappear(_ animated: Bool) {
 
-         super.viewWillDisappear(animated)
 
-         //离开页面的时候,需要恢复屏幕边缘手势,不能影响其他页面
 
-         navigationController?.interactivePopGestureRecognizer?.isEnabled = true
 
-     }
 
-     override func viewDidLayoutSubviews() {
 
-          super.viewDidLayoutSubviews()
 
-          segmentedView.frame = CGRect(x: 20, y: 10, width: totalItemWidth, height: 30)
 
-          listContainerView.frame = CGRect(x: 0, y: 50, width: view.bounds.size.width, height: view.bounds.size.height - 50)
 
-     }
 
- }
 
- extension IHRoomVCtr{
 
-     func setNavigationBar()  {
 
-         //导航栏的渲染方式
 
-              let addItem = UIBarButtonItem(image: UIImage(named: "新增")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(addAction1))
 
-              let setItem = UIBarButtonItem(image: UIImage(named: "模式设置")?.withRenderingMode(.alwaysOriginal), style: .plain, target: self, action: #selector(mapAction1))
 
-             self.navigationItem.rightBarButtonItems = [setItem,addItem]
 
-     }
 
-     
 
-     @objc func addAction1(){
 
-          log.debug("点击了")
 
-    
 
-            let newEquipment = IHNewEquipmentVCtr()
 
-         newEquipment.floorId = self.floorId
 
-         newEquipment.roomId = self.roomId
 
-         newEquipment.roomStyle = .oldRoom
 
-         newEquipment.gatewayList = self.gatewayList
 
-         newEquipment.navigationBarTitle = "新增设备"
 
-          self.navigationController?.pushViewController(newEquipment, animated: true)
 
-      }
 
-     @objc func mapAction(){
 
-         log.debug("点击了")
 
-         let map = IHDashboardMapMainVCtr()
 
-         self.navigationController?.pushViewController(map, animated: true)
 
-     }
 
-     
 
-     @objc func mapAction1(){
 
-         log.debug("点击了")
 
-         let centralied = IHCentralizedVCtr()
 
-        // vc.floorList = self.floorList
 
-         centralied.isSetSencenModel = true
 
-         centralied.roomId = self.roomId
 
-         self.navigationController?.pushViewController(centralied, animated: true)
 
-     }
 
- }
 
- extension IHRoomVCtr:JXSegmentedViewDelegate{
 
-     func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
 
-         if let dotDataSource = segmentedDataSource as? JXSegmentedDotDataSource {
 
-             //先更新数据源的数据
 
-             dotDataSource.dotStates[index] = false
 
-             //再调用reloadItem(at: index)
 
-             segmentedView.reloadItem(at: index)
 
-         }
 
-   
 
-         log.debug("segmentedView - \(index)")
 
-         NotificationCenter.default.post(name: NSNotification.Name(kIHRoomListManagerNoticationSegmentViewSelectedIndex), object: index)
 
-         navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
 
-     }
 
- }
 
- extension IHRoomVCtr:JXSegmentedListContainerViewDataSource{
 
-     func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
 
-         if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
 
-             return titleDataSource.dataSource.count
 
-         }
 
-         return 0
 
-     }
 
-     
 
-     func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
 
-         let vc = IHRoomListVCtr()
 
-         vc.hotelId = self.hotelId
 
-         vc.buildId = self.buildId
 
-         vc.floorId = self.floorId
 
-         vc.roomId = self.roomId
 
-         vc.devType = index
 
-         return vc
 
-     }
 
-     
 
-     
 
- }
 
 
  |