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.
97 lines
4.2 KiB
97 lines
4.2 KiB
![]()
1 year ago
|
//
|
||
|
// HelathItemCell.swift
|
||
|
// FireBoltt
|
||
|
//
|
||
|
// Created by Sheldon on 2021/9/21.
|
||
|
// Copyright © 2021 Sheldon. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import UIKit
|
||
|
|
||
|
class HelathItemCell: CollectionViewCell {
|
||
|
|
||
|
lazy var fb_leftTitleLabel: UILabel = {
|
||
|
let label = UILabel()
|
||
|
label.textColor = kHexColor(0x2A2A2A)
|
||
|
label.font = SystemMediumFont(18)
|
||
|
return label
|
||
|
}()
|
||
|
lazy var fb_blockView: HealthBlockView = {
|
||
|
let view = HealthBlockView()
|
||
|
return view
|
||
|
}()
|
||
|
|
||
|
override func setUpUI() {
|
||
|
containerView.addSubview(fb_leftTitleLabel)
|
||
|
containerView.addSubview(fb_blockView)
|
||
|
// containerView.backgroundColor = kRandomColor()
|
||
|
}
|
||
|
|
||
|
override func layoutUI() {
|
||
|
fb_leftTitleLabel.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(kScaleWidth(20))
|
||
|
make.left.equalTo(fb_blockView.snp.left).offset(12)
|
||
|
}
|
||
|
fb_blockView.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(fb_leftTitleLabel.snp.bottom).offset(5)
|
||
|
make.bottom.equalToSuperview()
|
||
|
make.left.equalToSuperview()
|
||
|
make.width.equalToSuperview()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
override func bind(model: ViewModel) {
|
||
|
super.bind(model: model)
|
||
|
guard let viewModel = model as? HealthCellViewModels else { return }
|
||
|
fb_leftTitleLabel.text = viewModel.type.titleLocalized
|
||
|
fb_blockView.fb_sleepCircleView.isHidden = true
|
||
|
switch viewModel.type {
|
||
|
case .sleep:
|
||
|
fb_blockView.fb_sleepCircleView.isHidden = false
|
||
|
fb_blockView.fb_bgImgBtn.setBackgroundImage(R.image.sleep_bg_fb(), for: .normal)
|
||
|
fb_blockView.fb_centerLabel.textColor = kHexColor(0x6D9CFF)
|
||
|
fb_blockView.fb_unitLabel.textColor = kHexColor(0x6D9CFF)
|
||
|
fb_blockView.fb_centerLabel.text = "0"
|
||
|
fb_blockView.fb_unitLabel.text = MultiLanguageKey_FB.hourFB.localized
|
||
|
viewModel.target
|
||
|
.bind(to: fb_blockView.fb_titleLabel.rx.text)
|
||
|
.disposed(by: cellDisposeBag)
|
||
|
case .heartRate:
|
||
|
fb_blockView.fb_bgImgBtn.setBackgroundImage(R.image.fb_heartRate_bg(), for: .normal)
|
||
|
fb_blockView.fb_titleLabel.text = MultiLanguageKey_FB.realHeartRateFB.localized
|
||
|
fb_blockView.fb_centerLabel.textColor = kHexColor(0xFF6D6D)
|
||
|
fb_blockView.fb_unitLabel.textColor = kHexColor(0xFF6D6D)
|
||
|
fb_blockView.fb_unitLabel.text = "bpm"
|
||
|
fb_blockView.fb_centerLabel.text = "--"
|
||
|
case .temperature:
|
||
|
fb_blockView.fb_bgImgBtn.setBackgroundImage(R.image.fb_temperature_bg(), for: .normal)
|
||
|
fb_blockView.fb_centerLabel.textColor = kHexColor(0x27ABFF)
|
||
|
fb_blockView.fb_unitLabel.textColor = kHexColor(0x27ABFF)
|
||
|
fb_blockView.fb_unitLabel.text = MultiLanguageKey_FB.centigradeFB.localized
|
||
|
fb_blockView.fb_titleLabel.text = MultiLanguageKey_FB.realTimeTemperatureFB.localized
|
||
|
case .bloodPressure:
|
||
|
fb_blockView.fb_bgImgBtn.setBackgroundImage(R.image.fb_bloodPressure_bg(), for: .normal)
|
||
|
fb_blockView.fb_centerLabel.textColor = kHexColor(0x48C0CB)
|
||
|
fb_blockView.fb_unitLabel.textColor = kHexColor(0x48C0CB)
|
||
|
fb_blockView.fb_unitLabel.text = MultiLanguageKey_FB.bloodPressureUnitFB.localized
|
||
|
fb_blockView.fb_titleLabel.text = MultiLanguageKey_FB.realTimeBloodPressureFB.localized
|
||
|
case .bloodOxygen:
|
||
|
fb_blockView.fb_bgImgBtn.setBackgroundImage(R.image.fb_bloodOxygen_bg(), for: .normal)
|
||
|
fb_blockView.fb_centerLabel.textColor = kHexColor(0xF74D4E)
|
||
|
fb_blockView.fb_unitLabel.textColor = kHexColor(0xF74D4E)
|
||
|
fb_blockView.fb_unitLabel.text = MultiLanguageKey_FB.bloodOxygenUnitFB.localized
|
||
|
fb_blockView.fb_titleLabel.text = MultiLanguageKey_FB.realTimeBloodOxygenFB.localized
|
||
|
default: break
|
||
|
}
|
||
|
viewModel.value
|
||
|
.bind(to: fb_blockView.fb_centerLabel.rx.text)
|
||
|
.disposed(by: cellDisposeBag)
|
||
|
viewModel.progress
|
||
|
.subscribe(onNext: { [weak self] (progress) in
|
||
|
self?.fb_blockView.fb_sleepCircleView.updateProcess(process: Float(progress))
|
||
|
})
|
||
|
.disposed(by: cellDisposeBag)
|
||
|
}
|
||
|
|
||
|
}
|