You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

65 lines
2.0 KiB

//
// TemperatureCell.swift
// FireBoltt
//
// Created by lemo. on 2020/9/4.
// Copyright © 2020 Sheldon. All rights reserved.
//
import UIKit
class TemperatureCellModel: ViewModel {
let temperature = BehaviorRelay<String>(value: "--")
}
class TemperatureCell: TableViewCell {
lazy var leftTitleLabel: UILabel = {
let label = UILabel()
label.textColor = kHexColor(0x2A2A2A)
label.font = SystemMediumFont(18)
label.text = MultiLanguageKey_FB.temperatureFB.localized
return label
}()
lazy var temperatureBlockView: HealthBlockView = {
let view = HealthBlockView()
view.fb_bgImgBtn.setBackgroundImage(R.image.fb_temperature_bg(), for: .normal)
view.fb_centerLabel.textColor = kHexColor(0x27ABFF)
view.fb_unitLabel.textColor = kHexColor(0x27ABFF)
view.fb_unitLabel.text = MultiLanguageKey_FB.centigradeFB.localized
view.fb_sleepCircleView.isHidden = true
view.fb_titleLabel.text = MultiLanguageKey_FB.realTimeTemperatureFB.localized
return view
}()
override func makeUI() {
super.makeUI()
selectionStyle = .none
contentView.addSubview(leftTitleLabel)
contentView.addSubview(temperatureBlockView)
layoutUI()
}
func layoutUI() {
leftTitleLabel.snp.makeConstraints { (make) in
make.top.equalTo(kScaleWidth(20))
make.left.equalTo(temperatureBlockView.snp.left).offset(12)
}
temperatureBlockView.snp.makeConstraints { (make) in
make.top.equalTo(leftTitleLabel.snp.bottom).offset(5)
make.bottom.equalToSuperview()
make.left.equalTo(13)
make.width.equalTo(kScreenW / 2.0 - 13)
}
}
override func bind(model: ViewModel) {
super.bind(model: model)
guard let viewModel = model as? TemperatureCellModel else { return }
viewModel.temperature.asDriver()
.drive(temperatureBlockView.fb_centerLabel.rx.text)
.disposed(by: cellDisposeBag)
}
}