替换 Xcode 默认模板: - 删除 ContentView/Item/__App - 新增 App/TijiApp(SwiftData ModelContainer)、RootView(3 Tab + RecordSheet) - DesignSystem:Tokens(色板/字体/圆角)+ Components(卡片/按钮/Chip) - Models:Indicator / Report / DiaryEntry @Model 初版 - Features:Home / Quick(A1-A3)/ Archive(B1-B5)/ Record / Trends / Me 静态 UI W2 AI 基座工作将在此基线上叠加。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
156 lines
5.4 KiB
Swift
156 lines
5.4 KiB
Swift
import SwiftUI
|
||
|
||
struct HomeView: View {
|
||
var onTapArchive: () -> Void = {}
|
||
|
||
var body: some View {
|
||
ScrollView(showsIndicators: false) {
|
||
VStack(alignment: .leading, spacing: 0) {
|
||
greeting
|
||
.padding(.top, 4)
|
||
.padding(.bottom, 18)
|
||
|
||
todaySummaryCard
|
||
.padding(.bottom, 18)
|
||
|
||
recentSection
|
||
.padding(.bottom, 22)
|
||
|
||
archiveSection
|
||
}
|
||
.padding(.horizontal, 20)
|
||
.padding(.bottom, 20)
|
||
}
|
||
.background(Tj.Palette.sand.ignoresSafeArea())
|
||
}
|
||
|
||
private var greeting: some View {
|
||
HStack(alignment: .top) {
|
||
VStack(alignment: .leading, spacing: 4) {
|
||
Text("5 月 25 日 · 周一")
|
||
.font(.system(size: 12))
|
||
.tracking(1)
|
||
.foregroundStyle(Tj.Palette.text3)
|
||
Text("早安,林意")
|
||
.font(.tjTitle())
|
||
.foregroundStyle(Tj.Palette.text)
|
||
}
|
||
Spacer()
|
||
TjLockChip()
|
||
.padding(.top, 4)
|
||
}
|
||
}
|
||
|
||
private var todaySummaryCard: some View {
|
||
VStack(alignment: .leading, spacing: 0) {
|
||
HStack(spacing: 10) {
|
||
Text("今日 · 摘记")
|
||
.font(.system(size: 12, weight: .semibold))
|
||
.tracking(0.3)
|
||
.foregroundStyle(Tj.Palette.brick)
|
||
.fixedSize()
|
||
Rectangle()
|
||
.fill(Tj.Palette.line)
|
||
.frame(height: 1)
|
||
Text("本机摘要")
|
||
.font(.system(size: 11))
|
||
.foregroundStyle(Tj.Palette.text3)
|
||
.fixedSize()
|
||
}
|
||
.padding(.bottom, 10)
|
||
|
||
Text("上次体检后,\(Text("低密度脂蛋白").underline(color: Tj.Palette.brick).foregroundColor(Tj.Palette.text))持续偏高已 3 个月。建议本周记录一次空腹血脂。")
|
||
.font(.tjSerifBody())
|
||
.foregroundStyle(Tj.Palette.text)
|
||
.lineSpacing(6)
|
||
.padding(.bottom, 14)
|
||
|
||
HStack(spacing: 14) {
|
||
Button("记录今日") {}
|
||
.buttonStyle(TjPrimaryButton(height: 34, fontSize: 13, horizontalPadding: 14))
|
||
Button("查看趋势") {}
|
||
.buttonStyle(TjGhostButton(height: 34, fontSize: 13, horizontalPadding: 14))
|
||
}
|
||
}
|
||
.padding(.leading, 20)
|
||
.padding(.trailing, 18)
|
||
.padding(.vertical, 18)
|
||
.background(
|
||
Tj.Palette.paper
|
||
.overlay(alignment: .leading) {
|
||
Tj.Palette.brick.frame(width: 3)
|
||
}
|
||
)
|
||
.clipShape(RoundedRectangle(cornerRadius: 2, style: .continuous))
|
||
.shadow(color: Color(red: 0.196, green: 0.157, blue: 0.098).opacity(0.06), radius: 0, x: 0, y: 1)
|
||
}
|
||
|
||
private var recentSection: some View {
|
||
VStack(alignment: .leading, spacing: 10) {
|
||
HStack(alignment: .lastTextBaseline) {
|
||
Text("最近记录").font(.tjH2()).foregroundStyle(Tj.Palette.text)
|
||
Spacer()
|
||
Text("全部 ›")
|
||
.font(.system(size: 12))
|
||
.foregroundStyle(Tj.Palette.text3)
|
||
}
|
||
|
||
VStack(spacing: 10) {
|
||
RecentItemRow(
|
||
date: "昨天 18:20",
|
||
type: "异常项快拍",
|
||
name: "低密度脂蛋白 LDL-C",
|
||
value: "3.84 mmol/L",
|
||
status: .high
|
||
)
|
||
RecentItemRow(
|
||
date: "5 月 23 日",
|
||
type: "关键报告归档",
|
||
name: "春季年度体检 · 共 3 页",
|
||
value: "3 项偏高",
|
||
status: .archive
|
||
)
|
||
RecentItemRow(
|
||
date: "5 月 22 日",
|
||
type: "文字日记",
|
||
name: "头痛 · 上午 10 点起,午后缓解",
|
||
value: nil,
|
||
status: .diary
|
||
)
|
||
}
|
||
}
|
||
}
|
||
|
||
private var archiveSection: some View {
|
||
VStack(alignment: .leading, spacing: 10) {
|
||
Text("影像档案").font(.tjH2()).foregroundStyle(Tj.Palette.text)
|
||
|
||
Button(action: onTapArchive) {
|
||
HStack(spacing: 14) {
|
||
TjPlaceholder(label: "档案 · 12")
|
||
.frame(width: 56, height: 56)
|
||
VStack(alignment: .leading, spacing: 2) {
|
||
Text("我的报告档案")
|
||
.font(.system(size: 14, weight: .semibold))
|
||
.foregroundStyle(Tj.Palette.text)
|
||
Text("12 份 · 218 项指标 · 端侧加密")
|
||
.font(.system(size: 11))
|
||
.foregroundStyle(Tj.Palette.text3)
|
||
}
|
||
Spacer()
|
||
Image(systemName: "chevron.right")
|
||
.font(.system(size: 14, weight: .medium))
|
||
.foregroundStyle(Tj.Palette.text3)
|
||
}
|
||
.padding(14)
|
||
.tjCard(bordered: true)
|
||
}
|
||
.buttonStyle(.plain)
|
||
}
|
||
}
|
||
}
|
||
|
||
#Preview {
|
||
HomeView()
|
||
}
|