123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // IHAirView.swift
- // Inhealth
- //
- // Created by weclouds on 2019/12/18.
- // Copyright © 2019 weclouds. All rights reserved.
- //
- import UIKit
- protocol IHAirViewDelegate : NSObjectProtocol{
- func air_switchDataType(_ index: Int,purifierId:String)
-
- func air_adjustSwitch(_ purifierId: String, status: String, level: String)
-
- func air_ctrolGear(_ purifierId: String, level: String)
-
- }
- class IHAirView: UIView {
- weak var delegate : IHAirViewDelegate?
- var reportData: PurifierReportData?{
- didSet{
- self.tableView.reloadData()
-
- #warning("在Air purifiers的History Score点击选择时第一次选不上")
- // let indexP = IndexPath(row: 0, section: 0)
- // self.tableView.reloadRows(at: [indexP], with: .fade)
- }
- }
- var airData : PurifierInfodata?{
- didSet{
- self.tableView.reloadData()
- }
- }
-
- lazy var tableView: UITableView = {
- let tableView = UITableView(frame: CGRect.zero, style: .plain)
- tableView.delegate = self
- tableView.dataSource = self
- tableView.separatorStyle = .none
- tableView.register(UINib(nibName: "IHAirFirstCell", bundle: nil), forCellReuseIdentifier: "firstcell")
- tableView.register(UINib(nibName: "IHAirAdjustCell", bundle: nil), forCellReuseIdentifier: "aircell")
- return tableView
- }()
- override init(frame: CGRect) {
- super.init(frame: frame)
- backgroundColor = .white
-
- addSubview(tableView)
-
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- override func layoutSubviews() {
- super.layoutSubviews()
- tableView.frame = self.bounds
- }
- }
- extension IHAirView: UITableViewDelegate,UITableViewDataSource {
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return 2
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- if indexPath.row == 0 {
- let cell = tableView.dequeueReusableCell(withIdentifier: "firstcell") as! IHAirFirstCell
- cell.airData = self.airData
- cell.reportData = self.reportData
- cell.delegate = self
- cell.selectionStyle = .none
- return cell
- }else{
- let cell = tableView.dequeueReusableCell(withIdentifier: "aircell") as! IHAirAdjustCell
- cell.airData = self.airData
- cell.delegate = self
- cell.selectionStyle = .none
- return cell
- }
- }
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- if indexPath.row == 0 {
- //隐藏了一个view,减70
- return self.airData?.alarmStatus == "1" ? 420 : 420 - 60 - 70
- }else{
- return 650
- }
- }
-
- }
- extension IHAirView : IHAirFirstCellDelegate,IHAirAdjustCellDelegate{
- func ctrolGear(_ purifierId: String, level: String) {
- if let delegate = self.delegate {
- delegate.air_ctrolGear(purifierId, level: level)
- }
- }
-
- func cellSwitchDataType(_ index: Int,purifierId:String) {
- if let delegate = self.delegate {
- delegate.air_switchDataType(index, purifierId: purifierId)
- }
- }
-
- func adjustSwitch(_ purifierId: String, status: String, level: String) {
- if let delegate = self.delegate {
- delegate.air_adjustSwitch(purifierId, status: status, level: level)
- }
- }
-
-
- }
|