Files
kangkang/康康/Features/Quick/A3BatchView.swift
link2026 44ed01acf4 ```
refactor: 重命名项目名称从"体己"到"康康"

将整个项目的目录结构从"体己"重命名为"康康",包括所有源代码文件、
资源文件、测试文件以及Xcode项目配置文件。此更改涉及项目中所有的
文件路径和应用入口点(App/TijiApp.swift → App/KangkangApp.swift)。
```
2026-05-25 19:01:16 +08:00

125 lines
4.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import SwiftUI
struct A3BatchItem {
let name: String
let value: String
let unit: String
let range: String
let status: IndicatorStatus
}
struct A3BatchView: View {
var onAddMore: () -> Void
var onFinish: () -> Void
var onBack: () -> Void
let items: [A3BatchItem] = [
.init(name: "低密度脂蛋白胆固醇", value: "3.84", unit: "mmol/L", range: "< 3.40", status: .high),
.init(name: "甘油三酯 TG", value: "1.78", unit: "mmol/L", range: "< 1.70", status: .high),
.init(name: "空腹血糖 GLU", value: "5.4", unit: "mmol/L", range: "3.96.1", status: .normal),
]
var body: some View {
VStack(spacing: 0) {
header
ScrollView(showsIndicators: false) {
VStack(spacing: 10) {
ForEach(Array(items.enumerated()), id: \.offset) { idx, it in
BatchRow(index: idx + 1, item: it)
}
addRow
}
.padding(.horizontal, 16)
.padding(.bottom, 16)
}
HStack(spacing: 10) {
Button {
onFinish()
} label: {
Text("全部保存(\(items.count)").frame(maxWidth: .infinity)
}
.buttonStyle(TjPrimaryButton())
}
.padding(.horizontal, 16)
.padding(.bottom, 14)
}
.background(Tj.Palette.sand.ignoresSafeArea())
}
private var header: some View {
HStack(spacing: 6) {
Button(action: onBack) {
Image(systemName: "chevron.left")
.font(.system(size: 18, weight: .semibold))
.foregroundStyle(Tj.Palette.text)
.frame(width: 36, height: 36)
}
VStack(alignment: .leading, spacing: 2) {
Text("本次已记录 \(items.count)")
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(Tj.Palette.text)
Text("核对后一次保存")
.font(.system(size: 11))
.foregroundStyle(Tj.Palette.text3)
}
Spacer()
Text("· · ·")
.font(.system(size: 14, design: .monospaced))
.foregroundStyle(Tj.Palette.text3)
.padding(.trailing, 12)
}
.padding(.horizontal, 12)
.padding(.top, 4)
.padding(.bottom, 12)
}
private var addRow: some View {
Button(action: onAddMore) {
HStack(spacing: 8) {
Image(systemName: "camera").font(.system(size: 14))
Text("再拍一项")
.font(.system(size: 13))
}
.foregroundStyle(Tj.Palette.text3)
.frame(maxWidth: .infinity)
.padding(.vertical, 14)
.overlay(
RoundedRectangle(cornerRadius: Tj.Radius.md, style: .continuous)
.strokeBorder(Tj.Palette.line, style: StrokeStyle(lineWidth: 1.5, dash: [4, 4]))
)
}
.buttonStyle(.plain)
}
}
private struct BatchRow: View {
let index: Int
let item: A3BatchItem
var body: some View {
HStack(spacing: 12) {
TjPlaceholder(label: "#\(index)")
.frame(width: 60, height: 44)
VStack(alignment: .leading, spacing: 2) {
Text(item.name)
.font(.system(size: 13, weight: .semibold))
.foregroundStyle(Tj.Palette.text)
.lineLimit(1)
Text("范围 \(item.range) \(item.unit)")
.font(.system(size: 11))
.foregroundStyle(Tj.Palette.text3)
}
Spacer(minLength: 8)
VStack(alignment: .trailing, spacing: 2) {
Text(item.value)
.font(.system(size: 17, weight: .semibold))
.foregroundStyle(item.status == .high ? Tj.Palette.brick : Tj.Palette.text)
TjBadge(text: item.status == .high ? "偏高" : "正常",
style: item.status == .high ? .brick : .leaf)
}
}
.padding(12)
.tjCard()
}
}