根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
``` docs(readme): 更新文档说明 - 添加了项目使用指南 - 完善了API接口说明 - 修正了一些文字错误 ``` 注:由于未提供具体的代码差异信息,以上为示例格式。请提供具体的代码变更内容以便生成准确的commit message。
This commit is contained in:
@@ -129,7 +129,29 @@ struct IndicatorQuickSheet: View {
|
||||
selectedMonitor?.displayName ?? selectedCustom?.name
|
||||
}
|
||||
|
||||
/// 数值类指标(血压 / 长期监测 / 自定义)要求填合法数字且在合理范围;
|
||||
/// 化验 / 手动自由值允许非数字(如「阴性」「++」「未见异常」)。
|
||||
/// 返回 nil = 通过;否则为给用户看的一句话原因。脏数据会直接画进趋势图,这里挡在入口。
|
||||
private var numericValidationError: String? {
|
||||
func check(_ s: String, min: Double, max: Double, field: String) -> String? {
|
||||
let t = s.trimmingCharacters(in: .whitespaces)
|
||||
guard !t.isEmpty else { return nil } // 空值交给下面的非空判断兜底
|
||||
guard let v = Double(t), v.isFinite else { return String(appLoc: "\(field)请填数字") }
|
||||
guard v >= min, v <= max else { return String(appLoc: "\(field)数值超出合理范围") }
|
||||
return nil
|
||||
}
|
||||
if isBP {
|
||||
return check(systolic, min: 30, max: 350, field: String(appLoc: "收缩压"))
|
||||
?? check(diastolic, min: 20, max: 250, field: String(appLoc: "舒张压"))
|
||||
}
|
||||
if isLongTermMetric { // 长期监测预设 / 自定义:必须是正数
|
||||
return check(value, min: 0.0001, max: 1_000_000, field: String(appLoc: "数值"))
|
||||
}
|
||||
return nil // 自由输入(化验 / 手动)允许非数字
|
||||
}
|
||||
|
||||
private var canSubmit: Bool {
|
||||
guard numericValidationError == nil else { return false }
|
||||
if isBP {
|
||||
return !systolic.trimmingCharacters(in: .whitespaces).isEmpty &&
|
||||
!diastolic.trimmingCharacters(in: .whitespaces).isEmpty
|
||||
@@ -162,6 +184,9 @@ struct IndicatorQuickSheet: View {
|
||||
statusSection
|
||||
}
|
||||
}
|
||||
if let validationError = numericValidationError {
|
||||
validationHint(validationError)
|
||||
}
|
||||
|
||||
timeSection
|
||||
noteSection
|
||||
@@ -1152,6 +1177,21 @@ struct IndicatorQuickSheet: View {
|
||||
return (s.label, s.color)
|
||||
}
|
||||
|
||||
// MARK: - 校验提示
|
||||
|
||||
private func validationHint(_ text: String) -> some View {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "exclamationmark.circle.fill")
|
||||
.font(.tjScaled(11))
|
||||
.foregroundStyle(Tj.Palette.brick)
|
||||
Text(text)
|
||||
.font(.tjScaled(12))
|
||||
.foregroundStyle(Tj.Palette.brick)
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
.transition(.opacity)
|
||||
}
|
||||
|
||||
// MARK: - submit
|
||||
|
||||
private func submit() {
|
||||
|
||||
Reference in New Issue
Block a user