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
// Lookfit
//
// 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.temperature.localized
return label
}()
lazy var temperatureBlockView: HealthBlockView = {
let view = HealthBlockView()
view.bgImgBtn.setBackgroundImage(R.image.temperature_bg(), for: .normal)
view.centerLabel.textColor = kHexColor(0x27ABFF)
view.unitLabel.textColor = kHexColor(0x27ABFF)
view.unitLabel.text = MultiLanguageKey.centigrade.localized
view.sleepCircleView.isHidden = true
view.titleLabel.text = MultiLanguageKey.realTimeTemperature.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.centerLabel.rx.text)
.disposed(by: cellDisposeBag)
}
}