PulseModels.swift
6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//
// PulseModels.swift
// hippo-watch Watch App
//
import SwiftUI
enum PulseType: Int, Codable {
case fu = 1
case chen = 2
case chi = 3
case shu = 4
case hua = 5
case se = 6
case xu = 7
case pin = 8
var model: PulseModel {
switch self {
case .fu:
return PulseModel(
name: "浮脉",
characteristic: "轻取即得",
traditionalChineseMedicine: PulseTraditionalChineseMedicine(
summary: "脉位表浅,轻按明显,重按稍弱。",
bodyShape: "常见于外感初起、体表不适等状态。",
mainDisease: "注意保暖与休息。"
),
dietAdvice: "饮食宜清淡温和,少食生冷。",
sportAdvice: "适合低强度散步和舒展。"
)
case .chen:
return PulseModel(
name: "沉脉",
characteristic: "重按始得",
traditionalChineseMedicine: PulseTraditionalChineseMedicine(
summary: "脉位偏深,轻取不明显。",
bodyShape: "可能提示身体处于较疲惫或内在压力状态。",
mainDisease: "注意睡眠和规律作息。"
),
dietAdvice: "可选择温热易消化饮食。",
sportAdvice: "以轻量活动为主,避免过度消耗。"
)
case .chi:
return PulseModel(
name: "迟脉",
characteristic: "节律偏缓",
traditionalChineseMedicine: PulseTraditionalChineseMedicine(
summary: "脉来较缓,整体节奏偏慢。",
bodyShape: "可能与寒凉、代谢偏慢或疲劳相关。",
mainDisease: "注意保暖,观察身体状态。"
),
dietAdvice: "少食寒凉,适当补充温热汤水。",
sportAdvice: "适合缓慢热身后的轻运动。"
)
case .shu:
return PulseModel(
name: "数脉",
characteristic: "节律偏快",
traditionalChineseMedicine: PulseTraditionalChineseMedicine(
summary: "脉来较快,身体兴奋度偏高。",
bodyShape: "可能与紧张、运动后或睡眠不足相关。",
mainDisease: "先休息后复测更准确。"
),
dietAdvice: "减少辛辣刺激,补充水分。",
sportAdvice: "避免高强度训练,优先放松。"
)
case .hua:
return PulseModel(
name: "滑脉",
characteristic: "往来流利",
traditionalChineseMedicine: PulseTraditionalChineseMedicine(
summary: "脉象圆滑流畅,来去较利。",
bodyShape: "可见于身体能量较足或饮食偏丰盛时。",
mainDisease: nil
),
dietAdvice: "饮食保持均衡,避免过饱。",
sportAdvice: "适合规律有氧运动。"
)
case .se:
return PulseModel(
name: "涩脉",
characteristic: "往来艰涩",
traditionalChineseMedicine: PulseTraditionalChineseMedicine(
summary: "脉行不够流畅,节律感偏滞。",
bodyShape: "可能与疲劳、压力或循环状态相关。",
mainDisease: "建议持续观察。"
),
dietAdvice: "适当补水,饮食清淡。",
sportAdvice: "从舒缓拉伸开始,循序渐进。"
)
case .xu:
return PulseModel(
name: "虚脉",
characteristic: "按之无力",
traditionalChineseMedicine: PulseTraditionalChineseMedicine(
summary: "脉势偏弱,身体恢复感不足。",
bodyShape: "可能提示近期休息不足或消耗较多。",
mainDisease: "优先保证睡眠。"
),
dietAdvice: "选择高质量蛋白和温和主食。",
sportAdvice: "减少强度,安排恢复性活动。"
)
case .pin:
return PulseModel(
name: "平脉",
characteristic: "节律平稳",
traditionalChineseMedicine: PulseTraditionalChineseMedicine(
summary: "脉象较平稳,整体状态相对均衡。",
bodyShape: "继续保持规律作息和适度运动。",
mainDisease: nil
),
dietAdvice: "保持均衡饮食。",
sportAdvice: "可进行日常规律运动。"
)
}
}
var waveformImage: ImageResource {
switch self {
case .fu:
return .pulseWaveformFu
case .chen:
return .pulseWaveformChen
case .chi:
return .pulseWaveformChi
case .shu:
return .pulseWaveformShu
case .hua:
return .pulseWaveformHua
case .se:
return .pulseWaveformSe
case .xu:
return .pulseWaveformXu
case .pin:
return .pulseWaveformPin
}
}
}
struct PulseModel {
let name: String
let characteristic: String
let traditionalChineseMedicine: PulseTraditionalChineseMedicine
let dietAdvice: String
let sportAdvice: String
}
struct PulseTraditionalChineseMedicine {
let summary: String
let bodyShape: String
let mainDisease: String?
}
struct PulseWaveformView: View {
let pulseType: PulseType
var lineColor: Color = .white
var body: some View {
Image(pulseType.waveformImage)
.renderingMode(.template)
.resizable()
.scaledToFit()
.foregroundStyle(lineColor)
}
}