MotionRecordCell.swift 1.71 KB
//
//  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!
    
    
    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.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
    }
    
}