主体:多语言支持(简体中文源 + 英/日/韩)
- 基础设施:Localizable.xcstrings(String Catalog,sourceLanguage=zh-Hans)
+ pbxproj developmentRegion/knownRegions 注册 en/ja/ko
- 全部硬编码 Locale("zh_CN") → Locale.current;中文 dateFormat → Date.FormatStyle(跟随系统)
- UI 中文字面量统一为 String(appLoc:)(显式绑定所选语言 bundle+locale,即时切换)
Text 字面量走环境 \.locale + Bundle 重定向
- 549 个 catalog key 全部 en/ja/ko 翻译完成(0 未翻译)
- App 内语言切换:我的 → 语言(LanguageManager + 即时生效,无需重启)
- 双用预设(症状/监测指标/慢病)本地化:static→computed 避免缓存
注:本提交为 WIP,一并打包了并行进行的功能模块
(HealthExport 健康导出、Security/Face ID 锁、DiaryAssist 日记 AI 辅助)
及 App 图标、CLAUDE.md、docs/scripts。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
149 lines
5.7 KiB
Swift
149 lines
5.7 KiB
Swift
import SwiftUI
|
|
|
|
enum RecordKind: String, Identifiable, CaseIterable {
|
|
case quick, indicator, archive, diary, symptom, reminder
|
|
var id: String { rawValue }
|
|
|
|
/// RecordSheet 列表的展示顺序(从上到下)。与 enum 声明序解耦,改顺序只动这里。
|
|
static let displayOrder: [RecordKind] = [.diary, .reminder, .symptom, .indicator, .quick, .archive]
|
|
|
|
var title: String {
|
|
switch self {
|
|
case .quick: return String(appLoc: "异常项快拍")
|
|
case .indicator: return String(appLoc: "记录指标")
|
|
case .archive: return String(appLoc: "体检报告归档")
|
|
case .diary: return String(appLoc: "健康日记")
|
|
case .symptom: return String(appLoc: "记录症状")
|
|
case .reminder: return String(appLoc: "开启一个提醒")
|
|
}
|
|
}
|
|
var subtitle: String {
|
|
switch self {
|
|
case .quick: return String(appLoc: "拍一张化验单,VL 自动识别")
|
|
case .indicator: return String(appLoc: "手动填一项指标(免拍照)")
|
|
case .archive: return String(appLoc: "完整保存整份报告(可多页)")
|
|
case .diary: return String(appLoc: "记录身体状态、用药、感受 · 可让 AI 辅助")
|
|
case .symptom: return String(appLoc: "开始一个持续症状,结束时再点结束")
|
|
case .reminder: return String(appLoc: "管理用药、复查、监测的周期提醒")
|
|
}
|
|
}
|
|
var icon: String {
|
|
switch self {
|
|
case .quick: return "camera.fill"
|
|
case .indicator: return "number.square.fill"
|
|
case .archive: return "doc.fill"
|
|
case .diary: return "heart.text.square"
|
|
case .symptom: return "waveform.path.ecg"
|
|
case .reminder: return "bell.badge"
|
|
}
|
|
}
|
|
var accent: Color {
|
|
switch self {
|
|
case .quick: return Tj.Palette.brick
|
|
case .indicator: return Tj.Palette.brick
|
|
case .archive: return Tj.Palette.ink
|
|
case .diary: return Tj.Palette.leaf
|
|
case .symptom: return Tj.Palette.amber
|
|
case .reminder: return Tj.Palette.leaf
|
|
}
|
|
}
|
|
}
|
|
|
|
struct RecordSheet: View {
|
|
var onPick: (RecordKind) -> Void
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
Capsule()
|
|
.fill(Tj.Palette.line)
|
|
.frame(width: 40, height: 4)
|
|
.padding(.top, 10)
|
|
.padding(.bottom, 16)
|
|
|
|
HStack {
|
|
Text("记录什么?")
|
|
.font(.tjH2())
|
|
.foregroundStyle(Tj.Palette.text)
|
|
Spacer()
|
|
Text("本地处理 · 永不上传")
|
|
.font(.system(size: 12))
|
|
.foregroundStyle(Tj.Palette.text3)
|
|
}
|
|
.padding(.bottom, 14)
|
|
|
|
// ScrollView 包裹:6 个入口在小屏固定 detent 下可能溢出,滚动确保都能触达。
|
|
ScrollView {
|
|
VStack(spacing: 10) {
|
|
ForEach(RecordKind.displayOrder) { kind in
|
|
Button {
|
|
onPick(kind)
|
|
} label: {
|
|
HStack(spacing: 14) {
|
|
ZStack {
|
|
RoundedRectangle(cornerRadius: Tj.Radius.sm, style: .continuous)
|
|
.fill(kind.accent)
|
|
Image(systemName: kind.icon)
|
|
.font(.system(size: 18, weight: .medium))
|
|
.foregroundStyle(Tj.Palette.paper)
|
|
}
|
|
.frame(width: 44, height: 44)
|
|
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
Text(kind.title)
|
|
.font(.system(size: 15, weight: .semibold))
|
|
.foregroundStyle(Tj.Palette.text)
|
|
Text(kind.subtitle)
|
|
.font(.system(size: 12))
|
|
.foregroundStyle(Tj.Palette.text3)
|
|
}
|
|
Spacer()
|
|
Image(systemName: "chevron.right")
|
|
.font(.system(size: 14, weight: .medium))
|
|
.foregroundStyle(Tj.Palette.text3)
|
|
}
|
|
.padding(16)
|
|
.tjCard()
|
|
}
|
|
.buttonStyle(.plain)
|
|
}
|
|
}
|
|
.padding(.bottom, 22)
|
|
}
|
|
.scrollIndicators(.hidden)
|
|
}
|
|
.padding(.horizontal, 18)
|
|
.background(
|
|
Tj.Palette.sand
|
|
.clipShape(RoundedRectangle(cornerRadius: Tj.Radius.xl, style: .continuous))
|
|
.ignoresSafeArea(edges: .bottom)
|
|
)
|
|
.presentationDetents([.fraction(0.8)])
|
|
.presentationDragIndicator(.hidden)
|
|
.presentationBackground(Tj.Palette.sand)
|
|
.presentationCornerRadius(Tj.Radius.xl)
|
|
}
|
|
}
|
|
|
|
#Preview("RecordSheet · 直接渲染") {
|
|
RecordSheet { kind in print("picked: \(kind)") }
|
|
.frame(width: 390, height: 560)
|
|
.background(Tj.Palette.sand)
|
|
}
|
|
|
|
#Preview("RecordSheet · sheet 模式") {
|
|
PreviewContainer()
|
|
}
|
|
|
|
private struct PreviewContainer: View {
|
|
@State private var show = true
|
|
var body: some View {
|
|
Text("点这里再开一次")
|
|
.onTapGesture { show = true }
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
.background(Tj.Palette.sand.ignoresSafeArea())
|
|
.sheet(isPresented: $show) {
|
|
RecordSheet { kind in print("picked: \(kind)"); show = false }
|
|
}
|
|
}
|
|
}
|