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.
101 lines
3.5 KiB
101 lines
3.5 KiB
![]()
2 years ago
|
//
|
||
|
// HealthSleeoHeartRateCell.swift
|
||
|
// Lookfit
|
||
|
//
|
||
|
// Created by lemo. on 2020/4/6.
|
||
|
// Copyright © 2020 Sheldon. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import UIKit
|
||
|
|
||
|
class HealthSleeoHeartRateCell: TableViewCell {
|
||
|
|
||
|
lazy var leftTitleLabel: UILabel = {
|
||
|
let label = UILabel()
|
||
|
label.textColor = kHexColor(0x2A2A2A)
|
||
|
label.font = SystemMediumFont(18)
|
||
|
label.text = MultiLanguageKey.sleep.localized
|
||
|
return label
|
||
|
}()
|
||
|
lazy var sleepBlockView: HealthBlockView = {
|
||
|
let view = HealthBlockView()
|
||
|
view.bgImgBtn.setBackgroundImage(R.image.sleep_bg(), for: .normal)
|
||
|
view.centerLabel.textColor = kHexColor(0x6D9CFF)
|
||
|
view.unitLabel.textColor = kHexColor(0x6D9CFF)
|
||
|
view.centerLabel.text = "0"
|
||
|
view.unitLabel.text = MultiLanguageKey.hour.localized
|
||
|
return view
|
||
|
}()
|
||
|
lazy var rightTitleLabel: UILabel = {
|
||
|
let label = UILabel()
|
||
|
label.textColor = kHexColor(0x2A2A2A)
|
||
|
label.font = SystemMediumFont(18)
|
||
|
label.text = MultiLanguageKey.heartRate.localized
|
||
|
return label
|
||
|
}()
|
||
|
lazy var hearRateBlockView: HealthBlockView = {
|
||
|
let view = HealthBlockView()
|
||
|
view.sleepCircleView.isHidden = true
|
||
|
view.bgImgBtn.setBackgroundImage(R.image.heartRate_bg(), for: .normal)
|
||
|
view.titleLabel.text = MultiLanguageKey.realHeartRate.localized
|
||
|
view.centerLabel.textColor = kHexColor(0xFF6D6D)
|
||
|
view.unitLabel.textColor = kHexColor(0xFF6D6D)
|
||
|
view.unitLabel.text = "bpm"
|
||
|
view.centerLabel.text = "--"
|
||
|
return view
|
||
|
}()
|
||
|
|
||
|
override func makeUI() {
|
||
|
super.makeUI()
|
||
|
selectionStyle = .none
|
||
|
contentView.addSubview(sleepBlockView)
|
||
|
contentView.addSubview(hearRateBlockView)
|
||
|
contentView.addSubview(rightTitleLabel)
|
||
|
contentView.addSubview(leftTitleLabel)
|
||
|
layoutUI()
|
||
|
}
|
||
|
|
||
|
func layoutUI() {
|
||
|
leftTitleLabel.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(kScaleWidth(20))
|
||
|
make.left.equalTo(sleepBlockView.snp.left).offset(12)
|
||
|
}
|
||
|
sleepBlockView.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)
|
||
|
}
|
||
|
rightTitleLabel.snp.makeConstraints { (make) in
|
||
|
make.left.equalTo(hearRateBlockView.snp.left).offset(12)
|
||
|
make.top.equalTo(kScaleWidth(20))
|
||
|
}
|
||
|
hearRateBlockView.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(rightTitleLabel.snp.bottom).offset(5)
|
||
|
make.bottom.equalToSuperview()
|
||
|
make.right.equalTo(-13)
|
||
|
make.width.equalTo(kScreenW / 2.0 - 13)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
override func bind(model: ViewModel) {
|
||
|
super.bind(model: model)
|
||
|
guard let viewModel = model as? SleepHeartCellViewModel else { return }
|
||
|
viewModel.sleepTarget
|
||
|
.bind(to: sleepBlockView.titleLabel.rx.text)
|
||
|
.disposed(by: cellDisposeBag)
|
||
|
viewModel.sleep
|
||
|
.bind(to: sleepBlockView.centerLabel.rx.text)
|
||
|
.disposed(by: cellDisposeBag)
|
||
|
viewModel.sleepProgress
|
||
|
.subscribe(onNext: { [weak self] (progress) in
|
||
|
self?.sleepBlockView.sleepCircleView.updateProcess(process: Float(progress))
|
||
|
})
|
||
|
.disposed(by: cellDisposeBag)
|
||
|
viewModel.heartRate
|
||
|
.bind(to: hearRateBlockView.centerLabel.rx.text)
|
||
|
.disposed(by: cellDisposeBag)
|
||
|
}
|
||
|
|
||
|
}
|