// // MotionCell.swift // Twear // // Created by yangbin on 2021/11/16. // import UIKit class MotionCell: UICollectionViewCell { @IBOutlet weak var imageView: UIImageView! @IBOutlet weak var dateLabel: UILabel! @IBOutlet weak var distnaceLabel: UILabel! @IBOutlet weak var noDataLabel: UILabel! @IBOutlet weak var titleLabel: UILabel! var motion: MotionModel = MotionModel() { didSet { if motion.date == nil { dateLabel.text = "" imageView.image = UIImage(named: "home_motion_nodata") imageView.isHidden = true noDataLabel.isHidden = false distnaceLabel.text = "" } else { if UserInfo.distanceUnit == 0 { distnaceLabel.toUnitMode(text: String(format:"%.2f",Float(motion.distance)/1000), unit: " \(LocString("公里"))", font: BoldFont(25), unitFont: RegularFont(11), unitColor: UIColor.rgbColorFromHex(0x808080)) } else { distnaceLabel.toUnitMode(text: (Float(motion.distance)/1000).mileString(), unit: " \(LocString("英里"))", font: BoldFont(25), unitFont: RegularFont(11), unitColor: UIColor.rgbColorFromHex(0x808080)) } // distnaceLabel.text = String(format:"%.2f",Float(motion.distance)/1000) + "公里" dateLabel.text = motion.date!.toString(.custom("yyyy/MM/dd")) imageView.image = UIImage(named: "home_motion_bg") imageView.isHidden = false noDataLabel.isHidden = true } } } // func getHeight() -> CGFloat { // return train.count* // } override func awakeFromNib() { super.awakeFromNib() titleLabel.text = LocString("运动记录") // Initialization code } }