From e101721593e3f63e3ccbf0d2e885c34c89cc2093 Mon Sep 17 00:00:00 2001 From: daifengyi Date: Sat, 20 May 2023 11:48:11 +0800 Subject: [PATCH] feat:home page UI --- HDFwear.xcodeproj/project.pbxproj | 10 ++++++++++ HDFwear/Assets.xcassets/Home/add_device.imageset/Contents.json | 22 ++++++++++++++++++++++ HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@2x.png | Bin 0 -> 3454 bytes HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@3x.png | Bin 0 -> 2621 bytes HDFwear/Basic/View/Base.lproj/StepCircleView.xib | 28 ++++++++++++++-------------- HDFwear/Basic/View/StepCircleView.swift | 2 +- HDFwear/Home/Base.lproj/Home.storyboard | 259 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------- HDFwear/Home/Cell/Base.lproj/BloodOxygenCell.xib | 46 ++++++++++++++++++++++------------------------ HDFwear/Home/Cell/Base.lproj/BloodPressureCell.xib | 44 ++++++++++++++++++++------------------------ HDFwear/Home/Cell/Base.lproj/HeartRateCell.xib | 48 ++++++++++++++++++++++-------------------------- HDFwear/Home/Cell/Base.lproj/MotionCell.xib | 39 ++++++++++++++++++++++----------------- HDFwear/Home/Cell/Base.lproj/SleepCell.xib | 39 ++++++++++++++++++++++----------------- HDFwear/Home/Cell/Base.lproj/TrainCell.xib | 44 ++++++++++++++++++++------------------------ HDFwear/Home/Cell/Base.lproj/WomenHealthCell.xib | 53 +++++++++++++++++++++++------------------------------ HDFwear/Home/Cell/BloodOxygenCell.swift | 15 ++++++++------- HDFwear/Home/Cell/BloodPressureCell.swift | 17 +++++++++-------- HDFwear/Home/Cell/HeartRateCell.swift | 16 ++++++++-------- HDFwear/Home/Cell/MotionCell.swift | 8 ++++++-- HDFwear/Home/Cell/SleepCell.swift | 10 ++++++---- HDFwear/Home/Cell/SortPageSectionHeader.h | 16 ++++++++++++++++ HDFwear/Home/Cell/SortPageSectionHeader.m | 20 ++++++++++++++++++++ HDFwear/Home/Cell/SortPageSectionHeader.xib | 28 ++++++++++++++++++++++++++++ HDFwear/Home/Cell/TrainCell.swift | 16 ++++++++-------- HDFwear/Home/Cell/WomenHealthCell.swift | 20 +++++++++++--------- HDFwear/Home/HomeViewController.swift | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------- 25 files changed, 482 insertions(+), 454 deletions(-) create mode 100644 HDFwear/Assets.xcassets/Home/add_device.imageset/Contents.json create mode 100644 HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@2x.png create mode 100644 HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@3x.png create mode 100644 HDFwear/Home/Cell/SortPageSectionHeader.h create mode 100644 HDFwear/Home/Cell/SortPageSectionHeader.m create mode 100644 HDFwear/Home/Cell/SortPageSectionHeader.xib diff --git a/HDFwear.xcodeproj/project.pbxproj b/HDFwear.xcodeproj/project.pbxproj index caf67b0..23080d0 100644 --- a/HDFwear.xcodeproj/project.pbxproj +++ b/HDFwear.xcodeproj/project.pbxproj @@ -284,6 +284,8 @@ 6CFEEBC42773355700621863 /* SleepReferenceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFEEBC32773355700621863 /* SleepReferenceVC.swift */; }; B212F1FD2A14CE0400781D59 /* LaunchSetting.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B212F1FF2A14CE0400781D59 /* LaunchSetting.storyboard */; }; B212F2052A14D28E00781D59 /* LaunchMyBodySettingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B212F2042A14D28E00781D59 /* LaunchMyBodySettingVC.swift */; }; + B23AA1012A1879D100BB3902 /* SortPageSectionHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = B23AA1002A1879D100BB3902 /* SortPageSectionHeader.m */; }; + B23AA1032A1879E200BB3902 /* SortPageSectionHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = B23AA1022A1879E200BB3902 /* SortPageSectionHeader.xib */; }; B2AF58822A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2AF58812A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift */; }; /* End PBXBuildFile section */ @@ -655,6 +657,9 @@ B212F2012A14CE0900781D59 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/LaunchSetting.strings"; sourceTree = ""; }; B212F2032A14CE0A00781D59 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/LaunchSetting.strings; sourceTree = ""; }; B212F2042A14D28E00781D59 /* LaunchMyBodySettingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchMyBodySettingVC.swift; sourceTree = ""; }; + B23AA0FF2A1879D100BB3902 /* SortPageSectionHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SortPageSectionHeader.h; sourceTree = ""; }; + B23AA1002A1879D100BB3902 /* SortPageSectionHeader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SortPageSectionHeader.m; sourceTree = ""; }; + B23AA1022A1879E200BB3902 /* SortPageSectionHeader.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SortPageSectionHeader.xib; sourceTree = ""; }; B2AF58812A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchMyInfoSettingVC.swift; sourceTree = ""; }; C621CFD20D2BD60CF4F959C3 /* Pods-HDFwear.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HDFwear.release.xcconfig"; path = "Target Support Files/Pods-HDFwear/Pods-HDFwear.release.xcconfig"; sourceTree = ""; }; E7F3880C37BC5F6DD15C709D /* Pods-HDFwear.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HDFwear.debug.xcconfig"; path = "Target Support Files/Pods-HDFwear/Pods-HDFwear.debug.xcconfig"; sourceTree = ""; }; @@ -1235,6 +1240,9 @@ 6C90AD10276B2E9500555FB8 /* MotionRecordCell.swift */, 6C28F531278FC68000E74EA5 /* MotionRecordCell.xib */, 6CCB7FF7276C6C06009EF617 /* RecordHeaderView.swift */, + B23AA0FF2A1879D100BB3902 /* SortPageSectionHeader.h */, + B23AA1002A1879D100BB3902 /* SortPageSectionHeader.m */, + B23AA1022A1879E200BB3902 /* SortPageSectionHeader.xib */, ); path = Cell; sourceTree = ""; @@ -1424,6 +1432,7 @@ 6CEA284727EB033E006A44AB /* MedalCell.xib in Resources */, 6C28F53E279017B200E74EA5 /* Mine.storyboard in Resources */, 6C2EA18A27CDBAFA0080FCA1 /* MettCell.xib in Resources */, + B23AA1032A1879E200BB3902 /* SortPageSectionHeader.xib in Resources */, 6C85FB74278D5CF2007D309A /* StepCircleView.xib in Resources */, 6C28F56127901D6800E74EA5 /* SleepReportCell.xib in Resources */, 6C5A978F27CCA03E00221361 /* PressureCell.xib in Resources */, @@ -1644,6 +1653,7 @@ 6C6F409027438FBE00F9473C /* Config.swift in Sources */, 6CB5416D27E0694C00BAEBD0 /* DialStyleCell.swift in Sources */, 6C6505C02798FB030043DB7A /* LTAdvancedManager.swift in Sources */, + B23AA1012A1879D100BB3902 /* SortPageSectionHeader.m in Sources */, 6CFEEBC02773353700621863 /* BOReferenceVC.swift in Sources */, 6CFEEBA42772BAB000621863 /* MBProgressHUD+Extension.swift in Sources */, 6CFEEBAE2772F18400621863 /* SettingCell2.swift in Sources */, diff --git a/HDFwear/Assets.xcassets/Home/add_device.imageset/Contents.json b/HDFwear/Assets.xcassets/Home/add_device.imageset/Contents.json new file mode 100644 index 0000000..c2032c6 --- /dev/null +++ b/HDFwear/Assets.xcassets/Home/add_device.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "add_device@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "add_device@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@2x.png b/HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@2x.png new file mode 100644 index 0000000..2c50ab7 Binary files /dev/null and b/HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@2x.png differ diff --git a/HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@3x.png b/HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@3x.png new file mode 100644 index 0000000..7ded329 Binary files /dev/null and b/HDFwear/Assets.xcassets/Home/add_device.imageset/add_device@3x.png differ diff --git a/HDFwear/Basic/View/Base.lproj/StepCircleView.xib b/HDFwear/Basic/View/Base.lproj/StepCircleView.xib index 575f4a2..6b09b00 100644 --- a/HDFwear/Basic/View/Base.lproj/StepCircleView.xib +++ b/HDFwear/Basic/View/Base.lproj/StepCircleView.xib @@ -1,9 +1,9 @@ - + - + @@ -22,21 +22,21 @@ @@ -44,9 +44,9 @@ - - - + + + diff --git a/HDFwear/Basic/View/StepCircleView.swift b/HDFwear/Basic/View/StepCircleView.swift index 606e47e..10c49c6 100644 --- a/HDFwear/Basic/View/StepCircleView.swift +++ b/HDFwear/Basic/View/StepCircleView.swift @@ -43,7 +43,7 @@ class StepCircleView: UIView { private func setupUI() { locLabel1.text = LocString("步数") - locLabel2.text = LocString("步") + locLabel2.text = LocString("") // 0.25 透明度的白色背景 bgLayer.fillColor = nil bgLayer.strokeColor = LineColor.cgColor diff --git a/HDFwear/Home/Base.lproj/Home.storyboard b/HDFwear/Home/Base.lproj/Home.storyboard index dde31b5..1cb5b38 100644 --- a/HDFwear/Home/Base.lproj/Home.storyboard +++ b/HDFwear/Home/Base.lproj/Home.storyboard @@ -21,173 +21,86 @@ - - + - - - - - + - - + + - - - - + + + - - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + @@ -262,6 +197,7 @@ + @@ -269,20 +205,16 @@ - - + - - - - + + + + - - - @@ -297,9 +229,9 @@ - + - + @@ -5158,18 +5090,15 @@ + - - - - @@ -5177,7 +5106,7 @@ - + @@ -5190,11 +5119,7 @@ - - - - diff --git a/HDFwear/Home/Cell/Base.lproj/BloodOxygenCell.xib b/HDFwear/Home/Cell/Base.lproj/BloodOxygenCell.xib index 125e8f3..bbf8d88 100644 --- a/HDFwear/Home/Cell/Base.lproj/BloodOxygenCell.xib +++ b/HDFwear/Home/Cell/Base.lproj/BloodOxygenCell.xib @@ -1,9 +1,9 @@ - + - + @@ -38,31 +38,28 @@ - - + - @@ -70,23 +67,23 @@ - - - + + - + + - + @@ -97,16 +94,17 @@ - + + - + diff --git a/HDFwear/Home/Cell/Base.lproj/BloodPressureCell.xib b/HDFwear/Home/Cell/Base.lproj/BloodPressureCell.xib index 2d6627c..c7076eb 100644 --- a/HDFwear/Home/Cell/Base.lproj/BloodPressureCell.xib +++ b/HDFwear/Home/Cell/Base.lproj/BloodPressureCell.xib @@ -1,9 +1,9 @@ - + - + @@ -37,31 +37,28 @@ - + - + @@ -69,8 +66,6 @@ - - @@ -78,16 +73,17 @@ + - - - + + + - + @@ -100,14 +96,14 @@ + - - + diff --git a/HDFwear/Home/Cell/Base.lproj/HeartRateCell.xib b/HDFwear/Home/Cell/Base.lproj/HeartRateCell.xib index 65b98ad..d36b1c3 100644 --- a/HDFwear/Home/Cell/Base.lproj/HeartRateCell.xib +++ b/HDFwear/Home/Cell/Base.lproj/HeartRateCell.xib @@ -1,9 +1,9 @@ - + - + @@ -38,31 +38,28 @@ - - + - - diff --git a/HDFwear/Home/Cell/Base.lproj/SleepCell.xib b/HDFwear/Home/Cell/Base.lproj/SleepCell.xib index be22608..f0836a8 100644 --- a/HDFwear/Home/Cell/Base.lproj/SleepCell.xib +++ b/HDFwear/Home/Cell/Base.lproj/SleepCell.xib @@ -1,9 +1,9 @@ - + - + @@ -38,7 +38,7 @@ diff --git a/HDFwear/Home/Cell/BloodOxygenCell.swift b/HDFwear/Home/Cell/BloodOxygenCell.swift index a95199b..de7487f 100644 --- a/HDFwear/Home/Cell/BloodOxygenCell.swift +++ b/HDFwear/Home/Cell/BloodOxygenCell.swift @@ -12,23 +12,23 @@ class BloodOxygenCell: UICollectionViewCell { @IBOutlet weak var boValueLabel: UILabel! @IBOutlet weak var dateLabel: UILabel! + @IBOutlet weak var noDataLabel: UILabel! @IBOutlet weak var noDataImageView: UIImageView! @IBOutlet weak var lineChartView: LineChartView! @IBOutlet weak var titleLabel: UILabel! - var boHistory: [BloodOxygenModel] = [] { didSet { let count = boHistory.count if count == 0 { - boValueLabel.text = "--" - dateLabel.text = LocString("暂无数据") - noDataImageView.isHidden = false + boValueLabel.text = "" + dateLabel.text = "" + noDataLabel.isHidden = false lineChartView.isHidden = true } else { - boValueLabel.text = "\(boHistory[count-1].value)" - dateLabel.text = boHistory[count-1].date!.toString(.custom("yyyy/MM/dd")) + boValueLabel.text = "\(boHistory[count-1].value)%" + dateLabel.text = boHistory[count-1].date!.toString(.custom("MM/dd")) updateChartView(boHistory) - noDataImageView.isHidden = true + noDataLabel.isHidden = true lineChartView.isHidden = false } } @@ -86,6 +86,7 @@ class BloodOxygenCell: UICollectionViewCell { override func awakeFromNib() { super.awakeFromNib() titleLabel.text = LocString("血氧") + noDataImageView.isHidden = true // Initialization code } diff --git a/HDFwear/Home/Cell/BloodPressureCell.swift b/HDFwear/Home/Cell/BloodPressureCell.swift index 4657021..c287ff5 100644 --- a/HDFwear/Home/Cell/BloodPressureCell.swift +++ b/HDFwear/Home/Cell/BloodPressureCell.swift @@ -12,24 +12,24 @@ class BloodPressureCell: UICollectionViewCell { @IBOutlet weak var bpValueLabel: UILabel! @IBOutlet weak var lineChartView: LineChartView! + @IBOutlet weak var noDataLabel: UILabel! @IBOutlet weak var noDataImageView: UIImageView! @IBOutlet weak var dateLabel: UILabel! - @IBOutlet weak var unitLabel: UILabel! @IBOutlet weak var titleLabel: UILabel! var bpHistory: [BloodPressureModel] = [] { didSet { let count = bpHistory.count if count == 0 { - bpValueLabel.text = "--/--" - dateLabel.text = LocString("暂无数据") - noDataImageView.isHidden = false + bpValueLabel.text = "" + dateLabel.text = "" + noDataLabel.isHidden = false lineChartView.isHidden = true } else { - bpValueLabel.text = "\(bpHistory[count-1].sbp)/\(bpHistory[count-1].dbp)" - dateLabel.text = bpHistory[count-1].date!.toString(.custom("yyyy/MM/dd")) + bpValueLabel.text = "\(bpHistory[count-1].sbp)/\(bpHistory[count-1].dbp)mmHg" + dateLabel.text = bpHistory[count-1].date!.toString(.custom("MM/dd")) updateChartView(bpHistory) - noDataImageView.isHidden = true + noDataLabel.isHidden = true lineChartView.isHidden = false } } @@ -91,7 +91,8 @@ class BloodPressureCell: UICollectionViewCell { override func awakeFromNib() { super.awakeFromNib() titleLabel.text = LocString("血压") - unitLabel.text = LocString("毫米汞柱") + noDataImageView.isHidden = true +// unitLabel.text = LocString("毫米汞柱") // Initialization code } diff --git a/HDFwear/Home/Cell/HeartRateCell.swift b/HDFwear/Home/Cell/HeartRateCell.swift index 33983ba..aff7eb1 100644 --- a/HDFwear/Home/Cell/HeartRateCell.swift +++ b/HDFwear/Home/Cell/HeartRateCell.swift @@ -12,24 +12,24 @@ class HeartRateCell: UICollectionViewCell { @IBOutlet weak var hrValueLabel: UILabel! @IBOutlet weak var dateLabel: UILabel! + @IBOutlet weak var noDataLabel: UILabel! @IBOutlet weak var noDataImageView: UIImageView! @IBOutlet weak var lineChartView: LineChartView! - @IBOutlet weak var unitLabel: UILabel! @IBOutlet weak var titleLabel: UILabel! var hrHistory: [HeartRateModel] = [] { didSet { let count = hrHistory.count if count == 0 { - hrValueLabel.text = "--" - dateLabel.text = LocString("暂无数据") - noDataImageView.isHidden = false + hrValueLabel.text = "" + dateLabel.text = "" + noDataLabel.isHidden = false lineChartView.isHidden = true } else { - hrValueLabel.text = "\(hrHistory[count-1].value)" - dateLabel.text = hrHistory[count-1].date!.toString(.custom("yyyy/MM/dd")) + hrValueLabel.text = "\(hrHistory[count-1].value)次/分" + dateLabel.text = hrHistory[count-1].date!.toString(.custom("MM/dd")) updateChartView(hrHistory) - noDataImageView.isHidden = true + noDataLabel.isHidden = true lineChartView.isHidden = false } } @@ -85,8 +85,8 @@ class HeartRateCell: UICollectionViewCell { override func awakeFromNib() { super.awakeFromNib() - unitLabel.text = LocString("次/分钟") titleLabel.text = LocString("心率") + noDataImageView.isHidden = true // lineChartView.isUserInteractionEnabled = false // Initialization code } diff --git a/HDFwear/Home/Cell/MotionCell.swift b/HDFwear/Home/Cell/MotionCell.swift index 59a98b8..7e0a899 100644 --- a/HDFwear/Home/Cell/MotionCell.swift +++ b/HDFwear/Home/Cell/MotionCell.swift @@ -12,14 +12,16 @@ 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 = LocString("暂无数据") + dateLabel.text = "" imageView.image = UIImage(named: "home_motion_nodata") + imageView.isHidden = true + noDataLabel.isHidden = false distnaceLabel.text = "" } else { if UserInfo.distanceUnit == 0 { @@ -31,6 +33,8 @@ class MotionCell: UICollectionViewCell { // 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 } } } diff --git a/HDFwear/Home/Cell/SleepCell.swift b/HDFwear/Home/Cell/SleepCell.swift index ad52a56..7cd0e1e 100644 --- a/HDFwear/Home/Cell/SleepCell.swift +++ b/HDFwear/Home/Cell/SleepCell.swift @@ -11,6 +11,7 @@ import Charts class SleepCell: UICollectionViewCell { @IBOutlet weak var lengthLabel: UILabel! @IBOutlet weak var dateLabel: UILabel! + @IBOutlet weak var noDataLabel: UILabel! @IBOutlet weak var noDataImageView: UIImageView! @IBOutlet weak var barChartView: BarChartView! @@ -19,14 +20,14 @@ class SleepCell: UICollectionViewCell { didSet { if sleep.startDate == nil { lengthLabel.text = " " - dateLabel.text = LocString("暂无数据") - noDataImageView.isHidden = false + dateLabel.text = "" + noDataLabel.isHidden = false barChartView.isHidden = true } else { lengthLabel.toTimeType1(length: sleep.sleepLength, BoldFont(25), LightFont(11)) - dateLabel.text = sleep.endDate!.toString(.custom("yyyy/MM/dd")) + dateLabel.text = sleep.endDate!.toString(.custom("MM/dd")) updateChartView(sleep) - noDataImageView.isHidden = true + noDataLabel.isHidden = true barChartView.isHidden = false } } @@ -88,6 +89,7 @@ class SleepCell: UICollectionViewCell { override func awakeFromNib() { super.awakeFromNib() titleLabel.text = LocString("睡眠") + noDataImageView.isHidden = true // lineChartView.isUserInteractionEnabled = false // Initialization code } diff --git a/HDFwear/Home/Cell/SortPageSectionHeader.h b/HDFwear/Home/Cell/SortPageSectionHeader.h new file mode 100644 index 0000000..60041ba --- /dev/null +++ b/HDFwear/Home/Cell/SortPageSectionHeader.h @@ -0,0 +1,16 @@ +// +// SortPageSectionHeader.h +// HDFwear +// +// Created by daifengyi on 2023/5/20. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SortPageSectionHeader : UITableViewHeaderFooterView + +@end + +NS_ASSUME_NONNULL_END diff --git a/HDFwear/Home/Cell/SortPageSectionHeader.m b/HDFwear/Home/Cell/SortPageSectionHeader.m new file mode 100644 index 0000000..b036490 --- /dev/null +++ b/HDFwear/Home/Cell/SortPageSectionHeader.m @@ -0,0 +1,20 @@ +// +// SortPageSectionHeader.m +// HDFwear +// +// Created by daifengyi on 2023/5/20. +// + +#import "SortPageSectionHeader.h" + +@implementation SortPageSectionHeader + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { + // Drawing code +} +*/ + +@end diff --git a/HDFwear/Home/Cell/SortPageSectionHeader.xib b/HDFwear/Home/Cell/SortPageSectionHeader.xib new file mode 100644 index 0000000..a1ebed0 --- /dev/null +++ b/HDFwear/Home/Cell/SortPageSectionHeader.xib @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HDFwear/Home/Cell/TrainCell.swift b/HDFwear/Home/Cell/TrainCell.swift index 0fcd59f..8a98c85 100644 --- a/HDFwear/Home/Cell/TrainCell.swift +++ b/HDFwear/Home/Cell/TrainCell.swift @@ -13,24 +13,24 @@ class TrainCell: UICollectionViewCell { @IBOutlet weak var lengthLabel: UILabel! @IBOutlet weak var dateLabel: UILabel! + @IBOutlet weak var noDataLabel: UILabel! @IBOutlet weak var noDataImageView: UIImageView! @IBOutlet weak var barChartView: BarChartView! - @IBOutlet weak var unitLabel: UILabel! @IBOutlet weak var titleLabel: UILabel! var trainHistory: [TrainModel] = [] { didSet { let count = trainHistory.count if count == 0 { - lengthLabel.text = "--" - dateLabel.text = LocString("暂无数据") - noDataImageView.isHidden = false + lengthLabel.text = "" + dateLabel.text = "" + noDataLabel.isHidden = false barChartView.isHidden = true } else { - lengthLabel.text = "\(trainHistory[count-1].length/60)" - dateLabel.text = trainHistory[count-1].date!.toString(.custom("yyyy/MM/dd")) + lengthLabel.text = "\(trainHistory[count-1].length/60)分钟" + dateLabel.text = trainHistory[count-1].date!.toString(.custom("MM/dd")) updateChartView(trainHistory) - noDataImageView.isHidden = true + noDataLabel.isHidden = true barChartView.isHidden = false } } @@ -86,7 +86,7 @@ class TrainCell: UICollectionViewCell { override func awakeFromNib() { super.awakeFromNib() titleLabel.text = LocString("训练") - unitLabel.text = LocString("分钟min") + noDataImageView.isHidden = true // Initialization code } diff --git a/HDFwear/Home/Cell/WomenHealthCell.swift b/HDFwear/Home/Cell/WomenHealthCell.swift index cb7738d..6adef37 100644 --- a/HDFwear/Home/Cell/WomenHealthCell.swift +++ b/HDFwear/Home/Cell/WomenHealthCell.swift @@ -13,31 +13,33 @@ class WomenHealthCell: UICollectionViewCell { @IBOutlet weak var imageView: UIImageView! @IBOutlet weak var dateLabel: UILabel! @IBOutlet weak var lastLabel: UILabel! - - @IBOutlet weak var locLabel: UILabel! + @IBOutlet weak var noDataLabel: UILabel! @IBOutlet weak var titleLabel: UILabel! - @IBOutlet weak var detailLabel: UILabel! var menstrual: MenstrualModel = MenstrualModel() { didSet { if menstrual.days == 0 { - dateLabel.text = LocString("暂无数据") + dateLabel.text = "" imageView.image = UIImage(named: "home_women_health_nodata") - detailLabel.isHidden = true + imageView.isHidden = true + noDataLabel.isHidden = false lastLabel.text = "" } else { if let model = MenstrualCalendarModel.getLastMenstrual() { - lastLabel.text = model.date!.toString(.custom("MM/dd")) + let interval = Date() .timeIntervalSince(model.date!) + let day = Int(interval / 24 / 60 / 60); +// lastLabel.text = model.date!.toString(.custom("MM/dd")) + lastLabel.text = "经期第\(day)天" } - dateLabel.text = DateInRegion().date.toString(.custom("yyyy/MM/dd")) + dateLabel.text = DateInRegion().date.toString(.custom("MM/dd")) imageView.image = UIImage(named: "home_women_health_bg") - detailLabel.isHidden = false + imageView.isHidden = false + noDataLabel.isHidden = true } } } override func awakeFromNib() { super.awakeFromNib() titleLabel.text = LocString("女性健康") - locLabel.text = LocString("最近一次月经") // Initialization code } diff --git a/HDFwear/Home/HomeViewController.swift b/HDFwear/Home/HomeViewController.swift index 6dc60cb..968b42f 100644 --- a/HDFwear/Home/HomeViewController.swift +++ b/HDFwear/Home/HomeViewController.swift @@ -19,24 +19,24 @@ import CoreLocation class HomeViewController: UIViewController, CLLocationManagerDelegate { + @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var collectionView: UICollectionView! @IBOutlet weak var collectViewHeight: NSLayoutConstraint! @IBOutlet weak var scrollView: UIScrollView! @IBOutlet weak var bindButton: UIButton! - @IBOutlet weak var bindLabel: UILabel! + @IBOutlet weak var bindLabel: UILabel? @IBOutlet weak var stepProgressView: StepCircleView! - @IBOutlet weak var stepsGoalLabel: UILabel! - @IBOutlet weak var stepDateLabel: UILabel! + @IBOutlet weak var stepsTimeLabel: UILabel! @IBOutlet weak var stepsDistanceLabel: UILabel! @IBOutlet weak var stepsCalorieLabel: UILabel! @IBOutlet weak var topView: UIView! - @IBOutlet weak var weatherImageView: UIImageView! - @IBOutlet weak var weatherDateLabel: UILabel! - @IBOutlet weak var weatherLabel: UILabel! - private var weatherArray: [WeatherModel] = [] +// @IBOutlet weak var weatherImageView: UIImageView! +// @IBOutlet weak var weatherDateLabel: UILabel! +// @IBOutlet weak var weatherLabel: UILabel! +// private var weatherArray: [WeatherModel] = [] var collectArray: [String] = CurDevice.homePage var scanView: ScanView? = nil @@ -101,7 +101,7 @@ class HomeViewController: UIViewController, CLLocationManagerDelegate { } SystemAuth.authLocation {[weak self] isAuth, isFirst in if isAuth || isFirst { - self?.updateWeatherView(true) +// self?.updateWeatherView(true) } } @@ -125,7 +125,7 @@ class HomeViewController: UIViewController, CLLocationManagerDelegate { @objc func clockDidChanged() { let date = DateInRegion().date - weatherDateLabel.text = date.toString(.custom("yyyy/MM/dd")) + " " + date.weekText +// weatherDateLabel.text = date.toString(.custom("yyyy/MM/dd")) + " " + date.weekText BluetoothManager.shared.setTime(format: TimeFormat(rawValue: UInt8(UserInfo.timeFormat))!, completion: nil) } @@ -148,12 +148,13 @@ class HomeViewController: UIViewController, CLLocationManagerDelegate { switch manager.authorizationStatus { case .notDetermined: if manager.authorizationStatus == .authorizedAlways || manager.authorizationStatus == .authorizedWhenInUse { - updateWeatherView(true) +// updateWeatherView(true) } else { } - case .authorizedAlways, .authorizedWhenInUse: - updateWeatherView(true) + break +// case .authorizedAlways, .authorizedWhenInUse: +// updateWeatherView(true) default: break } @@ -267,42 +268,42 @@ class HomeViewController: UIViewController, CLLocationManagerDelegate { weatherArray[1].date = nowDate + 1.days weatherArray[2].date = nowDate + 2.days AdminHelper.shared.savaWeather(weatherArray) - updateWeatherView() - } - } - - private func updateWeatherView(_ isQuery: Bool = false) { - let date = DateInRegion().date - weatherDateLabel.text = date.toString(.custom("yyyy/MM/dd")) + " " + date.weekText - let weatherArray = AdminHelper.shared.loadLocalWeatherData() - if weatherArray.count > 0, let weather = weatherArray.first { - if UserInfo.temperatureUnit == 0 { - weatherLabel.text = "\(LocString(weather.text)) \(weather.lowest)℃-\(weather.highest)℃" - } else { - weatherLabel.text = "\(LocString(weather.text)) \(Int(32+Float(weather.lowest)*1.8))℉-\(Int(32+Float(weather.highest)*1.8))℉" - } - weatherImageView.image = UIImage(named: weather.icon) - if isQuery { - if let lastDate = weather.date { - if (date - lastDate).in(.hour) ?? 9 >= 8 { - queryLocation() - } - } - } - } else { - queryLocation() - weatherLabel.text = LocString("无法获取当前天气") - } - } +// updateWeatherView() + } + } + +// private func updateWeatherView(_ isQuery: Bool = false) { +// let date = DateInRegion().date +// weatherDateLabel.text = date.toString(.custom("yyyy/MM/dd")) + " " + date.weekText +// let weatherArray = AdminHelper.shared.loadLocalWeatherData() +// if weatherArray.count > 0, let weather = weatherArray.first { +// if UserInfo.temperatureUnit == 0 { +// weatherLabel.text = "\(LocString(weather.text)) \(weather.lowest)℃-\(weather.highest)℃" +// } else { +// weatherLabel.text = "\(LocString(weather.text)) \(Int(32+Float(weather.lowest)*1.8))℉-\(Int(32+Float(weather.highest)*1.8))℉" +// } +// weatherImageView.image = UIImage(named: weather.icon) +// if isQuery { +// if let lastDate = weather.date { +// if (date - lastDate).in(.hour) ?? 9 >= 8 { +// queryLocation() +// } +// } +// } +// } else { +// queryLocation() +// weatherLabel.text = LocString("无法获取当前天气") +// } +// } private func updateConnectView(_ isConnected: Bool) { if CurDevice.uuid == "" { - bindButton.setImage(UIImage(named: "bind_device"), for: .normal) - bindLabel.text = LocString("添加设备") + bindButton.setImage(UIImage(named: "add_device"), for: .normal) +// bindLabel.text = LocString("添加设备") } else { bindButton.setImage(UIImage(named: "device_connected"), for: .normal) - bindLabel.text = isConnected ? LocString("已连接") : LocString("已断开") +// bindLabel.text = isConnected ? LocString("已连接") : LocString("已断开") } } @@ -310,24 +311,26 @@ class HomeViewController: UIViewController, CLLocationManagerDelegate { let step = StepModel.getRecentSteps() let goal = UserInfo.stepsGoal stepProgressView.stepLabel.text = "\(step.number)" - stepDateLabel.text = step.date?.toString(.custom("yyyy/MM/dd")) stepProgressView.value = min(step.number*100/goal, 100) + stepProgressView.locLabel2.text = "\(LocString("目标"))\(UserInfo.stepsGoal)\(LocString("步"))" // stepsGoalLabel.text = "/\(StepsGoal)步/\(String(format:"%.2f", step.calorie))千卡/\(String(format:"%.2f", step.distance))公里" - stepsGoalLabel.toUnitMode1(title: LocString("目标步数"), text: "\(goal)", unit: LocString("步"), font: RegularFont(13), unitFont: LightFont(11)) +// stepsGoalLabel.toUnitMode1(title: LocString("目标步数"), text: "\(goal)", unit: LocString("步"), font: RegularFont(13), unitFont: LightFont(11)) - stepsCalorieLabel.toUnitMode1(title: LocString("热量"), text: String(format:"%02d",Int(step.calorie)), unit: LocString("千卡"), font: RegularFont(13), unitFont: LightFont(11)) +// stepsCalorieLabel.toUnitMode1(title: LocString("热量"), text: String(format:"%02d",Int(step.calorie)), unit: LocString("千卡"), font: RegularFont(13), unitFont: LightFont(11)) + stepsCalorieLabel.text = "\(Int(step.calorie))" + stepsTimeLabel.text = "111"//jtd! + stepsDistanceLabel.text = "\(String(format:"%.2f", step.distance))" - if UserInfo.distanceUnit == 0 { - stepsDistanceLabel.toUnitMode1(title: LocString("距离"), text: "\(String(format:"%.2f", step.distance))", unit: LocString("公里"), font: RegularFont(13), unitFont: LightFont(11)) - } else { - stepsDistanceLabel.toUnitMode1(title: LocString("距离"), text: "\(step.distance.mileString())", unit: LocString("英里"), font: RegularFont(13), unitFont: LightFont(11)) - } +// if UserInfo.distanceUnit == 0 { +// stepsDistanceLabel.toUnitMode1(title: LocString("距离"), text: "\(String(format:"%.2f", step.distance))", unit: LocString("公里"), font: RegularFont(13), unitFont: LightFont(11)) +// } else { +// stepsDistanceLabel.toUnitMode1(title: LocString("距离"), text: "\(step.distance.mileString())", unit: LocString("英里"), font: RegularFont(13), unitFont: LightFont(11)) +// } if let index = collectArray.firstIndex(of: "MotionRecord") { collectionView.reloadItems(at: [IndexPath(row: index, section: 0)]) } - // print(stepDateLabel.font) } @@ -387,6 +390,11 @@ class HomeViewController: UIViewController, CLLocationManagerDelegate { } } + @IBAction func addDevice(_ sender: Any) { +// let shareView = ShareView(getShareImage()) + // shareView.shareImage = getShareImage() +// shareView.show() + } @IBAction func share(_ sender: Any) { let shareView = ShareView(getShareImage()) @@ -437,7 +445,7 @@ class HomeViewController: UIViewController, CLLocationManagerDelegate { func reconnect() { print("重连") - if bindLabel.text == LocString("连接中...") || bindLabel.text == LocString("已断开") { + if bindLabel?.text == LocString("连接中...") || bindLabel?.text == LocString("已断开") { BluetoothManager.shared.reConnect() BluetoothManager.shared.reconnectPer() } else { @@ -461,7 +469,7 @@ extension HomeViewController: BluetoothManagerDelegate { switch state { case 4: //power off if CurDevice.uuid != "" { - bindLabel.text = LocString("已断开") + bindLabel?.text = LocString("已断开") } case 5: //power on print("home power on ??") @@ -832,10 +840,10 @@ extension HomeViewController: XMLParserDelegate { if error == nil { MettModel.addArray(mettArray) } - self?.setWeatherData() +// self?.setWeatherData() } } else { - setWeatherData() +// setWeatherData() } } @@ -855,15 +863,15 @@ extension HomeViewController: XMLParserDelegate { } } - func setWeatherData() { - print("同步天气") - if weatherArray.count == 0 { - weatherArray = AdminHelper.shared.loadLocalWeatherData() - } - BluetoothManager.shared.setWeather(weatherArray) {[weak self] error in - self?.getSettingData() - } - } +// func setWeatherData() { +// print("同步天气") +// if weatherArray.count == 0 { +// weatherArray = AdminHelper.shared.loadLocalWeatherData() +// } +// BluetoothManager.shared.setWeather(weatherArray) {[weak self] error in +// self?.getSettingData() +// } +// } func queryFirmwareVersion() { -- libgit2 0.21.4