refactor(profile,monitor): move height/weight from MonitorMetric to UserProfile

身高/体重对成人变化慢,作为 Profile 静态字段比每次录入 Indicator 更合适。

- MonitorMetric:6 case(从 8 减),删 .height / .weight
- UserProfile:加 weightKG: Double?(支持小数),加 bmi computed
- summaryLine 加体重段:'175cm · 68.5kg'(整数省小数)
- ProfileEditView basics 加 weight 行 + footer 显示 BMI + 分类(偏瘦/正常/超重/肥胖)
- IndicatorQuickSheet:删 .height 回写 Profile 的特殊逻辑
- UserProfileTests:+5 个(weight 字段、summaryLine 含 weight、BMI 计算)

兼容性:老 Indicator 里的 seriesKey 'weight' / 'height' 数据保留(SwiftData String?
不变),只是新录入路径走 Profile 不走 Indicator;Trends 仍能用 String seriesKey
查询历史(如果将来要展示老数据)。

测试:60 case pass / 0 fail / 0 warning。
This commit is contained in:
link2026
2026-05-26 07:58:47 +08:00
parent 37b47b2076
commit 39edc25dc1
5 changed files with 83 additions and 31 deletions

View File

@@ -9,11 +9,11 @@ enum MonitorMetric: String, CaseIterable, Identifiable {
case bloodPressure // bp.systolic + bp.diastolic
case fastingGlucose // glucose.fasting
case postprandialGlucose // glucose.postprandial
case weight // weight
case temperature // temperature
case heartRate // heart_rate
case spo2 // spo2
case height // height( UserProfile.heightCM)
// : / UserProfile (,)
var id: String { rawValue }
@@ -22,11 +22,9 @@ enum MonitorMetric: String, CaseIterable, Identifiable {
case .bloodPressure: return "血压"
case .fastingGlucose: return "空腹血糖"
case .postprandialGlucose: return "餐后血糖"
case .weight: return "体重"
case .temperature: return "体温"
case .heartRate: return "心率"
case .spo2: return "血氧"
case .height: return "身高"
}
}
@@ -36,11 +34,9 @@ enum MonitorMetric: String, CaseIterable, Identifiable {
case .bloodPressure: return "heart.fill"
case .fastingGlucose: return "drop.fill"
case .postprandialGlucose: return "drop.circle.fill"
case .weight: return "scalemass.fill"
case .temperature: return "thermometer.medium"
case .heartRate: return "waveform.path.ecg"
case .spo2: return "lungs.fill"
case .height: return "ruler.fill"
}
}
@@ -71,12 +67,6 @@ enum MonitorMetric: String, CaseIterable, Identifiable {
unit: "mmol/L",
placeholder: "6.5",
baseRange: 0...7.8)]
case .weight:
return [Field(seriesKey: "weight",
label: "体重",
unit: "kg",
placeholder: "68",
baseRange: nil)]
case .temperature:
return [Field(seriesKey: "temperature",
label: "体温",
@@ -95,12 +85,6 @@ enum MonitorMetric: String, CaseIterable, Identifiable {
unit: "%",
placeholder: "98",
baseRange: 95...100)]
case .height:
return [Field(seriesKey: "height",
label: "身高",
unit: "cm",
placeholder: "175",
baseRange: nil)]
}
}
}