MotionRecordCell.swift
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// MotionRecordCell.swift
// Twear
//
// Created by yangbin on 2021/12/16.
//
import UIKit
class MotionRecordCell: UITableViewCell {
@IBOutlet weak var motionImageView: UIImageView!
@IBOutlet weak var sourceImageView: UIImageView!
@IBOutlet weak var mileageLabel: UILabel!
@IBOutlet weak var calorieLabel: UILabel!
@IBOutlet weak var timeLabel: UILabel!
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var unitLabel: UILabel!
var user = UserInfo
var motion: MotionModel = MotionModel() {
didSet {
var imageName = "跑步"
switch motion.type {
case .walking:
imageName = "步行"
case .bicycle:
imageName = "骑行"
case .mountaineering:
imageName = "爬山"
default:
break
}
motionImageView.image = UIImage(named: imageName)
// timeLabel.text = "\(train.length)分钟"
mileageLabel.text = String(format:"%.2f",Float(motion.distance)/1000)
calorieLabel.text = String(format:"%.2f",Float(motion.calorie))
//+ LocString("千卡")
sourceImageView.image = UIImage(named: "phone")
dateLabel.text = motion.date!.toString(.custom("MM/dd"))
timeLabel.toTimeType3(length: motion.length)
if user.distanceUnit == 0 {
mileageLabel.text = String(format:"%.2f",Float(motion.distance)/1000)
unitLabel.text = LocString("公里")
} else {
mileageLabel.text = Float(Float(motion.distance)/1000).mileString()
unitLabel.text = LocString("英里")
}
// timeLabel.text = "\(String(format:"%02d",motion.length/3600)):\(String(format:"%02d",motion.length/60)):\(String(format:"%02d",motion.length%60))"
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}