diff --git a/HDFwear.xcodeproj/project.pbxproj b/HDFwear.xcodeproj/project.pbxproj index 23080d0..054668d 100644 --- a/HDFwear.xcodeproj/project.pbxproj +++ b/HDFwear.xcodeproj/project.pbxproj @@ -284,8 +284,10 @@ 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 */; }; + B23AA1052A18F22600BB3902 /* SortPageSectionHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B23AA1042A18F22600BB3902 /* SortPageSectionHeader.swift */; }; + B23AA1082A18F3F100BB3902 /* SortPageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B23AA1062A18F3F100BB3902 /* SortPageCell.swift */; }; + B23AA1092A18F3F100BB3902 /* SortPageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B23AA1072A18F3F100BB3902 /* SortPageCell.xib */; }; B2AF58822A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2AF58812A14C4BE0080B464 /* LaunchMyInfoSettingVC.swift */; }; /* End PBXBuildFile section */ @@ -657,9 +659,10 @@ 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 = ""; }; + B23AA1042A18F22600BB3902 /* SortPageSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SortPageSectionHeader.swift; sourceTree = ""; }; + B23AA1062A18F3F100BB3902 /* SortPageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SortPageCell.swift; sourceTree = ""; }; + B23AA1072A18F3F100BB3902 /* SortPageCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SortPageCell.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 = ""; }; @@ -1240,9 +1243,10 @@ 6C90AD10276B2E9500555FB8 /* MotionRecordCell.swift */, 6C28F531278FC68000E74EA5 /* MotionRecordCell.xib */, 6CCB7FF7276C6C06009EF617 /* RecordHeaderView.swift */, - B23AA0FF2A1879D100BB3902 /* SortPageSectionHeader.h */, - B23AA1002A1879D100BB3902 /* SortPageSectionHeader.m */, + B23AA1042A18F22600BB3902 /* SortPageSectionHeader.swift */, B23AA1022A1879E200BB3902 /* SortPageSectionHeader.xib */, + B23AA1062A18F3F100BB3902 /* SortPageCell.swift */, + B23AA1072A18F3F100BB3902 /* SortPageCell.xib */, ); path = Cell; sourceTree = ""; @@ -1435,6 +1439,7 @@ B23AA1032A1879E200BB3902 /* SortPageSectionHeader.xib in Resources */, 6C85FB74278D5CF2007D309A /* StepCircleView.xib in Resources */, 6C28F56127901D6800E74EA5 /* SleepReportCell.xib in Resources */, + B23AA1092A18F3F100BB3902 /* SortPageCell.xib in Resources */, 6C5A978F27CCA03E00221361 /* PressureCell.xib in Resources */, 6C0AE81B279149770064D377 /* ShareView.xib in Resources */, 6C6505D12799154A0043DB7A /* AddPictureCell.xib in Resources */, @@ -1531,6 +1536,7 @@ files = ( 6C80540F27699D950083B295 /* UILabel+Extension.swift in Sources */, 6C5B545A277569BE007F7901 /* UIView+Extension.swift in Sources */, + B23AA1052A18F22600BB3902 /* SortPageSectionHeader.swift in Sources */, 6CA862422747710100139069 /* StepViewController.swift in Sources */, 6C8F74E72779B8C700B8A1A7 /* SettingCell5.swift in Sources */, 6C2081F0277F00A600F6D4B9 /* HomePageSortVC.swift in Sources */, @@ -1653,7 +1659,6 @@ 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 */, @@ -1667,6 +1672,7 @@ 6C6F40752743828700F9473C /* BloodPressureCell.swift in Sources */, 6C5A978E27CCA03E00221361 /* PressureCell.swift in Sources */, 6C6505C42798FB030043DB7A /* LTVCExtension.swift in Sources */, + B23AA1082A18F3F100BB3902 /* SortPageCell.swift in Sources */, 6C5B545827756865007F7901 /* DatePickerView.swift in Sources */, 6C5120802797C22F006F8B64 /* CardDetailVC.swift in Sources */, 6C1B7EA427B7976600DB9D1C /* NFCDetailVC.swift in Sources */, diff --git a/HDFwear/Home/Base.lproj/Home.storyboard b/HDFwear/Home/Base.lproj/Home.storyboard index 1cb5b38..8f3f6f6 100644 --- a/HDFwear/Home/Base.lproj/Home.storyboard +++ b/HDFwear/Home/Base.lproj/Home.storyboard @@ -231,7 +231,7 @@ - + @@ -239,7 +239,7 @@ - + diff --git a/HDFwear/Home/Cell/SortPageCell.swift b/HDFwear/Home/Cell/SortPageCell.swift new file mode 100644 index 0000000..bf1727f --- /dev/null +++ b/HDFwear/Home/Cell/SortPageCell.swift @@ -0,0 +1,25 @@ +// +// SortPageCell.swift +// HDFwear +// +// Created by daifengyi on 2023/5/20. +// + +import UIKit + +class SortPageCell: UITableViewCell { + @IBOutlet weak var iconVIew: UIImageView! + @IBOutlet weak var nameLabel: UILabel! + + 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 + } + +} diff --git a/HDFwear/Home/Cell/SortPageCell.xib b/HDFwear/Home/Cell/SortPageCell.xib new file mode 100644 index 0000000..873dcfb --- /dev/null +++ b/HDFwear/Home/Cell/SortPageCell.xib @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HDFwear/Home/Cell/SortPageSectionHeader.h b/HDFwear/Home/Cell/SortPageSectionHeader.h deleted file mode 100644 index 60041ba..0000000 --- a/HDFwear/Home/Cell/SortPageSectionHeader.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// 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.swift index b036490..60d7bab 100644 --- a/HDFwear/Home/Cell/SortPageSectionHeader.m +++ b/HDFwear/Home/Cell/SortPageSectionHeader.swift @@ -1,20 +1,22 @@ // -// SortPageSectionHeader.m +// SortPageSectionHeader.swift // HDFwear // // Created by daifengyi on 2023/5/20. // -#import "SortPageSectionHeader.h" +import UIKit -@implementation SortPageSectionHeader +class SortPageSectionHeader: UITableViewHeaderFooterView { + @IBOutlet weak var topLabelTopConstraint: NSLayoutConstraint! + @IBOutlet weak var topLabel: UILabel! + @IBOutlet weak var bottomLabel: UILabel! + /* + // Only override draw() if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + override func draw(_ rect: CGRect) { + // Drawing code + } + */ -/* -// 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 index a1ebed0..231c321 100644 --- a/HDFwear/Home/Cell/SortPageSectionHeader.xib +++ b/HDFwear/Home/Cell/SortPageSectionHeader.xib @@ -11,13 +11,38 @@ - - + + + + + + + + + + + + - + + + + + + diff --git a/HDFwear/Home/HomePageSortVC.swift b/HDFwear/Home/HomePageSortVC.swift index 06eb21f..36790cc 100644 --- a/HDFwear/Home/HomePageSortVC.swift +++ b/HDFwear/Home/HomePageSortVC.swift @@ -18,6 +18,7 @@ class HomePageSortVC: UIViewController, UITableViewDelegate, UITableViewDataSour var ary2 = [String]() let dic: [String: String] = ["BloodPressure": "血压", "BloodOxygen": "血氧", "HeartRate": "心率", "Sleep": "睡眠", "Train": "训练", "WomenHealth": "女性健康", "MotionRecord": "运动记录", "Pressure": "压力", "Mett": "梅脱"] + let iconDic: [String: String] = ["BloodPressure": "home_bp", "BloodOxygen": "home_bo", "HeartRate": "home_hr", "Sleep": "home_sleep", "Train": "home_train", "WomenHealth": "home_women_health", "MotionRecord": "home_motion"] lazy var footerView: UIView = { let view = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 200)) @@ -46,10 +47,13 @@ class HomePageSortVC: UIViewController, UITableViewDelegate, UITableViewDataSour title = LocString("编辑健康功能") tableView.setEditing(true, animated: false) tableView.contentInset = UIEdgeInsets.init(top: 5, left: 0, bottom: 0, right: 0) + tableView.separatorStyle = .none + tableView.register(UINib(nibName: "SortPageSectionHeader", bundle: .main), forHeaderFooterViewReuseIdentifier: "SortPageSectionHeader") + tableView.register(UINib(nibName: "SortPageCell", bundle: .main), forCellReuseIdentifier: "SortPageCell") ary2 = device.allFunctions testDate() - tableView.tableFooterView = footerView +// tableView.tableFooterView = footerView for a in ary1 { if let i = ary2.firstIndex(of: a) { @@ -81,17 +85,29 @@ class HomePageSortVC: UIViewController, UITableViewDelegate, UITableViewDataSour } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - var cell = tableView.dequeueReusableCell(withIdentifier: "SortCellId") - if cell == nil { - cell = UITableViewCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: "SortCellId") - } - cell?.textLabel?.font = RegularFont(15) + let cell = tableView.dequeueReusableCell(withIdentifier: "SortPageCell", for: indexPath) as! SortPageCell if indexPath.section == 1 { - cell?.textLabel?.text = LocString(dic[ary2[indexPath.row]]!) + cell.iconVIew.image = UIImage(named: iconDic[ary2[indexPath.row]]!) + cell.nameLabel.text = LocString(dic[ary2[indexPath.row]]!) } else { - cell?.textLabel?.text = LocString(dic[ary1[indexPath.row]]!) + cell.iconVIew.image = UIImage(named: iconDic[ary1[indexPath.row]]!) + cell.nameLabel.text = LocString(dic[ary1[indexPath.row]]!) + } + return cell + } + + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SortPageSectionHeader") as! SortPageSectionHeader + if section == 0 { + header.topLabelTopConstraint.constant = 8 + header.topLabel.text = LocString("显示在首页") + header.bottomLabel.text = LocString("长按并拖拽可调整排序") + }else { + header.topLabelTopConstraint.constant = 15 + header.topLabel.text = LocString("不显示在首页") + header.bottomLabel.text = "" } - return cell! + return header } func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { @@ -136,13 +152,13 @@ class HomePageSortVC: UIViewController, UITableViewDelegate, UITableViewDataSour func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - return 50 + return 72 } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { - return 35 + return 0 } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - return 0.5 + return 57 } // func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { // if section == 1 {