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.
176 lines
6.3 KiB
176 lines
6.3 KiB
![]()
2 years ago
|
//
|
||
|
// HealthStepCell.swift
|
||
![]()
1 year ago
|
// FireBoltt
|
||
![]()
2 years ago
|
//
|
||
|
// Created by lemo. on 2020/4/6.
|
||
|
// Copyright © 2020 Sheldon. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import UIKit
|
||
|
|
||
|
class HealthStepCell: TableViewCell {
|
||
|
|
||
![]()
1 year ago
|
lazy var fb_titleLabel: UILabel = {
|
||
![]()
2 years ago
|
let label = UILabel()
|
||
|
label.textColor = kHexColor(0x2A2A2A)
|
||
|
label.font = SystemMediumFont(18)
|
||
![]()
1 year ago
|
label.text = MultiLanguageKey_FB.stepFB.localized
|
||
![]()
2 years ago
|
return label
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_dateLabel: UILabel = {
|
||
![]()
2 years ago
|
let label = UILabel()
|
||
|
label.textColor = kHexColor(0x888888)
|
||
|
label.font = SystemRegularFont(12)
|
||
|
label.text = DateClass.timestampToStr(Int(Date().timeIntervalSince1970), formatStr: "yyyy/MM/dd")
|
||
|
return label
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_bgView: UIView = {
|
||
![]()
2 years ago
|
let view = UIView()
|
||
![]()
2 years ago
|
view.gradient(colors: [kHexColor(0x499FFF), kHexColor(0x004EFF)], locations: nil, autoLaoutFrame: CGRect(x: 0, y: 0, width: kScaleWidth(335), height: kScaleWidth(160)))
|
||
![]()
2 years ago
|
view.layer.cornerRadius = 10
|
||
|
view.layer.masksToBounds = true
|
||
|
return view
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_stepCircleView: CircleView = {
|
||
![]()
2 years ago
|
let view = CircleView(lineWidth: 8, bottomColor: kHexColor(0xfffff, 0.3), progressColor: kHexColor(0xfffff), type: .doubleLine)
|
||
|
return view
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_stepValue: UILabel = {
|
||
![]()
2 years ago
|
let label = UILabel()
|
||
|
label.font = DigitalFont(32)
|
||
|
label.textColor = kHexColor(0xffffff)
|
||
|
label.text = "0"
|
||
|
return label
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_stepUnit: UILabel = {
|
||
![]()
2 years ago
|
let label = UILabel()
|
||
|
label.font = SystemRegularFont(12)
|
||
|
label.textColor = kHexColor(0xffffff)
|
||
![]()
1 year ago
|
label.text = MultiLanguageKey_FB.stepTipFB.localized
|
||
![]()
2 years ago
|
return label
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_dataCircleView: CircleView = {
|
||
![]()
2 years ago
|
let view = CircleView(lineWidth: 2, bottomColor: kHexColor(0xfffff, 0.3), type: .dottedLine)
|
||
|
return view
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_stepCaloriesValue: UILabel = {
|
||
![]()
2 years ago
|
let label = UILabel()
|
||
|
label.font = SystemMediumFont(21)
|
||
|
label.textColor = kHexColor(0xffffff)
|
||
|
label.text = "0"
|
||
|
return label
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_stepDistanceValue: UILabel = {
|
||
![]()
2 years ago
|
let label = UILabel()
|
||
|
label.font = SystemMediumFont(21)
|
||
|
label.textColor = kHexColor(0xffffff)
|
||
|
label.text = "0"
|
||
|
return label
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_stepCalories: UILabel = {
|
||
![]()
2 years ago
|
let label = UILabel()
|
||
|
label.font = SystemRegularFont(12)
|
||
|
label.textColor = kHexColor(0x8C4B05)
|
||
![]()
1 year ago
|
label.text = MultiLanguageKey_FB.kcalFB.localized
|
||
![]()
2 years ago
|
return label
|
||
|
}()
|
||
![]()
1 year ago
|
lazy var fb_stepDistance: UILabel = {
|
||
![]()
2 years ago
|
let label = UILabel()
|
||
|
label.font = SystemRegularFont(12)
|
||
|
label.textColor = kHexColor(0x8C4B05)
|
||
![]()
1 year ago
|
label.text = MultiLanguageKey_FB.kmFB.localized
|
||
![]()
2 years ago
|
return label
|
||
|
}()
|
||
|
|
||
|
override func makeUI() {
|
||
|
super.makeUI()
|
||
|
selectionStyle = .none
|
||
![]()
1 year ago
|
addSubview(fb_titleLabel)
|
||
|
addSubview(fb_dateLabel)
|
||
|
addSubview(fb_bgView)
|
||
|
fb_bgView.addSubview(fb_stepCircleView)
|
||
|
fb_bgView.addSubview(fb_dataCircleView)
|
||
|
fb_stepCircleView.addSubview(fb_stepValue)
|
||
|
fb_stepCircleView.addSubview(fb_stepUnit)
|
||
|
fb_dataCircleView.addSubview(fb_stepCaloriesValue)
|
||
|
fb_dataCircleView.addSubview(fb_stepDistanceValue)
|
||
|
fb_dataCircleView.addSubview(fb_stepCalories)
|
||
|
fb_dataCircleView.addSubview(fb_stepDistance)
|
||
![]()
2 years ago
|
layoutUI()
|
||
|
}
|
||
|
|
||
|
func layoutUI() {
|
||
![]()
1 year ago
|
fb_titleLabel.snp.makeConstraints { (make) in
|
||
![]()
2 years ago
|
make.top.equalTo(kScaleWidth(20))
|
||
|
make.left.equalTo(25)
|
||
|
}
|
||
![]()
1 year ago
|
fb_dateLabel.snp.makeConstraints { (make) in
|
||
|
make.bottom.equalTo(fb_titleLabel.snp.bottom)
|
||
![]()
2 years ago
|
make.right.equalTo(-25)
|
||
|
}
|
||
![]()
1 year ago
|
fb_bgView.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(fb_titleLabel.snp.bottom).offset(10)
|
||
![]()
2 years ago
|
make.left.equalTo(20)
|
||
|
make.right.equalTo(-20)
|
||
|
make.height.equalTo(kScaleWidth(160))
|
||
|
}
|
||
![]()
1 year ago
|
fb_stepCircleView.snp.makeConstraints { (make) in
|
||
![]()
2 years ago
|
make.centerY.equalToSuperview()
|
||
|
make.width.height.equalTo(kScaleWidth(130))
|
||
|
make.left.equalTo(kScaleWidth(28))
|
||
|
}
|
||
![]()
1 year ago
|
fb_stepValue.snp.makeConstraints { (make) in
|
||
![]()
2 years ago
|
make.top.equalTo(kScaleWidth(39))
|
||
|
make.centerX.equalToSuperview()
|
||
|
}
|
||
![]()
1 year ago
|
fb_stepUnit.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(fb_stepValue.snp.bottom)
|
||
![]()
2 years ago
|
make.centerX.equalToSuperview()
|
||
|
}
|
||
![]()
1 year ago
|
fb_dataCircleView.snp.makeConstraints { (make) in
|
||
![]()
2 years ago
|
make.centerY.equalToSuperview()
|
||
|
make.width.height.equalTo(kScaleWidth(130))
|
||
|
make.right.equalTo(-kScaleWidth(28))
|
||
|
}
|
||
![]()
1 year ago
|
fb_stepCaloriesValue.snp.makeConstraints { (make) in
|
||
![]()
2 years ago
|
make.top.equalTo(kScaleWidth(34))
|
||
|
make.centerX.equalToSuperview()
|
||
|
}
|
||
![]()
1 year ago
|
fb_stepDistanceValue.snp.makeConstraints { (make) in
|
||
|
make.top.equalTo(fb_stepCaloriesValue.snp.bottom).offset(kScaleWidth(4))
|
||
![]()
2 years ago
|
make.centerX.equalToSuperview()
|
||
|
}
|
||
![]()
1 year ago
|
fb_stepCalories.snp.makeConstraints { (make) in
|
||
|
make.lastBaseline.equalTo(fb_stepCaloriesValue.snp.lastBaseline)
|
||
|
make.left.equalTo(fb_stepCaloriesValue.snp.right).offset(5)
|
||
![]()
2 years ago
|
}
|
||
![]()
1 year ago
|
fb_stepDistance.snp.makeConstraints { (make) in
|
||
|
make.lastBaseline.equalTo(fb_stepDistanceValue.snp.lastBaseline)
|
||
|
make.left.equalTo(fb_stepDistanceValue.snp.right).offset(5)
|
||
![]()
2 years ago
|
}
|
||
|
}
|
||
|
|
||
|
override func bind(model: ViewModel) {
|
||
|
super.bind(model: model)
|
||
![]()
2 years ago
|
guard let viewModel = model as? StepCellViewModels else { return }
|
||
![]()
2 years ago
|
viewModel.step
|
||
![]()
1 year ago
|
.bind(to: fb_stepValue.rx.text)
|
||
![]()
2 years ago
|
.disposed(by: cellDisposeBag)
|
||
|
viewModel.calories
|
||
![]()
1 year ago
|
.bind(to: fb_stepCaloriesValue.rx.text)
|
||
![]()
2 years ago
|
.disposed(by: cellDisposeBag)
|
||
|
viewModel.distance
|
||
![]()
1 year ago
|
.bind(to: fb_stepDistanceValue.rx.text)
|
||
![]()
2 years ago
|
.disposed(by: cellDisposeBag)
|
||
|
viewModel.progress
|
||
|
.subscribe(onNext: { [weak self] (progress) in
|
||
![]()
1 year ago
|
self?.fb_stepCircleView.updateProcess(process: Float(progress))
|
||
![]()
2 years ago
|
})
|
||
|
.disposed(by: cellDisposeBag)
|
||
|
viewModel.dateStr
|
||
![]()
1 year ago
|
.bind(to: fb_dateLabel.rx.text)
|
||
![]()
2 years ago
|
.disposed(by: cellDisposeBag)
|
||
|
}
|
||
|
|
||
|
}
|