Files
kangkang/康康/Features/Me/MeView.swift
link2026 1b01923c8e feat(capture): 统一报告捕获流程并集成视觉语言模型识别
- 替换 QuickCaptureFlow 和 ArchiveFlow 为 UnifiedCaptureFlow 统一流程
- 新增 VLSession 封装 Qwen2.5-VL 模型进行图像文本推理
- 实现 AIRuntime 中 VL 模型的准备和分析功能
- 添加 VLPrompts 定义体检化验单识别的 JSON 输出模板
- 创建 CaptureReviewForm 提供 VL 解析结果的可编辑表单界面
- 集成 VisionKit 文档扫描器支持真机多页文档扫描
- 为模拟器实现 PhotosPicker 回退方案选择已有照片
- 在 RootView 中统一使用 UnifiedCaptureFlow 处理快速和归档流程
- 添加 CustomMetricEditor 支持自定义监测指标的创建编辑删除
- 扩展 KangkangApp 模型配置以支持新数据类型
- 实现档案列表中症状结束功能通过时间线行点击触发
2026-05-26 11:18:00 +08:00

205 lines
7.1 KiB
Swift

import SwiftUI
import SwiftData
struct MeView: View {
@Environment(\.modelContext) private var ctx
@Query private var profiles: [UserProfile]
@Query private var reminders: [MetricReminder]
@Query private var customMetrics: [CustomMonitorMetric]
private var profile: UserProfile? { profiles.first }
private var enabledReminderCount: Int { reminders.filter(\.enabled).count }
var body: some View {
NavigationStack {
ScrollView {
VStack(spacing: 12) {
profileCard
remindersCard
customMetricsCard
settingsCard(title: "模型管理",
detail: "未配置",
icon: "cpu")
settingsCard(title: "Face ID 启动锁",
detail: "关闭",
icon: "faceid")
settingsCard(title: "关于",
detail: "v0.1 · W2",
icon: "info.circle")
#if DEBUG
DebugAIRunner()
.padding(.top, 8)
#endif
}
.padding(.horizontal, 16)
.padding(.vertical, 20)
}
.background(Tj.Palette.sand.ignoresSafeArea())
.navigationTitle("我的")
.navigationBarTitleDisplayMode(.large)
.onAppear {
if profiles.isEmpty {
_ = UserProfileStore.loadOrCreate(in: ctx)
}
}
}
}
// MARK: - Cards
private var profileCard: some View {
NavigationLink {
ProfileEditView()
} label: {
HStack(spacing: 12) {
ZStack {
Circle()
.fill(Tj.Palette.amber.opacity(0.25))
Image(systemName: "person.crop.circle.fill")
.font(.system(size: 22))
.foregroundStyle(Tj.Palette.ink)
}
.frame(width: 44, height: 44)
VStack(alignment: .leading, spacing: 2) {
Text("个人资料")
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(Tj.Palette.text)
Text(profileLine)
.font(.system(size: 12))
.foregroundStyle(Tj.Palette.text3)
.lineLimit(1)
}
Spacer()
Image(systemName: "chevron.right")
.font(.system(size: 13, weight: .medium))
.foregroundStyle(Tj.Palette.text3)
}
.padding(14)
.tjCard()
}
.buttonStyle(.plain)
}
private var remindersCard: some View {
NavigationLink {
RemindersListView()
} label: {
HStack(spacing: 12) {
ZStack {
Circle()
.fill(enabledReminderCount > 0 ? Tj.Palette.amber.opacity(0.25) : Tj.Palette.sand2)
Image(systemName: "bell.fill")
.font(.system(size: 18))
.foregroundStyle(enabledReminderCount > 0 ? Tj.Palette.ink : Tj.Palette.text2)
}
.frame(width: 44, height: 44)
VStack(alignment: .leading, spacing: 2) {
Text("记录提醒")
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(Tj.Palette.text)
Text(reminderLine)
.font(.system(size: 12))
.foregroundStyle(Tj.Palette.text3)
.lineLimit(1)
}
Spacer()
Image(systemName: "chevron.right")
.font(.system(size: 13, weight: .medium))
.foregroundStyle(Tj.Palette.text3)
}
.padding(14)
.tjCard()
}
.buttonStyle(.plain)
}
private var reminderLine: String {
if reminders.isEmpty { return "尚未设置" }
if enabledReminderCount == 0 { return "全部已关闭(\(reminders.count) 条)" }
return "\(enabledReminderCount) 项启用"
}
private var customMetricsCard: some View {
NavigationLink {
CustomMetricsListView()
} label: {
HStack(spacing: 12) {
ZStack {
Circle()
.fill(customMetrics.isEmpty ? Tj.Palette.sand2 : Tj.Palette.leafSoft)
Image(systemName: "slider.horizontal.3")
.font(.system(size: 18))
.foregroundStyle(customMetrics.isEmpty ? Tj.Palette.text2 : Tj.Palette.ink)
}
.frame(width: 44, height: 44)
VStack(alignment: .leading, spacing: 2) {
Text("自定义指标")
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(Tj.Palette.text)
Text(customMetricsLine)
.font(.system(size: 12))
.foregroundStyle(Tj.Palette.text3)
.lineLimit(1)
}
Spacer()
Image(systemName: "chevron.right")
.font(.system(size: 13, weight: .medium))
.foregroundStyle(Tj.Palette.text3)
}
.padding(14)
.tjCard()
}
.buttonStyle(.plain)
}
private var customMetricsLine: String {
if customMetrics.isEmpty { return "添加你自己的长期监测项" }
return "\(customMetrics.count)"
}
private func settingsCard(title: String, detail: String, icon: String) -> some View {
HStack(spacing: 12) {
ZStack {
Circle().fill(Tj.Palette.sand2)
Image(systemName: icon)
.font(.system(size: 18))
.foregroundStyle(Tj.Palette.text2)
}
.frame(width: 44, height: 44)
Text(title)
.font(.system(size: 15, weight: .medium))
.foregroundStyle(Tj.Palette.text)
Spacer()
Text(detail)
.font(.system(size: 12))
.foregroundStyle(Tj.Palette.text3)
Image(systemName: "chevron.right")
.font(.system(size: 13, weight: .medium))
.foregroundStyle(Tj.Palette.text3)
}
.padding(14)
.tjCard()
}
private var profileLine: String {
guard let p = profile, p.hasAnyBasics else {
return "点这里完善你的资料"
}
return p.summaryLine
}
}
#Preview {
MeView()
.modelContainer(for: [
UserProfile.self, Indicator.self, Report.self, DiaryEntry.self,
Asset.self, ChatTurn.self, Symptom.self, MetricReminder.self,
CustomMonitorMetric.self,
], inMemory: true)
}