Blame view

HDFwear/Home/Cell/MotionCell.swift 1.66 KB
f2cf74c7   yangbin   1.0.20(4)
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
  //
  //  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 titleLabel: UILabel!
      var motion: MotionModel = MotionModel() {
          didSet {
              
              if motion.date == nil {
                  dateLabel.text = LocString("暂无数据")
                  imageView.image = UIImage(named: "home_motion_nodata")
                  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")
              }
          }
      }
      
  //    func getHeight() -> CGFloat {
  //        return train.count*
  //    }
  
      override func awakeFromNib() {
          super.awakeFromNib()
          titleLabel.text = LocString("运动记录")
          
          // Initialization code
      }
  
  }