PulseDetailView.swift
7.48 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
//
// PulseDetailView.swift
// hippo-watch Watch App
//
// Created by shihao on 2025/10/21.
//
import Foundation
import SwiftUI
struct PulseDetailView: View {
@StateObject private var userManager = WatchUserinfoManager.share
@State var pulseType: PulseType
var body: some View {
ZStack(alignment: .top) {
LinearGradient(colors: [.init(hex: "#EEE6FF"),
.init(hex: "#ECE3FF"),
.init(hex: "#EEE6FF"),
.init(hex: "#FFFFFF"),
],
startPoint: .top,
endPoint: .bottom)
.ignoresSafeArea()
Image(.pulseDetailBg)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: ScreenSize.width)
.frame(height: 280.x)
.ignoresSafeArea()
ScrollView {
VStack(alignment: .center, spacing: 12) {
pulseOverView
vipBanner
pulseCharacteristicView
traditionalChineseMedicineView
dietAdviceView
sportAdviceView
tipView
Spacer().frame(height: 40)
}
}
.ignoresSafeArea(.container, edges: .bottom)
}
}
@ViewBuilder
private var pulseOverView: some View {
VStack(spacing: 0) {
PulseWaveformView(pulseType: pulseType,
lineColor: .white)
.frame(width: 152.x, height: 85.x, alignment: .center)
.padding(.top, 34)
Text(pulseType.model.name)
.wenyiheiFont(size: 24)
.foregroundColor(.init(hex: "#2C2020"))
.padding(.top, 14)
Text(pulseType.model.characteristic)
.font(.custom("Songti SC Regular", size: 16))
.foregroundColor(.init(hex: "#896CDC"))
}
.padding(.top, 35)
.padding(.bottom, 20)
}
@ViewBuilder
private var vipBanner: some View {
if isVip == false {
HStack(spacing: 6) {
Image(.pulseDetailVipBannerIcon)
Text("前往手机APP开通会员\n即可查看脉象详情")
.font(.system(size: 14, weight: .semibold))
.foregroundColor(.init(hex: "#FFECBD"))
}
.padding(.horizontal, 10)
.frame(height: 52)
.background(
LinearGradient(colors: [.init(hex: "#4B2E78"),
.init(hex: "#794097")], startPoint: .leading, endPoint: .trailing)
)
.cornerRadius(12)
.padding(.bottom, 3)
}
}
@ViewBuilder
private var pulseCharacteristicView: some View {
HStack {
VStack(spacing: 4) {
ForEach(Array(pulseType.model.name), id: \.self) { char in
Text(String(char))
.font(.custom("Songti SC Bold", size: 16))
.foregroundColor(.white)
}
}
.background {
Image(.pulseDetailTitleBg)
}
.padding(.trailing, 12)
VStack(alignment: .leading, spacing: 7) {
Text("脉象特征")
.font(.custom("Songti SC Regular", size: 13))
.foregroundColor(.init(hex: "#896CDC"))
Text(pulseType.model.traditionalChineseMedicine.summary)
.font(.custom("Songti SC Bold", size: 13))
.foregroundColor(.init(hex: "#2C2020"))
.blur(radius: isVip ? 0 : 5)
}
}
.padding(.horizontal, 17)
.padding(.bottom, 3)
}
@ViewBuilder
private var traditionalChineseMedicineView: some View {
VStack(alignment: .leading, spacing: 2) {
HStack(alignment: .center, spacing: 2) {
Image(.pulseDetailZhongyiIcon)
Text("中医理论")
.wenyiheiFont(size: 12)
.foregroundColor(.init(hex: "#2C2020"))
Spacer()
}
Text(pulseType.model.traditionalChineseMedicine.bodyShape)
.font(.custom("Songti SC Bold", size: 13))
.foregroundColor(.init(hex: "#896CDC"))
.padding(.leading, 4)
.blur(radius: isVip ? 0 : 5)
if let mainDisease = pulseType.model.traditionalChineseMedicine.mainDisease {
Text(mainDisease)
.font(.custom("Songti SC Bold", size: 13))
.foregroundColor(.init(hex: "#896CDC"))
.padding(.leading, 4)
.blur(radius: isVip ? 0 : 5)
.padding(.bottom, 8)
}
}
.padding(.horizontal, 10)
.padding(.top, 12)
.padding(.bottom, 20)
.background(.white)
.cornerRadius(24)
.padding(.horizontal, 18)
}
@ViewBuilder
private var dietAdviceView: some View {
VStack(alignment: .leading, spacing: 2) {
HStack(alignment: .center, spacing: 2) {
Image(.pulseDetailDietIcon)
Text("饮食建议")
.wenyiheiFont(size: 12)
.foregroundColor(.init(hex: "#2C2020"))
Spacer()
}
Text(pulseType.model.dietAdvice)
.font(.custom("Songti SC Bold", size: 13))
.foregroundColor(.init(hex: "#896CDC"))
.padding(.leading, 4)
.blur(radius: isVip ? 0 : 5)
}
.padding(.horizontal, 10)
.padding(.top, 12)
.padding(.bottom, 17)
.background(.white)
.cornerRadius(24)
.padding(.horizontal, 18)
}
@ViewBuilder
private var sportAdviceView: some View {
VStack(alignment: .leading, spacing: 2) {
HStack(alignment: .center, spacing: 2) {
Image(.pulseDetailSportIcon)
Text("运动建议")
.wenyiheiFont(size: 12)
.foregroundColor(.init(hex: "#2C2020"))
Spacer()
}
Text(pulseType.model.sportAdvice)
.font(.custom("Songti SC Bold", size: 13))
.foregroundColor(.init(hex: "#896CDC"))
.padding(.leading, 4)
.blur(radius: isVip ? 0 : 5)
}
.padding(.horizontal, 10)
.padding(.top, 12)
.padding(.bottom, 18)
.background(.white)
.cornerRadius(24)
.padding(.horizontal, 18)
}
@ViewBuilder
private var tipView: some View {
Text(
"""
特别提醒
本结论中提供的建议仅供参考
如您有任何健康疑虑或不适症状
请及时咨询正规医疗机构或执业医师
"""
)
.font(.custom("Songti SC Regular", size: 9))
.foregroundColor(.init(hex: "#908B91"))
.multilineTextAlignment(.center)
.lineSpacing(6)
.padding(.top, 17)
.padding(.bottom, 24)
}
private var isVip: Bool {
return userManager.isMeVip ?? false
}
}